···793793as shared libraries only, i.e. there is just no static library available that
794794Cabal could link!
795795796796+### Building GHC with integer-simple
797797+798798+By default GHC implements the Integer type using the
799799+[GNU Multiple Precision Arithmetic (GMP) library](https://gmplib.org/).
800800+The implementation can be found in the
801801+[integer-gmp](http://hackage.haskell.org/package/integer-gmp) package.
802802+803803+A potential problem with this is that GMP is licensed under the
804804+[GNU Lesser General Public License (LGPL)](http://www.gnu.org/copyleft/lesser.html),
805805+a kind of "copyleft" license. According to the terms of the LGPL, paragraph 5,
806806+you may distribute a program that is designed to be compiled and dynamically
807807+linked with the library under the terms of your choice (i.e., commercially) but
808808+if your program incorporates portions of the library, if it is linked
809809+statically, then your program is a "derivative"--a "work based on the
810810+library"--and according to paragraph 2, section c, you "must cause the whole of
811811+the work to be licensed" under the terms of the LGPL (including for free).
812812+813813+The LGPL licensing for GMP is a problem for the overall licensing of binary
814814+programs compiled with GHC because most distributions (and builds) of GHC use
815815+static libraries. (Dynamic libraries are currently distributed only for OS X.)
816816+The LGPL licensing situation may be worse: even though
817817+[The Glasgow Haskell Compiler License](https://www.haskell.org/ghc/license)
818818+is essentially a "free software" license (BSD3), according to
819819+paragraph 2 of the LGPL, GHC must be distributed under the terms of the LGPL!
820820+821821+To work around these problems GHC can be build with a slower but LGPL-free
822822+alternative implemention for Integer called
823823+[integer-simple](http://hackage.haskell.org/package/integer-simple).
824824+825825+To get a GHC compiler build with `integer-simple` instead of `integer-gmp` use
826826+the attribute: `pkgs.haskell.compiler.integer-simple."${ghcVersion}"`.
827827+For example:
828828+829829+ $ nix-build -E '(import <nixpkgs> {}).pkgs.haskell.compiler.integer-simple.ghc802'
830830+ ...
831831+ $ result/bin/ghc-pkg list | grep integer
832832+ integer-simple-0.1.1.1
833833+834834+The following command displays the complete list of GHC compilers build with `integer-simple`:
835835+836836+ $ nix-env -f "<nixpkgs>" -qaP -A haskell.compiler.integer-simple
837837+ haskell.compiler.integer-simple.ghc7102 ghc-7.10.2
838838+ haskell.compiler.integer-simple.ghc7103 ghc-7.10.3
839839+ haskell.compiler.integer-simple.ghc722 ghc-7.2.2
840840+ haskell.compiler.integer-simple.ghc742 ghc-7.4.2
841841+ haskell.compiler.integer-simple.ghc763 ghc-7.6.3
842842+ haskell.compiler.integer-simple.ghc783 ghc-7.8.3
843843+ haskell.compiler.integer-simple.ghc784 ghc-7.8.4
844844+ haskell.compiler.integer-simple.ghc801 ghc-8.0.1
845845+ haskell.compiler.integer-simple.ghc802 ghc-8.0.2
846846+ haskell.compiler.integer-simple.ghcHEAD ghc-8.1.20170106
847847+848848+To get a package set supporting `integer-simple` use the attribute:
849849+`pkgs.haskell.packages.integer-simple."${ghcVersion}"`. For example
850850+use the following to get the `scientific` package build with `integer-simple`:
851851+852852+ $ nix-build -A pkgs.haskell.packages.integer-simple.ghc802.scientific
853853+796854797855## Other resources
798856
···2525 sha512 = "99cea54b553158c1e08cf19157ac2bb6822fd1fef0501d36f983e6b8d4f2143a2e6124d61297446944033d3fed9326fe0f12ca45db0b5815be71a0777e73ffb0";
2626 };
27272828+ patches = [ ./gcc6.patch ];
2929+2830 # New sed no longer tolerates this mistake.
2931 postPatch = ''
3032 for f in mozilla/{js/src,}/configure; do
···11+22+# HG changeset patch
33+# User Mike Hommey <mh+mozilla@glandium.org>
44+# Date 1457596445 -32400
55+# Node ID 55212130f19da3079167a6b0a5a0ed6689c9a71d
66+# Parent 27c94617d7064d566c24a42e11cd4c7ef725923d
77+Bug 1245076 - Don't include mozalloc.h from the cstdlib wrapper. r=froydnj
88+99+Our STL wrappers do various different things, one of which is including
1010+mozalloc.h for infallible operator new. mozalloc.h includes stdlib.h,
1111+which, in libstdc++ >= 6 is now itself a wrapper around cstdlib, which
1212+circles back to our STL wrapper.
1313+1414+But of the things our STL wrappers do, including mozalloc.h is not one
1515+that is necessary for cstdlib. So skip including mozalloc.h in our
1616+cstdlib wrapper.
1717+1818+Additionally, some C++ sources (in media/mtransport) are including
1919+headers in an extern "C" block, which end up including stdlib.h, which
2020+ends up including cstdlib because really, this is all C++, and our
2121+wrapper pre-includes <new> for mozalloc.h, which fails because templates
2222+don't work inside extern "C". So, don't pre-include <new> when we're not
2323+including mozalloc.h.
2424+2525+2626+diff --git a/mozilla/config/gcc-stl-wrapper.template.h b/mozilla/config/gcc-stl-wrapper.template.h
2727+--- a/mozilla/config/gcc-stl-wrapper.template.h
2828++++ b/mozilla/config/gcc-stl-wrapper.template.h
2929+@@ -12,33 +12,40 @@
3030+ // compiling ObjC.
3131+ #if defined(__EXCEPTIONS) && __EXCEPTIONS && !(__OBJC__ && __GNUC__ && XP_IOS)
3232+ # error "STL code can only be used with -fno-exceptions"
3333+ #endif
3434+3535+ // Silence "warning: #include_next is a GCC extension"
3636+ #pragma GCC system_header
3737+3838++// Don't include mozalloc for cstdlib. See bug 1245076.
3939++#ifndef moz_dont_include_mozalloc_for_cstdlib
4040++# define moz_dont_include_mozalloc_for_cstdlib
4141++#endif
4242++#ifndef moz_dont_include_mozalloc_for_${HEADER}
4343+ // mozalloc.h wants <new>; break the cycle by always explicitly
4444+ // including <new> here. NB: this is a tad sneaky. Sez the gcc docs:
4545+ //
4646+ // `#include_next' does not distinguish between <file> and "file"
4747+ // inclusion, nor does it check that the file you specify has the
4848+ // same name as the current file. It simply looks for the file
4949+ // named, starting with the directory in the search path after the
5050+ // one where the current file was found.
5151+-#include_next <new>
5252++# include_next <new>
5353+5454+ // See if we're in code that can use mozalloc. NB: this duplicates
5555+ // code in nscore.h because nscore.h pulls in prtypes.h, and chromium
5656+ // can't build with that being included before base/basictypes.h.
5757+-#if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
5858+-# include "mozilla/mozalloc.h"
5959+-#else
6060+-# error "STL code can only be used with infallible ::operator new()"
6161++# if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
6262++# include "mozilla/mozalloc.h"
6363++# else
6464++# error "STL code can only be used with infallible ::operator new()"
6565++# endif
6666++
6767+ #endif
6868+6969+ #if defined(DEBUG) && !defined(_GLIBCXX_DEBUG)
7070+ // Enable checked iterators and other goodies
7171+ //
7272+ // FIXME/bug 551254: gcc's debug STL implementation requires -frtti.
7373+ // Figure out how to resolve this with -fno-rtti. Maybe build with
7474+ // -frtti in DEBUG builds?
7575+
···1616 makeFlagsArray+=(PREFIX="$out" LIBDIRNAME=/lib)
1717 '';
18181919+ # Work around "libfaketime.c:513:7: error: nonnull argument 'buf' compared to NULL [-Werror=nonnull-compare]".
2020+ NIX_CFLAGS_COMPILE = "-Wno-nonnull-compare";
2121+1922 meta = with stdenv.lib; {
2023 description = "Report faked system time to programs without having to change the system-wide time";
2124 homepage = http://www.code-wizards.com/projects/libfaketime/;
···3232 # This is needed, for instance, so that running "ldd" on a binary that is
3333 # PaX-marked to disable mprotect doesn't fail with permission denied.
3434 ./pt-pax-flags.patch
3535+3636+ # Bfd looks in BINDIR/../lib for some plugins that don't
3737+ # exist. This is pointless (since users can't install plugins
3838+ # there) and causes a cycle between the lib and bin outputs, so
3939+ # get rid of it.
4040+ ./no-plugins.patch
3541 ];
36423737- outputs = [ "out" "info" ] ++ (optional (cross == null) "dev");
4343+ outputs = [ "out" ]
4444+ ++ optional (!stdenv.isDarwin) "lib" # problems in Darwin stdenv
4545+ ++ [ "info" ]
4646+ ++ optional (cross == null) "dev";
38473948 nativeBuildInputs = [ bison ];
4049 buildInputs = [ zlib ];