···1305 # Name of the compiler and package set you want to change. If you are using
1306 # the default package set `haskellPackages`, you need to look up what version
1307 # of GHC it currently uses (note that this is subject to change).
1308- ghcName = "ghc92";
1309 # Desired new setting
1310 enableProfiling = true;
1311
···1305 # Name of the compiler and package set you want to change. If you are using
1306 # the default package set `haskellPackages`, you need to look up what version
1307 # of GHC it currently uses (note that this is subject to change).
1308+ ghcName = "ghc910";
1309 # Desired new setting
1310 enableProfiling = true;
1311
+5-3
doc/release-notes/rl-2511.section.md
···2425- GCC 9, 10, 11, and 12 have been removed, as they have reached end‐of‐life upstream and are no longer supported.
2627-- GHC 8.6 and its package set have been removed. It was only used to bootstrap GHC for powerpc64le, but this was probably broken anyway.
28-29- GHCJS 8.10, exposed via `haskell.compiler.ghcjs` and `haskell.compiler.ghcjs810`, has been removed. Downstream users should migrate their projects to the new JavaScript backend of GHC proper which can be used via `pkgsCross.ghcjs` from Nixpkgs. Haskell packaging code, like `haskellPackages.mkDerivation`, `ghcWithPackages` and `hoogleWithPackages`, also no longer supports GHCJS.
3031-- GHC 9.0 and its package set have been removed.
00003233- `base16-builder` node package has been removed due to lack of upstream maintenance.
34
···2425- GCC 9, 10, 11, and 12 have been removed, as they have reached end‐of‐life upstream and are no longer supported.
260027- GHCJS 8.10, exposed via `haskell.compiler.ghcjs` and `haskell.compiler.ghcjs810`, has been removed. Downstream users should migrate their projects to the new JavaScript backend of GHC proper which can be used via `pkgsCross.ghcjs` from Nixpkgs. Haskell packaging code, like `haskellPackages.mkDerivation`, `ghcWithPackages` and `hoogleWithPackages`, also no longer supports GHCJS.
2829+- GHC 8.6, 8.10, 9.0, 9.2, and their package sets have been removed.
30+31+- Support for bootstrapping native GHC compilers on 32‐bit ARM and little‐endian 64‐bit PowerPC has been dropped.
32+ The latter was probably broken anyway.
33+ If there is interest in restoring support for these architectures, it should be possible to cross‐compile a bootstrap GHC binary.
3435- `base16-builder` node package has been removed due to lack of upstream maintenance.
36
+2-2
lib/options.nix
···267268 mkPackageOption pkgs "GHC" {
269 default = [ "ghc" ];
270- example = "pkgs.haskell.packages.ghc92.ghc.withPackages (hkgs: [ hkgs.primes ])";
271 }
272- => { ...; default = pkgs.ghc; defaultText = literalExpression "pkgs.ghc"; description = "The GHC package to use."; example = literalExpression "pkgs.haskell.packages.ghc92.ghc.withPackages (hkgs: [ hkgs.primes ])"; type = package; }
273274 mkPackageOption pkgs [ "python3Packages" "pytorch" ] {
275 extraDescription = "This is an example and doesn't actually do anything.";
···267268 mkPackageOption pkgs "GHC" {
269 default = [ "ghc" ];
270+ example = "pkgs.haskellPackages.ghc.withPackages (hkgs: [ hkgs.primes ])";
271 }
272+ => { ...; default = pkgs.ghc; defaultText = literalExpression "pkgs.ghc"; description = "The GHC package to use."; example = literalExpression "pkgs.haskellPackages.ghc.withPackages (hkgs: [ hkgs.primes ])"; type = package; }
273274 mkPackageOption pkgs [ "python3Packages" "pytorch" ] {
275 extraDescription = "This is an example and doesn't actually do anything.";
···6 and builds all derivations (or at least a reasonable subset) affected by
7 these overrides.
89- By default, it checks `configuration-{common,nix,ghc-8.10.x}.nix`. You can
10 invoke it like this:
1112 nix-build maintainers/scripts/haskell/test-configurations.nix --keep-going
···50 files ? [
51 "configuration-common.nix"
52 "configuration-nix.nix"
53- "configuration-ghc-8.10.x.nix"
54 ],
55 nixpkgsPath ? ../../..,
56 config ? {
···6 and builds all derivations (or at least a reasonable subset) affected by
7 these overrides.
89+ By default, it checks `configuration-{common,nix,ghc-9.8.x}.nix`. You can
10 invoke it like this:
1112 nix-build maintainers/scripts/haskell/test-configurations.nix --keep-going
···50 files ? [
51 "configuration-common.nix"
52 "configuration-nix.nix"
53+ "configuration-ghc-9.8.x.nix"
54 ],
55 nixpkgsPath ? ../../..,
56 config ? {
···74 haskellPackages = mkOption {
75 default = pkgs.haskellPackages;
76 defaultText = literalExpression "pkgs.haskellPackages";
77- example = literalExpression "pkgs.haskell.packages.ghc810";
78 type = types.attrs;
79 description = ''
80 haskellPackages used to build Xmonad and other packages.
···74 haskellPackages = mkOption {
75 default = pkgs.haskellPackages;
76 defaultText = literalExpression "pkgs.haskellPackages";
77+ example = literalExpression "pkgs.haskell.packages.ghc910";
78 type = types.attrs;
79 description = ''
80 haskellPackages used to build Xmonad and other packages.
-546
pkgs/development/compilers/ghc/8.10.7-binary.nix
···1-{
2- lib,
3- stdenv,
4- fetchurl,
5- perl,
6- gcc,
7- ncurses5,
8- ncurses6,
9- gmp,
10- libiconv,
11- numactl,
12- llvmPackages,
13- coreutils,
14- rcodesign,
15- targetPackages,
16-17- # minimal = true; will remove files that aren't strictly necessary for
18- # regular builds and GHC bootstrapping.
19- # This is "useful" for staying within hydra's output limits for at least the
20- # aarch64-linux architecture.
21- minimal ? false,
22-}:
23-24-# Prebuilt only does native
25-assert stdenv.targetPlatform == stdenv.hostPlatform;
26-27-let
28- downloadsUrl = "https://downloads.haskell.org/ghc";
29-30- # Copy sha256 from https://downloads.haskell.org/~ghc/8.10.7/SHA256SUMS
31- version = "8.10.7";
32-33- # Information about available bindists that we use in the build.
34- #
35- # # Bindist library checking
36- #
37- # The field `archSpecificLibraries` also provides a way for us get notified
38- # early when the upstream bindist changes its dependencies (e.g. because a
39- # newer Debian version is used that uses a new `ncurses` version).
40- #
41- # Usage:
42- #
43- # * You can find the `fileToCheckFor` of libraries by running `readelf -d`
44- # on the compiler binary (`exePathForLibraryCheck`).
45- # * To skip library checking for an architecture,
46- # set `exePathForLibraryCheck = null`.
47- # * To skip file checking for a specific arch specific library,
48- # set `fileToCheckFor = null`.
49- ghcBinDists = {
50- # Binary distributions for the default libc (e.g. glibc, or libSystem on Darwin)
51- # nixpkgs uses for the respective system.
52- defaultLibc = {
53- i686-linux = {
54- variantSuffix = "";
55- src = {
56- url = "${downloadsUrl}/${version}/ghc-${version}-i386-deb9-linux.tar.xz";
57- sha256 = "fbfc1ef194f4e7a4c0da8c11cc69b17458a4b928b609b3622c97acc4acd5c5ab";
58- };
59- exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
60- archSpecificLibraries = [
61- {
62- nixPackage = gmp;
63- fileToCheckFor = null;
64- }
65- # The i686-linux bindist provided by GHC HQ is currently built on Debian 9,
66- # which link it against `libtinfo.so.5` (ncurses 5).
67- # Other bindists are linked `libtinfo.so.6` (ncurses 6).
68- {
69- nixPackage = ncurses5;
70- fileToCheckFor = "libtinfo.so.5";
71- }
72- ];
73- };
74- x86_64-linux = {
75- variantSuffix = "";
76- src = {
77- url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-deb10-linux.tar.xz";
78- sha256 = "a13719bca87a0d3ac0c7d4157a4e60887009a7f1a8dbe95c4759ec413e086d30";
79- };
80- exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
81- archSpecificLibraries = [
82- {
83- nixPackage = gmp;
84- fileToCheckFor = null;
85- }
86- {
87- nixPackage = ncurses6;
88- fileToCheckFor = "libtinfo.so.6";
89- }
90- ];
91- };
92- armv7l-linux = {
93- variantSuffix = "";
94- src = {
95- url = "${downloadsUrl}/${version}/ghc-${version}-armv7-deb10-linux.tar.xz";
96- sha256 = "3949c31bdf7d3b4afb765ea8246bca4ca9707c5d988d9961a244f0da100956a2";
97- };
98- exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
99- archSpecificLibraries = [
100- {
101- nixPackage = gmp;
102- fileToCheckFor = null;
103- }
104- {
105- nixPackage = ncurses6;
106- fileToCheckFor = "libtinfo.so.6";
107- }
108- ];
109- };
110- aarch64-linux = {
111- variantSuffix = "";
112- src = {
113- url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-deb10-linux.tar.xz";
114- sha256 = "fad2417f9b295233bf8ade79c0e6140896359e87be46cb61cd1d35863d9d0e55";
115- };
116- exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
117- archSpecificLibraries = [
118- {
119- nixPackage = gmp;
120- fileToCheckFor = null;
121- }
122- {
123- nixPackage = ncurses6;
124- fileToCheckFor = "libtinfo.so.6";
125- }
126- {
127- nixPackage = numactl;
128- fileToCheckFor = null;
129- }
130- ];
131- };
132- x86_64-darwin = {
133- variantSuffix = "";
134- src = {
135- url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz";
136- sha256 = "287db0f9c338c9f53123bfa8731b0996803ee50f6ee847fe388092e5e5132047";
137- };
138- exePathForLibraryCheck = null; # we don't have a library check for darwin yet
139- archSpecificLibraries = [
140- {
141- nixPackage = gmp;
142- fileToCheckFor = null;
143- }
144- {
145- nixPackage = ncurses6;
146- fileToCheckFor = null;
147- }
148- {
149- nixPackage = libiconv;
150- fileToCheckFor = null;
151- }
152- ];
153- };
154- aarch64-darwin = {
155- variantSuffix = "";
156- src = {
157- url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-apple-darwin.tar.xz";
158- sha256 = "dc469fc3c35fd2a33a5a575ffce87f13de7b98c2d349a41002e200a56d9bba1c";
159- };
160- exePathForLibraryCheck = null; # we don't have a library check for darwin yet
161- archSpecificLibraries = [
162- {
163- nixPackage = gmp;
164- fileToCheckFor = null;
165- }
166- {
167- nixPackage = ncurses6;
168- fileToCheckFor = null;
169- }
170- {
171- nixPackage = libiconv;
172- fileToCheckFor = null;
173- }
174- ];
175- };
176- };
177- # Binary distributions for the musl libc for the respective system.
178- musl = {
179- x86_64-linux = {
180- variantSuffix = "-musl-integer-simple";
181- src = {
182- url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-alpine3.10-linux-integer-simple.tar.xz";
183- sha256 = "16903df850ef73d5246f2ff169cbf57ecab76c2ac5acfa9928934282cfad575c";
184- };
185- exePathForLibraryCheck = "bin/ghc";
186- archSpecificLibraries = [
187- # No `gmp` here, since this is an `integer-simple` bindist.
188-189- # In contrast to glibc builds, the musl-bindist uses `libncursesw.so.*`
190- # instead of `libtinfo.so.*.`
191- {
192- nixPackage = ncurses6;
193- fileToCheckFor = "libncursesw.so.6";
194- }
195- ];
196- isHadrian = true;
197- };
198- };
199- };
200-201- distSetName = if stdenv.hostPlatform.isMusl then "musl" else "defaultLibc";
202-203- binDistUsed =
204- ghcBinDists.${distSetName}.${stdenv.hostPlatform.system}
205- or (throw "cannot bootstrap GHC on this platform ('${stdenv.hostPlatform.system}' with libc '${distSetName}')");
206-207- useLLVM = !(import ./common-have-ncg.nix { inherit lib stdenv version; });
208-209- libPath = lib.makeLibraryPath (
210- # Add arch-specific libraries.
211- map ({ nixPackage, ... }: nixPackage) binDistUsed.archSpecificLibraries
212- );
213-214- libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY" + "LD_LIBRARY_PATH";
215-216- runtimeDeps = [
217- targetPackages.stdenv.cc
218- targetPackages.stdenv.cc.bintools
219- coreutils # for cat
220- ]
221- ++ lib.optionals useLLVM [
222- (lib.getBin llvmPackages.llvm)
223- ]
224- # On darwin, we need unwrapped bintools as well (for otool)
225- ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [
226- targetPackages.stdenv.cc.bintools.bintools
227- ];
228-229-in
230-231-stdenv.mkDerivation {
232- inherit version;
233- pname = "ghc-binary${binDistUsed.variantSuffix}";
234-235- src = fetchurl binDistUsed.src;
236-237- # Note that for GHC 8.10 versions >= 8.10.6, the GHC HQ musl bindist
238- # uses `integer-simple` and has no `gmp` dependency:
239- # https://gitlab.haskell.org/ghc/ghc/-/commit/8306501020cd66f683ad9c215fa8e16c2d62357d
240- # Related nixpkgs issues:
241- # * https://github.com/NixOS/nixpkgs/pull/130441#issuecomment-922452843
242- # TODO: When this file is copied to `ghc-9.*-binary.nix`, determine whether
243- # the GHC 9 branch also switched from `gmp` to `integer-simple` via the
244- # currently-open issue:
245- # https://gitlab.haskell.org/ghc/ghc/-/issues/20059
246- # and update this comment accordingly.
247-248- nativeBuildInputs = [
249- perl
250- ]
251- # Upstream binaries may not be linker-signed, which invalidates their signatures
252- # because `install_name_tool` will only replace a signature if it is both
253- # an ad hoc signature and the signature is flagged as linker-signed.
254- #
255- # rcodesign is used to replace the signature instead of sigtool because it
256- # supports setting the linker-signed flag, which will ensure future processing
257- # of the binaries does not invalidate their signatures.
258- ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ rcodesign ];
259-260- # Set LD_LIBRARY_PATH or equivalent so that the programs running as part
261- # of the bindist installer can find the libraries they expect.
262- # Cannot patchelf beforehand due to relative RPATHs that anticipate
263- # the final install location.
264- ${libEnvVar} = libPath;
265-266- postUnpack =
267- # Verify our assumptions of which `libtinfo.so` (ncurses) version is used,
268- # so that we know when ghc bindists upgrade that and we need to update the
269- # version used in `libPath`.
270- lib.optionalString (binDistUsed.exePathForLibraryCheck != null)
271- # Note the `*` glob because some GHCs have a suffix when unpacked, e.g.
272- # the musl bindist has dir `ghc-VERSION-x86_64-unknown-linux/`.
273- # As a result, don't shell-quote this glob when splicing the string.
274- (
275- let
276- buildExeGlob = ''ghc-${version}*/"${binDistUsed.exePathForLibraryCheck}"'';
277- in
278- lib.concatStringsSep "\n" [
279- (''
280- shopt -u nullglob
281- echo "Checking that ghc binary exists in bindist at ${buildExeGlob}"
282- if ! test -e ${buildExeGlob}; then
283- echo >&2 "GHC binary ${binDistUsed.exePathForLibraryCheck} could not be found in the bindist build directory (at ${buildExeGlob}) for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
284- fi
285- '')
286- (lib.concatMapStringsSep "\n" (
287- { fileToCheckFor, nixPackage }:
288- lib.optionalString (fileToCheckFor != null) ''
289- echo "Checking bindist for ${fileToCheckFor} to ensure that is still used"
290- if ! readelf -d ${buildExeGlob} | grep "${fileToCheckFor}"; then
291- echo >&2 "File ${fileToCheckFor} could not be found in ${binDistUsed.exePathForLibraryCheck} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
292- fi
293-294- echo "Checking that the nix package ${nixPackage} contains ${fileToCheckFor}"
295- if ! test -e "${lib.getLib nixPackage}/lib/${fileToCheckFor}"; then
296- echo >&2 "Nix package ${nixPackage} did not contain ${fileToCheckFor} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
297- fi
298- ''
299- ) binDistUsed.archSpecificLibraries)
300- ]
301- )
302- # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
303- # during linking
304- + lib.optionalString stdenv.hostPlatform.isDarwin (
305- ''
306- export NIX_LDFLAGS+=" -no_dtrace_dof"
307- # not enough room in the object files for the full path to libiconv :(
308- for exe in $(find . -type f -executable); do
309- isScript $exe && continue
310- ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
311- install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $exe
312- ''
313- + lib.optionalString stdenv.hostPlatform.isAarch64 ''
314- # Resign the binary and set the linker-signed flag. Ignore failures when the file is an object file.
315- # Object files don’t have signatures, so ignoring the failures is harmless.
316- rcodesign sign --code-signature-flags linker-signed $exe || true
317- ''
318- + ''
319- done
320- ''
321- )
322- +
323-324- # Some scripts used during the build need to have their shebangs patched
325- ''
326- patchShebangs ghc-${version}/utils/
327- patchShebangs ghc-${version}/configure
328- test -d ghc-${version}/inplace/bin && \
329- patchShebangs ghc-${version}/inplace/bin
330- ''
331- +
332- # We have to patch the GMP paths for the integer-gmp package.
333- # Note that musl bindists do not contain them,
334- # see: https://gitlab.haskell.org/ghc/ghc/-/issues/20073#note_363231
335- # However, musl bindists >= 8.10.6 use `integer-simple`, not `gmp`.
336- ''
337- find . -name integer-gmp.buildinfo \
338- -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
339- ''
340- + lib.optionalString stdenv.hostPlatform.isDarwin ''
341- find . -name base.buildinfo \
342- -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
343- ''
344- +
345- # Some platforms do HAVE_NUMA so -lnuma requires it in library-dirs in rts/package.conf.in
346- # FFI_LIB_DIR is a good indication of places it must be needed.
347- lib.optionalString
348- (
349- lib.meta.availableOn stdenv.hostPlatform numactl
350- && builtins.any ({ nixPackage, ... }: nixPackage == numactl) binDistUsed.archSpecificLibraries
351- )
352- ''
353- find . -name package.conf.in \
354- -exec sed -i "s@FFI_LIB_DIR@FFI_LIB_DIR ${numactl.out}/lib@g" {} \;
355- ''
356- +
357- # Rename needed libraries and binaries, fix interpreter
358- lib.optionalString stdenv.hostPlatform.isLinux ''
359- find . -type f -executable -exec patchelf \
360- --interpreter ${stdenv.cc.bintools.dynamicLinker} {} \;
361- ''
362- +
363- # The hadrian install Makefile uses 'xxx' as a temporary placeholder in path
364- # substitution. Which can break the build if the store path / prefix happens
365- # to contain this string. This will be fixed with 9.4 bindists.
366- # https://gitlab.haskell.org/ghc/ghc/-/issues/21402
367- ''
368- # Detect hadrian Makefile by checking for the target that has the problem
369- if grep '^update_package_db' ghc-${version}*/Makefile > /dev/null; then
370- echo Hadrian bindist, applying workaround for xxx path substitution.
371- # based on https://gitlab.haskell.org/ghc/ghc/-/commit/dd5fecb0e2990b192d92f4dfd7519ecb33164fad.patch
372- substituteInPlace ghc-${version}*/Makefile --replace 'xxx' '\0xxx\0'
373- else
374- echo Not a hadrian bindist, not applying xxx path workaround.
375- fi
376- '';
377-378- # fix for `configure: error: Your linker is affected by binutils #16177`
379- preConfigure = lib.optionalString stdenv.targetPlatform.isAarch32 "LD=ld.gold";
380-381- configurePlatforms = [ ];
382- configureFlags = [
383- "--with-gmp-includes=${lib.getDev gmp}/include"
384- # Note `--with-gmp-libraries` does nothing for GHC bindists:
385- # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6124
386- ]
387- ++ lib.optional stdenv.hostPlatform.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"
388- # From: https://github.com/NixOS/nixpkgs/pull/43369/commits
389- ++ lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
390-391- # No building is necessary, but calling make without flags ironically
392- # calls install-strip ...
393- dontBuild = true;
394-395- # GHC tries to remove xattrs when installing to work around Gatekeeper
396- # (see https://gitlab.haskell.org/ghc/ghc/-/issues/17418). This step normally
397- # succeeds in nixpkgs because xattrs are not allowed in the store, but it
398- # can fail when a file has the `com.apple.provenance` xattr, and it can’t be
399- # modified (such as target of the symlink to `libiconv.dylib`).
400- # The `com.apple.provenance` xattr is a new feature of macOS as of macOS 13.
401- # See: https://eclecticlight.co/2023/03/13/ventura-has-changed-app-quarantine-with-a-new-xattr/
402- makeFlags = lib.optionals stdenv.buildPlatform.isDarwin [ "XATTR=/does-not-exist" ];
403-404- # Patch scripts to include runtime dependencies in $PATH.
405- postInstall = ''
406- for i in "$out/bin/"*; do
407- test ! -h "$i" || continue
408- isScript "$i" || continue
409- sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i"
410- done
411- '';
412-413- # Apparently necessary for the ghc Alpine (musl) bindist:
414- # When we strip, and then run the
415- # patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
416- # below, running ghc (e.g. during `installCheckPhase)` gives some apparently
417- # corrupted rpath or whatever makes the loader work on nonsensical strings:
418- # running install tests
419- # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: : symbol not found
420- # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: ir6zf6c9f86pfx8sr30n2vjy-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/../lib/x86_64-linux-ghc-8.10.5/libHSexceptions-0.10.4-ghc8.10.5.so: symbol not found
421- # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: y/lib/ghc-8.10.5/bin/../lib/x86_64-linux-ghc-8.10.5/libHStemplate-haskell-2.16.0.0-ghc8.10.5.so: symbol not found
422- # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: 8.10.5/libHStemplate-haskell-2.16.0.0-ghc8.10.5.so: symbol not found
423- # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: �: symbol not found
424- # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: �?: symbol not found
425- # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: 64-linux-ghc-8.10.5/libHSexceptions-0.10.4-ghc8.10.5.so: symbol not found
426- # This is extremely bogus and should be investigated.
427- dontStrip = if stdenv.hostPlatform.isMusl then true else false; # `if` for explicitness
428-429- # On Linux, use patchelf to modify the executables so that they can
430- # find editline/gmp.
431- postFixup =
432- lib.optionalString stdenv.hostPlatform.isLinux (
433- if stdenv.hostPlatform.isAarch64 then
434- # Keep rpath as small as possible on aarch64 for patchelf#244. All Elfs
435- # are 2 directories deep from $out/lib, so pooling symlinks there makes
436- # a short rpath.
437- ''
438- (cd $out/lib; ln -s ${ncurses6.out}/lib/libtinfo.so.6)
439- (cd $out/lib; ln -s ${gmp.out}/lib/libgmp.so.10)
440- (cd $out/lib; ln -s ${numactl.out}/lib/libnuma.so.1)
441- for p in $(find "$out/lib" -type f -name "*\.so*"); do
442- (cd $out/lib; ln -s $p)
443- done
444-445- for p in $(find "$out/lib" -type f -executable); do
446- if isELF "$p"; then
447- echo "Patchelfing $p"
448- patchelf --set-rpath "\$ORIGIN:\$ORIGIN/../.." $p
449- fi
450- done
451- ''
452- else
453- ''
454- for p in $(find "$out" -type f -executable); do
455- if isELF "$p"; then
456- echo "Patchelfing $p"
457- patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
458- fi
459- done
460- ''
461- )
462- + lib.optionalString stdenv.hostPlatform.isDarwin ''
463- # not enough room in the object files for the full path to libiconv :(
464- for exe in $(find "$out" -type f -executable); do
465- isScript $exe && continue
466- ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
467- install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $exe
468- done
469-470- for file in $(find "$out" -name setup-config); do
471- substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
472- done
473- ''
474- + lib.optionalString minimal ''
475- # Remove profiling files
476- find $out -type f -name '*.p_o' -delete
477- find $out -type f -name '*.p_hi' -delete
478- find $out -type f -name '*_p.a' -delete
479- # `-f` because e.g. musl bindist does not have this file.
480- rm -f $out/lib/ghc-*/bin/ghc-iserv-prof
481- # Hydra will redistribute this derivation, so we have to keep the docs for
482- # legal reasons (retaining the legal notices etc)
483- # As a last resort we could unpack the docs separately and symlink them in.
484- # They're in $out/share/{doc,man}.
485- '';
486-487- # GHC cannot currently produce outputs that are ready for `-pie` linking.
488- # Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
489- # See:
490- # * https://github.com/NixOS/nixpkgs/issues/129247
491- # * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
492- hardeningDisable = [ "pie" ];
493-494- doInstallCheck = true;
495- installCheckPhase = ''
496- # Sanity check, can ghc create executables?
497- cd $TMP
498- mkdir test-ghc; cd test-ghc
499- cat > main.hs << EOF
500- {-# LANGUAGE TemplateHaskell #-}
501- module Main where
502- main = putStrLn \$([|"yes"|])
503- EOF
504- env -i $out/bin/ghc --make main.hs || exit 1
505- echo compilation ok
506- [ $(./main) == "yes" ]
507- '';
508-509- passthru = {
510- targetPrefix = "";
511- enableShared = true;
512-513- inherit llvmPackages;
514-515- # Our Cabal compiler name
516- haskellCompilerName = "ghc-${version}";
517- }
518- # We duplicate binDistUsed here since we have a sensible default even if no bindist is available,
519- # this makes sure that getting the `meta` attribute doesn't throw even on unsupported platforms.
520- // lib.optionalAttrs (ghcBinDists.${distSetName}.${stdenv.hostPlatform.system}.isHadrian or false) {
521- # Normal GHC derivations expose the hadrian derivation used to build them
522- # here. In the case of bindists we just make sure that the attribute exists,
523- # as it is used for checking if a GHC derivation has been built with hadrian.
524- # The isHadrian mechanism will become obsolete with GHCs that use hadrian
525- # exclusively, i.e. 9.6 (and 9.4?).
526- hadrian = null;
527- };
528-529- meta = rec {
530- homepage = "http://haskell.org/ghc";
531- description = "Glasgow Haskell Compiler";
532- license = lib.licenses.bsd3;
533- # HACK: since we can't encode the libc / abi in platforms, we need
534- # to make the platform list dependent on the evaluation platform
535- # in order to avoid eval errors with musl which supports less
536- # platforms than the default libcs (i. e. glibc / libSystem).
537- # This is done for the benefit of Hydra, so `packagePlatforms`
538- # won't return any platforms that would cause an evaluation
539- # failure for `pkgsMusl.haskell.compiler.ghc8107Binary`, as
540- # long as the evaluator runs on a platform that supports
541- # `pkgsMusl`.
542- platforms = builtins.attrNames ghcBinDists.${distSetName};
543- maintainers = with lib.maintainers; [ ];
544- teams = [ lib.teams.haskell ];
545- };
546-}
···1-let
2- version = "8.10.7";
3-in
4-5-{
6- lib,
7- stdenv,
8- pkgsBuildTarget,
9- pkgsHostTarget,
10- buildPackages,
11- targetPackages,
12-13- # build-tools
14- bootPkgs,
15- autoreconfHook,
16- autoconf,
17- automake,
18- coreutils,
19- fetchpatch,
20- fetchurl,
21- perl,
22- python3,
23- m4,
24- sphinx,
25- xattr,
26- autoSignDarwinBinariesHook,
27- bash,
28-29- libiconv ? null,
30- ncurses,
31-32- # GHC can be built with system libffi or a bundled one.
33- # we explicitly use libffi-3.3 here because 3.4 removes a flag that causes
34- # problems for ghc-8.10.7's RTS. See #324384.
35- # Save for aarch_darwin since libffi-3.3 is broken there but the issue isn't present anyway
36- libffi ? null,
37- libffi_3_3 ? null,
38-39- useLLVM ? !(import ./common-have-ncg.nix { inherit lib stdenv version; }),
40- # LLVM is conceptually a run-time-only dependency, but for
41- # non-x86, we need LLVM to bootstrap later stages, so it becomes a
42- # build-time dependency too.
43- buildTargetLlvmPackages,
44- llvmPackages,
45-46- # If enabled, GHC will be built with the GPL-free but slower integer-simple
47- # library instead of the faster but GPLed integer-gmp library.
48- enableIntegerSimple ?
49- !(lib.meta.availableOn stdenv.hostPlatform gmp && lib.meta.availableOn stdenv.targetPlatform gmp),
50- gmp,
51-52- # If enabled, use -fPIC when compiling static libs.
53- enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform,
54-55- # Exceeds Hydra output limit (at the time of writing ~3GB) when cross compiled to riscv64.
56- # A riscv64 cross-compiler fits into the limit comfortably.
57- enableProfiledLibs ? !stdenv.hostPlatform.isRiscV64,
58-59- # Whether to build dynamic libs for the standard library (on the target
60- # platform). Static libs are always built.
61- enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt,
62-63- # Whether to build terminfo.
64- enableTerminfo ?
65- !(
66- stdenv.targetPlatform.isWindows
67- # terminfo can't be built for cross
68- || (stdenv.buildPlatform != stdenv.hostPlatform)
69- || (stdenv.hostPlatform != stdenv.targetPlatform)
70- ),
71-72- # Enable NUMA support in RTS
73- enableNuma ? lib.meta.availableOn stdenv.targetPlatform numactl,
74- numactl,
75-76- # What flavour to build. An empty string indicates no
77- # specific flavour and falls back to ghc default values.
78- ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) (
79- if useLLVM then "perf-cross" else "perf-cross-ncg"
80- ),
81-82- # Whether to build sphinx documentation.
83- enableDocs ? (
84- # Docs disabled if we are building on musl because it's a large task to keep
85- # all `sphinx` dependencies building in this environment.
86- !stdenv.buildPlatform.isMusl
87- ),
88-89- enableHaddockProgram ?
90- # Disabled for cross; see note [HADDOCK_DOCS].
91- (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform),
92-93- # Whether to disable the large address space allocator
94- # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
95- disableLargeAddressSpace ? stdenv.targetPlatform.isiOS,
96-97- # Whether to build an unregisterised version of GHC.
98- # GHC will normally auto-detect whether it can do a registered build, but this
99- # option will force it to do an unregistered build when set to true.
100- # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised
101- enableUnregisterised ? false,
102-}@args:
103-104-assert !enableIntegerSimple -> gmp != null;
105-106-# Cross cannot currently build the `haddock` program for silly reasons,
107-# see note [HADDOCK_DOCS].
108-assert
109- (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform)
110- -> !enableHaddockProgram;
111-112-# GHC does not support building when all 3 platforms are different.
113-assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform;
114-115-let
116- inherit (stdenv) buildPlatform hostPlatform targetPlatform;
117-118- # TODO(@Ericson2314) Make unconditional
119- targetPrefix = lib.optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-";
120-121- buildMK = ''
122- BuildFlavour = ${ghcFlavour}
123- ifneq \"\$(BuildFlavour)\" \"\"
124- include mk/flavours/\$(BuildFlavour).mk
125- endif
126- BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
127- BUILD_SPHINX_PDF = NO
128-129- WITH_TERMINFO = ${if enableTerminfo then "YES" else "NO"}
130- ''
131- +
132- # Note [HADDOCK_DOCS]:
133- # Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
134- # program is built (which we generally always want to have a complete GHC install)
135- # and whether it is run on the GHC sources to generate hyperlinked source code
136- # (which is impossible for cross-compilation); see:
137- # https://gitlab.haskell.org/ghc/ghc/-/issues/20077
138- # This implies that currently a cross-compiled GHC will never have a `haddock`
139- # program, so it can never generate haddocks for any packages.
140- # If this is solved in the future, we'd like to unconditionally
141- # build the haddock program (removing the `enableHaddockProgram` option).
142- ''
143- HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
144- # Build haddocks for boot packages with hyperlinking
145- EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump
146-147- DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
148- INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"}
149- ''
150- + lib.optionalString (targetPlatform != hostPlatform) ''
151- Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
152- CrossCompilePrefix = ${targetPrefix}
153- ''
154- + lib.optionalString (!enableProfiledLibs) ''
155- BUILD_PROF_LIBS = NO
156- ''
157- + lib.optionalString enableRelocatedStaticLibs ''
158- GhcLibHcOpts += -fPIC
159- GhcRtsHcOpts += -fPIC
160- ''
161- + lib.optionalString targetPlatform.useAndroidPrebuilt ''
162- EXTRA_CC_OPTS += -std=gnu99
163- ''
164- # While split sections are now enabled by default in ghc 8.8 for windows,
165- # they seem to lead to `too many sections` errors when building base for
166- # profiling.
167- + lib.optionalString targetPlatform.isWindows ''
168- SplitSections = NO
169- '';
170-171- # Splicer will pull out correct variations
172- libDeps =
173- platform:
174- lib.optional enableTerminfo ncurses
175- ++ [ args.${libffi_name} ]
176- ++ lib.optional (!enableIntegerSimple) gmp
177- ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
178-179- # TODO(@sternenseemann): is buildTarget LLVM unnecessary?
180- # GHC doesn't seem to have {LLC,OPT}_HOST
181- toolsForTarget = [
182- pkgsBuildTarget.targetPackages.stdenv.cc
183- ]
184- ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
185-186- buildCC = buildPackages.stdenv.cc;
187- targetCC = builtins.head toolsForTarget;
188- installCC = pkgsHostTarget.targetPackages.stdenv.cc;
189-190- # toolPath calculates the absolute path to the name tool associated with a
191- # given `stdenv.cc` derivation, i.e. it picks the correct derivation to take
192- # the tool from (cc, cc.bintools, cc.bintools.bintools) and adds the correct
193- # subpath of the tool.
194- toolPath =
195- name: cc:
196- let
197- tools =
198- {
199- "cc" = cc;
200- "c++" = cc;
201- as = cc.bintools;
202-203- ar = cc.bintools;
204- ranlib = cc.bintools;
205- nm = cc.bintools;
206- readelf = cc.bintools;
207- objdump = cc.bintools;
208-209- ld = cc.bintools;
210- "ld.gold" = cc.bintools;
211-212- otool = cc.bintools.bintools;
213-214- # GHC needs install_name_tool on all darwin platforms. The same one can
215- # be used on both platforms. It is safe to use with linker-generated
216- # signatures because it will update the signatures automatically after
217- # modifying the target binary.
218- install_name_tool = cc.bintools.bintools;
219-220- # strip on darwin is wrapped to enable deterministic mode.
221- strip =
222- # TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
223- if stdenv.targetPlatform.isDarwin then cc.bintools else cc.bintools.bintools;
224-225- # clang is used as an assembler on darwin with the LLVM backend
226- clang = cc;
227- }
228- .${name};
229- in
230- "${tools}/bin/${tools.targetPrefix}${name}";
231-232- # Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
233- # But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
234- # see #84670 and #49071 for more background.
235- useLdGold =
236- targetPlatform.linker == "gold"
237- || (
238- targetPlatform.linker == "bfd"
239- && (targetCC.bintools.bintools.hasGold or false)
240- && !targetPlatform.isMusl
241- );
242-243- # Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
244- variantSuffix = lib.concatStrings [
245- (lib.optionalString stdenv.hostPlatform.isMusl "-musl")
246- (lib.optionalString enableIntegerSimple "-integer-simple")
247- ];
248-249- libffi_name =
250- if stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64 then "libffi" else "libffi_3_3";
251-252- # These libraries are library dependencies of the standard libraries bundled
253- # by GHC (core libs) users will link their compiled artifacts again. Thus,
254- # they should be taken from targetPackages.
255- #
256- # We need to use pkgsHostTarget if we are cross compiling a native GHC compiler,
257- # though (when native compiling GHC, pkgsHostTarget == targetPackages):
258- #
259- # 1. targetPackages would be empty(-ish) in this situation since we can't
260- # execute cross compiled compilers in order to obtain the libraries
261- # that would be in targetPackages.
262- # 2. pkgsHostTarget is fine to use since hostPlatform == targetPlatform in this
263- # situation.
264- # 3. The core libs used by the final GHC (stage 2) for user artifacts are also
265- # used to build stage 2 GHC itself, i.e. the core libs are both host and
266- # target.
267- targetLibs =
268- let
269- basePackageSet = if hostPlatform != targetPlatform then targetPackages else pkgsHostTarget;
270- in
271- {
272- inherit (basePackageSet) gmp ncurses numactl;
273- # dynamic inherits are not possible in Nix
274- libffi = basePackageSet.${libffi_name};
275- };
276-277-in
278-279-stdenv.mkDerivation (
280- rec {
281- inherit version;
282- pname = "${targetPrefix}ghc${variantSuffix}";
283-284- src = fetchurl {
285- url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
286- sha256 = "e3eef6229ce9908dfe1ea41436befb0455fefb1932559e860ad4c606b0d03c9d";
287- };
288-289- enableParallelBuilding = true;
290-291- outputs = [
292- "out"
293- "doc"
294- ];
295-296- patches = [
297- # Fix docs build with sphinx >= 6.0
298- # https://gitlab.haskell.org/ghc/ghc/-/issues/22766
299- (fetchpatch {
300- name = "ghc-docs-sphinx-6.0.patch";
301- url = "https://gitlab.haskell.org/ghc/ghc/-/commit/10e94a556b4f90769b7fd718b9790d58ae566600.patch";
302- sha256 = "0kmhfamr16w8gch0lgln2912r8aryjky1hfcda3jkcwa5cdzgjdv";
303- })
304-305- # Determine size of time related types using hsc2hs instead of assuming CLong.
306- # Prevents failures when e.g. stat(2)ing on 32bit systems with 64bit time_t etc.
307- # https://github.com/haskell/ghcup-hs/issues/1107
308- # https://gitlab.haskell.org/ghc/ghc/-/issues/25095
309- # Note that in normal situations this shouldn't be the case since nixpkgs
310- # doesn't set -D_FILE_OFFSET_BITS=64 and friends (yet).
311- (fetchpatch {
312- name = "unix-fix-ctimeval-size-32-bit.patch";
313- url = "https://github.com/haskell/unix/commit/8183e05b97ce870dd6582a3677cc82459ae566ec.patch";
314- sha256 = "17q5yyigqr5kxlwwzb95sx567ysfxlw6bp3j4ji20lz0947aw6gv";
315- stripLen = 1;
316- extraPrefix = "libraries/unix/";
317- })
318-319- # See upstream patch at
320- # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4885. Since we build
321- # from source distributions, the auto-generated configure script needs to be
322- # patched as well, therefore we use an in-tree patch instead of pulling the
323- # upstream patch. Don't forget to check backport status of the upstream patch
324- # when adding new GHC releases in nixpkgs.
325- ./respect-ar-path.patch
326-327- # fix hyperlinked haddock sources: https://github.com/haskell/haddock/pull/1482
328- (fetchpatch {
329- url = "https://patch-diff.githubusercontent.com/raw/haskell/haddock/pull/1482.patch";
330- sha256 = "sha256-8w8QUCsODaTvknCDGgTfFNZa8ZmvIKaKS+2ZJZ9foYk=";
331- extraPrefix = "utils/haddock/";
332- stripLen = 1;
333- })
334-335- # cabal passes incorrect --host= when cross-compiling
336- # https://github.com/haskell/cabal/issues/5887
337- (fetchpatch {
338- url = "https://raw.githubusercontent.com/input-output-hk/haskell.nix/122bd81150386867da07fdc9ad5096db6719545a/overlays/patches/ghc/cabal-host.patch";
339- sha256 = "sha256:0yd0sajgi24sc1w5m55lkg2lp6kfkgpp3lgija2c8y3cmkwfpdc1";
340- })
341-342- # In order to build ghcjs packages, the Cabal of the ghc used for the ghcjs
343- # needs to be patched. Ref https://github.com/haskell/cabal/pull/7575
344- (fetchpatch {
345- url = "https://github.com/haskell/cabal/commit/369c4a0a54ad08a9e6b0d3bd303fedd7b5e5a336.patch";
346- sha256 = "120f11hwyaqa0pq9g5l1300crqij49jg0rh83hnp9sa49zfdwx1n";
347- stripLen = 3;
348- extraPrefix = "libraries/Cabal/Cabal/";
349- })
350-351- # We need to be able to set AR_STAGE0 and LD_STAGE0 when cross-compiling
352- (fetchpatch {
353- url = "https://gitlab.haskell.org/ghc/ghc/-/commit/8f7dd5710b80906ea7a3e15b7bb56a883a49fed8.patch";
354- hash = "sha256-C636Nq2U8YOG/av7XQmG3L1rU0bmC9/7m7Hty5pm5+s=";
355- })
356-357- # Backport part of <https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7111> to 8.10.7
358- # The change we are interested in is that Cabal no longer sets include-dirs
359- # for the GHCi library delegating to the system search path or (in our case)
360- # cc-wrapper. Without this patch, the target libffi ends up in there (which
361- # we provide via --with-ffi-includes) which breaks bootstrapping e.g. when
362- # cross compiling GHC. Without include-dirs, cc-wrapper and splicing will
363- # correctly pick the suitable libffi out of the build environment.
364- (fetchpatch {
365- name = "ghci-no-libffi-include.patch";
366- url = "https://gitlab.haskell.org/ghc/ghc/-/commit/b2721819f391ab49871271283f32df54810c4387.patch";
367- sha256 = "1rmv3132xhxbka97v0rx7r6larx5f5nnvs4mgm9q3rmgpjyd1vf9";
368- includes = [ "libraries/ghci/ghci.cabal.in" ];
369- })
370-371- # Correctly record libnuma's library and include directories in the
372- # package db. This fixes linking whenever stdenv and propagation won't
373- # quite pass the correct -L flags to the linker, e.g. when using GHC
374- # outside of stdenv/nixpkgs or build->build compilation in pkgsStatic.
375- ./ghc-8.10-9.2-rts-package-db-libnuma-dirs.patch
376- ]
377- ++ lib.optionals stdenv.hostPlatform.isDarwin [
378- # Make Block.h compile with c++ compilers. Remove with the next release
379- (fetchpatch {
380- url = "https://gitlab.haskell.org/ghc/ghc/-/commit/97d0b0a367e4c6a52a17c3299439ac7de129da24.patch";
381- sha256 = "0r4zjj0bv1x1m2dgxp3adsf2xkr94fjnyj1igsivd9ilbs5ja0b5";
382- })
383- ]
384- ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
385- # Prevent the paths module from emitting symbols that we don't use
386- # when building with separate outputs.
387- #
388- # These cause problems as they're not eliminated by GHC's dead code
389- # elimination on aarch64-darwin. (see
390- # https://github.com/NixOS/nixpkgs/issues/140774 for details).
391- ./Cabal-3.2-3.4-paths-fix-cycle-aarch64-darwin.patch
392- ];
393-394- postPatch = "patchShebangs .";
395-396- # GHC is a bit confused on its cross terminology.
397- # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
398- preConfigure = ''
399- for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
400- export "''${env#TARGET_}=''${!env}"
401- done
402- # Stage0 (build->build) which builds stage 1
403- export GHC="${bootPkgs.ghc}/bin/ghc"
404- # GHC is a bit confused on its cross terminology, as these would normally be
405- # the *host* tools.
406- export CC="${toolPath "cc" targetCC}"
407- export CXX="${toolPath "c++" targetCC}"
408- # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
409- export LD="${toolPath "ld${lib.optionalString useLdGold ".gold"}" targetCC}"
410- export AS="${toolPath "as" targetCC}"
411- export AR="${toolPath "ar" targetCC}"
412- export NM="${toolPath "nm" targetCC}"
413- export RANLIB="${toolPath "ranlib" targetCC}"
414- export READELF="${toolPath "readelf" targetCC}"
415- export STRIP="${toolPath "strip" targetCC}"
416- export OBJDUMP="${toolPath "objdump" targetCC}"
417- ''
418- + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
419- export OTOOL="${toolPath "otool" targetCC}"
420- export INSTALL_NAME_TOOL="${toolPath "install_name_tool" targetCC}"
421- ''
422- + lib.optionalString useLLVM ''
423- export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
424- export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
425- ''
426- + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
427- # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
428- # The executable we specify via $CLANG is used as an assembler (exclusively, it seems, but this isn't
429- # clarified in any user facing documentation). As such, it'll be called on assembly produced by $CC
430- # which usually comes from the darwin stdenv. To prevent a situation where $CLANG doesn't understand
431- # the assembly it is given, we need to make sure that it matches the LLVM version of $CC if possible.
432- # It is unclear (at the time of writing 2024-09-01) whether $CC should match the LLVM version we use
433- # for llc and opt which would require using a custom darwin stdenv for targetCC.
434- export CLANG="${
435- if targetCC.isClang then
436- toolPath "clang" targetCC
437- else
438- "${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
439- }"
440- ''
441- + ''
442- # No need for absolute paths since these tools only need to work during the build
443- export CC_STAGE0="$CC_FOR_BUILD"
444- export LD_STAGE0="$LD_FOR_BUILD"
445- export AR_STAGE0="$AR_FOR_BUILD"
446-447- echo -n "${buildMK}" > mk/build.mk
448- sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
449- ''
450- + lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
451- export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
452- ''
453- + lib.optionalString stdenv.hostPlatform.isDarwin ''
454- export NIX_LDFLAGS+=" -no_dtrace_dof"
455-456- # GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7
457- export XATTR=${lib.getBin xattr}/bin/xattr
458- ''
459- + lib.optionalString targetPlatform.useAndroidPrebuilt ''
460- sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
461- ''
462- + lib.optionalString targetPlatform.isMusl ''
463- echo "patching llvm-targets for musl targets..."
464- echo "Cloning these existing '*-linux-gnu*' targets:"
465- grep linux-gnu llvm-targets | sed 's/^/ /'
466- echo "(go go gadget sed)"
467- sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
468- echo "llvm-targets now contains these '*-linux-musl*' targets:"
469- grep linux-musl llvm-targets | sed 's/^/ /'
470-471- echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
472- # (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
473- for x in configure aclocal.m4; do
474- substituteInPlace $x \
475- --replace '*-android*|*-gnueabi*)' \
476- '*-android*|*-gnueabi*|*-musleabi*)'
477- done
478- '';
479-480- # Although it is usually correct to pass --host, we don't do that here because
481- # GHC's usage of build, host, and target is non-standard.
482- # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling
483- # TODO(@Ericson2314): Always pass "--target" and always prefix.
484- configurePlatforms = [
485- "build"
486- ]
487- ++ lib.optional (buildPlatform != hostPlatform || targetPlatform != hostPlatform) "target";
488-489- # `--with` flags for libraries needed for RTS linker
490- configureFlags = [
491- "--datadir=$doc/share/doc/ghc"
492- ]
493- ++ lib.optionals enableTerminfo [
494- "--with-curses-includes=${lib.getDev targetLibs.ncurses}/include"
495- "--with-curses-libraries=${lib.getLib targetLibs.ncurses}/lib"
496- ]
497- ++ lib.optionals (args.${libffi_name} != null) [
498- "--with-system-libffi"
499- "--with-ffi-includes=${targetLibs.libffi.dev}/include"
500- "--with-ffi-libraries=${targetLibs.libffi.out}/lib"
501- ]
502- ++ lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
503- "--with-gmp-includes=${targetLibs.gmp.dev}/include"
504- "--with-gmp-libraries=${targetLibs.gmp.out}/lib"
505- ]
506- ++
507- lib.optionals
508- (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows)
509- [
510- "--with-iconv-includes=${libiconv}/include"
511- "--with-iconv-libraries=${libiconv}/lib"
512- ]
513- ++ lib.optionals (targetPlatform != hostPlatform) [
514- "--enable-bootstrap-with-devel-snapshot"
515- ]
516- ++ lib.optionals useLdGold [
517- "CFLAGS=-fuse-ld=gold"
518- "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
519- "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
520- ]
521- ++ lib.optionals (disableLargeAddressSpace) [
522- "--disable-large-address-space"
523- ]
524- ++ lib.optionals enableNuma [
525- "--enable-numa"
526- "--with-libnuma-includes=${lib.getDev targetLibs.numactl}/include"
527- "--with-libnuma-libraries=${lib.getLib targetLibs.numactl}/lib"
528- ]
529- ++ lib.optionals enableUnregisterised [
530- "--enable-unregisterised"
531- ];
532-533- # Make sure we never relax`$PATH` and hooks support for compatibility.
534- strictDeps = true;
535-536- # Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
537- dontAddExtraLibs = true;
538-539- nativeBuildInputs = [
540- perl
541- autoreconfHook
542- autoconf
543- automake
544- m4
545- python3
546- bootPkgs.alex
547- bootPkgs.happy
548- bootPkgs.hscolour
549- bootPkgs.ghc-settings-edit
550- ]
551- ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
552- autoSignDarwinBinariesHook
553- ]
554- ++ lib.optionals enableDocs [
555- sphinx
556- ];
557-558- # Everything the stage0 compiler needs to build stage1: CC, bintools, extra libs.
559- # See also GHC, {CC,LD,AR}_STAGE0 in preConfigure.
560- depsBuildBuild = [
561- # N.B. We do not declare bootPkgs.ghc in any of the stdenv.mkDerivation
562- # dependency lists to prevent the bintools setup hook from adding ghc's
563- # lib directory to the linker flags. Instead we tell configure about it
564- # via the GHC environment variable.
565- buildCC
566- # stage0 builds terminfo unconditionally, so we always need ncurses
567- ncurses
568- ];
569- # For building runtime libs
570- depsBuildTarget = toolsForTarget;
571-572- # Prevent stage0 ghc from leaking into the final result. This was an issue
573- # with GHC 9.6.
574- disallowedReferences = [
575- bootPkgs.ghc
576- ];
577-578- buildInputs = [ bash ] ++ (libDeps hostPlatform);
579-580- # stage1 GHC doesn't need to link against libnuma, so it's target specific
581- depsTargetTarget = map lib.getDev (
582- libDeps targetPlatform ++ lib.optionals enableNuma [ targetLibs.numactl ]
583- );
584- depsTargetTargetPropagated = map (lib.getOutput "out") (
585- libDeps targetPlatform ++ lib.optionals enableNuma [ targetLibs.numactl ]
586- );
587-588- # required, because otherwise all symbols from HSffi.o are stripped, and
589- # that in turn causes GHCi to abort
590- stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
591-592- checkTarget = "test";
593-594- # GHC cannot currently produce outputs that are ready for `-pie` linking.
595- # Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
596- # See:
597- # * https://github.com/NixOS/nixpkgs/issues/129247
598- # * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
599- hardeningDisable = [
600- "format"
601- "pie"
602- ];
603-604- # big-parallel allows us to build with more than 2 cores on
605- # Hydra which already warrants a significant speedup
606- requiredSystemFeatures = [ "big-parallel" ];
607-608- postInstall = ''
609- settingsFile="$out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings"
610-611- # Make the installed GHC use the host->target tools.
612- ghc-settings-edit "$settingsFile" \
613- "C compiler command" "${toolPath "cc" installCC}" \
614- "Haskell CPP command" "${toolPath "cc" installCC}" \
615- "C++ compiler command" "${toolPath "c++" installCC}" \
616- "ld command" "${toolPath "ld${lib.optionalString useLdGold ".gold"}" installCC}" \
617- "Merge objects command" "${toolPath "ld${lib.optionalString useLdGold ".gold"}" installCC}" \
618- "ar command" "${toolPath "ar" installCC}" \
619- "ranlib command" "${toolPath "ranlib" installCC}"
620- ''
621- + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
622- ghc-settings-edit "$settingsFile" \
623- "otool command" "${toolPath "otool" installCC}" \
624- "install_name_tool command" "${toolPath "install_name_tool" installCC}"
625- ''
626- + lib.optionalString useLLVM ''
627- ghc-settings-edit "$settingsFile" \
628- "LLVM llc command" "${lib.getBin llvmPackages.llvm}/bin/llc" \
629- "LLVM opt command" "${lib.getBin llvmPackages.llvm}/bin/opt"
630- ''
631- + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
632- ghc-settings-edit "$settingsFile" \
633- "LLVM clang command" "${
634- # See comment for CLANG in preConfigure
635- if installCC.isClang then
636- toolPath "clang" installCC
637- else
638- "${llvmPackages.clang}/bin/${llvmPackages.clang.targetPrefix}clang"
639- }"
640- ''
641- + ''
642-643- # Install the bash completion file.
644- install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
645- '';
646-647- passthru = {
648- inherit bootPkgs targetPrefix;
649-650- inherit llvmPackages;
651- inherit enableShared;
652-653- # This is used by the haskell builder to query
654- # the presence of the haddock program.
655- hasHaddock = enableHaddockProgram;
656-657- # Our Cabal compiler name
658- haskellCompilerName = "ghc-${version}";
659-660- bootstrapAvailable = lib.meta.availableOn stdenv.buildPlatform bootPkgs.ghc;
661- };
662-663- meta = {
664- homepage = "http://haskell.org/ghc";
665- description = "Glasgow Haskell Compiler";
666- maintainers = with lib.maintainers; [
667- guibou
668- ];
669- teams = [ lib.teams.haskell ];
670- timeout = 24 * 3600;
671- platforms = lib.platforms.all;
672- inherit (bootPkgs.ghc.meta) license;
673- };
674-675- }
676- // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
677- dontStrip = true;
678- dontPatchELF = true;
679- noAuditTmpdir = true;
680- }
681-)
···309 # package db. This fixes linking whenever stdenv and propagation won't
310 # quite pass the correct -L flags to the linker, e.g. when using GHC
311 # outside of stdenv/nixpkgs or build->build compilation in pkgsStatic.
312- (
313- if lib.versionAtLeast version "9.4" then
314- ./ghc-9.4-rts-package-db-libnuma-dirs.patch
315- else
316- ./ghc-8.10-9.2-rts-package-db-libnuma-dirs.patch
317- )
318 ]
319320 # Before GHC 9.6, GHC, when used to compile C sources (i.e. to drive the CC), would first
···333 #
334 # https://gitlab.haskell.org/ghc/ghc/-/issues/25608#note_622589
335 # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6877
336- ++ (
337- if lib.versionAtLeast version "9.4" then
338- [
339- # Need to use this patch so the next one applies, passes file location info to the cc phase
340- (fetchpatch {
341- name = "ghc-add-location-to-cc-phase.patch";
342- url = "https://gitlab.haskell.org/ghc/ghc/-/commit/4a7256a75af2fc0318bef771a06949ffb3939d5a.patch";
343- hash = "sha256-DnTI+i1zMebeWvw75D59vMaEEBb2Nr9HusxTyhmdy2M=";
344- })
345- # Makes Cc phase directly generate object files instead of assembly
346- (fetchpatch {
347- name = "ghc-cc-directly-emit-object.patch";
348- url = "https://gitlab.haskell.org/ghc/ghc/-/commit/96811ba491495b601ec7d6a32bef8563b0292109.patch";
349- hash = "sha256-G8u7/MK/tGOEN8Wxccxj/YIOP7mL2G9Co1WKdHXOo6I=";
350- })
351- ]
352- else
353- [
354- # TODO(@sternenseemann): backport changes to GHC < 9.4 if possible
355- ]
356- )
357358 ++ [
359 # Don't generate code that doesn't compile when --enable-relocatable is passed to Setup.hs
···366 })
367 ]
368369- # fix hyperlinked haddock sources: https://github.com/haskell/haddock/pull/1482
370- ++ lib.optionals (lib.versionOlder version "9.4") [
371- (fetchpatch {
372- url = "https://patch-diff.githubusercontent.com/raw/haskell/haddock/pull/1482.patch";
373- sha256 = "sha256-8w8QUCsODaTvknCDGgTfFNZa8ZmvIKaKS+2ZJZ9foYk=";
374- extraPrefix = "utils/haddock/";
375- stripLen = 1;
376- })
377- ]
378-379 # Fixes stack overrun in rts which crashes an process whenever
380 # freeHaskellFunPtr is called with nixpkgs' hardening flags.
381 # https://gitlab.haskell.org/ghc/ghc/-/issues/25485
382 # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13599
383 # TODO: patch doesn't apply for < 9.4, but may still be necessary?
384- ++ lib.optionals (lib.versionAtLeast version "9.4") [
385 (fetchpatch {
386 name = "ghc-rts-adjustor-fix-i386-stack-overrun.patch";
387 url = "https://gitlab.haskell.org/ghc/ghc/-/commit/39bb6e583d64738db51441a556d499aa93a4fc4a.patch";
···389 })
390 ]
391392- ++ lib.optionals (lib.versionOlder version "9.4.6") [
393- # Fix docs build with sphinx >= 6.0
394- # https://gitlab.haskell.org/ghc/ghc/-/issues/22766
395- (fetchpatch {
396- name = "ghc-docs-sphinx-6.0.patch";
397- url = "https://gitlab.haskell.org/ghc/ghc/-/commit/10e94a556b4f90769b7fd718b9790d58ae566600.patch";
398- sha256 = "0kmhfamr16w8gch0lgln2912r8aryjky1hfcda3jkcwa5cdzgjdv";
399- })
400- ]
401-402 ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
403 # Prevent the paths module from emitting symbols that we don't use
404 # when building with separate outputs.
···466 export AR_STAGE0="$AR_FOR_BUILD"
467468 echo -n "${buildMK}" > mk/build.mk
469- ''
470- + lib.optionalString (lib.versionAtLeast version "9.4") ''
471 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
472 ''
473 + lib.optionalString (stdenv.hostPlatform.isLinux && hostPlatform.libc == "glibc") ''
···503 --replace '*-android*|*-gnueabi*)' \
504 '*-android*|*-gnueabi*|*-musleabi*)'
505 done
506- ''
507- # HACK: allow bootstrapping with GHC 8.10 which works fine, as we don't have
508- # binary 9.0 packaged. Bootstrapping with 9.2 is broken without hadrian.
509- + lib.optionalString (lib.versions.majorMinor version == "9.4") ''
510- substituteInPlace configure --replace \
511- 'MinBootGhcVersion="9.0"' \
512- 'MinBootGhcVersion="8.10"'
513 '';
514515 # Although it is usually correct to pass --host, we don't do that here because
···309 # package db. This fixes linking whenever stdenv and propagation won't
310 # quite pass the correct -L flags to the linker, e.g. when using GHC
311 # outside of stdenv/nixpkgs or build->build compilation in pkgsStatic.
312+ ./ghc-9.4-rts-package-db-libnuma-dirs.patch
00000313 ]
314315 # Before GHC 9.6, GHC, when used to compile C sources (i.e. to drive the CC), would first
···328 #
329 # https://gitlab.haskell.org/ghc/ghc/-/issues/25608#note_622589
330 # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6877
331+ ++ [
332+ # Need to use this patch so the next one applies, passes file location info to the cc phase
333+ (fetchpatch {
334+ name = "ghc-add-location-to-cc-phase.patch";
335+ url = "https://gitlab.haskell.org/ghc/ghc/-/commit/4a7256a75af2fc0318bef771a06949ffb3939d5a.patch";
336+ hash = "sha256-DnTI+i1zMebeWvw75D59vMaEEBb2Nr9HusxTyhmdy2M=";
337+ })
338+ # Makes Cc phase directly generate object files instead of assembly
339+ (fetchpatch {
340+ name = "ghc-cc-directly-emit-object.patch";
341+ url = "https://gitlab.haskell.org/ghc/ghc/-/commit/96811ba491495b601ec7d6a32bef8563b0292109.patch";
342+ hash = "sha256-G8u7/MK/tGOEN8Wxccxj/YIOP7mL2G9Co1WKdHXOo6I=";
343+ })
344+ ]
0000000345346 ++ [
347 # Don't generate code that doesn't compile when --enable-relocatable is passed to Setup.hs
···354 })
355 ]
3560000000000357 # Fixes stack overrun in rts which crashes an process whenever
358 # freeHaskellFunPtr is called with nixpkgs' hardening flags.
359 # https://gitlab.haskell.org/ghc/ghc/-/issues/25485
360 # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13599
361 # TODO: patch doesn't apply for < 9.4, but may still be necessary?
362+ ++ [
363 (fetchpatch {
364 name = "ghc-rts-adjustor-fix-i386-stack-overrun.patch";
365 url = "https://gitlab.haskell.org/ghc/ghc/-/commit/39bb6e583d64738db51441a556d499aa93a4fc4a.patch";
···367 })
368 ]
3690000000000370 ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
371 # Prevent the paths module from emitting symbols that we don't use
372 # when building with separate outputs.
···434 export AR_STAGE0="$AR_FOR_BUILD"
435436 echo -n "${buildMK}" > mk/build.mk
00437 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
438 ''
439 + lib.optionalString (stdenv.hostPlatform.isLinux && hostPlatform.libc == "glibc") ''
···469 --replace '*-android*|*-gnueabi*)' \
470 '*-android*|*-gnueabi*|*-musleabi*)'
471 done
0000000472 '';
473474 # Although it is usually correct to pass --host, we don't do that here because
···1971 # https://github.com/serokell/haskell-crypto/issues/25
1972 crypto-sodium = dontCheck super.crypto-sodium;
19731974- # Polyfill for GHCs from the integer-simple days that don't bundle ghc-bignum
1975- ghc-bignum = super.ghc-bignum or self.mkDerivation {
1976- pname = "ghc-bignum";
1977- version = "1.0";
1978- sha256 = "0xl848q8z6qx2bi6xil0d35lra7wshwvysyfblki659d7272b1im";
1979- description = "GHC BigNum library";
1980- license = lib.licenses.bsd3;
1981- # ghc-bignum is not buildable if none of the three backends
1982- # is explicitly enabled. We enable Native for now as it doesn't
1983- # depend on anything else as opposed to GMP and FFI.
1984- # Apply patch which fixes a compilation failure we encountered.
1985- # Will need to be kept until we can drop ghc-bignum entirely,
1986- # i. e. if GHC 8.10.* and 8.8.* have been removed.
1987- configureFlags = [
1988- "-f"
1989- "Native"
1990- ];
1991- patches = [
1992- (fetchpatch {
1993- url = "https://gitlab.haskell.org/ghc/ghc/-/commit/08d1588bf38d83140a86817a7a615db486357d4f.patch";
1994- sha256 = "sha256-Y9WW0KDQ/qY2L9ObPvh1i/6lxXIlprbxzdSBDfiaMtE=";
1995- relative = "libraries/ghc-bignum";
1996- })
1997- ];
1998- };
1999-2000 # 2021-04-09: too strict time bound
2001 # PR pending https://github.com/zohl/cereal-time/pull/2
2002 cereal-time = doJailbreak super.cereal-time;
···2615 # 2025-02-06: Allow tasty-quickcheck == 0.11.*
2616 # https://github.com/google/ghc-source-gen/issues/120
2617 ghc-source-gen = doJailbreak super.ghc-source-gen;
2618- ghc-source-gen_0_4_5_0 = doJailbreak super.ghc-source-gen_0_4_5_0;
2619 # https://github.com/byteverse/bytebuild/issues/20#issuecomment-2652113837
2620 bytebuild = doJailbreak super.bytebuild;
2621 # https://github.com/haskellari/lattices/issues/132