···13051305 # Name of the compiler and package set you want to change. If you are using
13061306 # the default package set `haskellPackages`, you need to look up what version
13071307 # of GHC it currently uses (note that this is subject to change).
13081308- ghcName = "ghc92";
13081308+ ghcName = "ghc910";
13091309 # Desired new setting
13101310 enableProfiling = true;
13111311
+5-3
doc/release-notes/rl-2511.section.md
···24242525- GCC 9, 10, 11, and 12 have been removed, as they have reached end‐of‐life upstream and are no longer supported.
26262727-- 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.
2828-2927- 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.
30283131-- GHC 9.0 and its package set have been removed.
2929+- GHC 8.6, 8.10, 9.0, 9.2, and their package sets have been removed.
3030+3131+- Support for bootstrapping native GHC compilers on 32‐bit ARM and little‐endian 64‐bit PowerPC has been dropped.
3232+ The latter was probably broken anyway.
3333+ If there is interest in restoring support for these architectures, it should be possible to cross‐compile a bootstrap GHC binary.
32343335- `base16-builder` node package has been removed due to lack of upstream maintenance.
3436
+2-2
lib/options.nix
···267267268268 mkPackageOption pkgs "GHC" {
269269 default = [ "ghc" ];
270270- example = "pkgs.haskell.packages.ghc92.ghc.withPackages (hkgs: [ hkgs.primes ])";
270270+ example = "pkgs.haskellPackages.ghc.withPackages (hkgs: [ hkgs.primes ])";
271271 }
272272- => { ...; 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; }
272272+ => { ...; default = pkgs.ghc; defaultText = literalExpression "pkgs.ghc"; description = "The GHC package to use."; example = literalExpression "pkgs.haskellPackages.ghc.withPackages (hkgs: [ hkgs.primes ])"; type = package; }
273273274274 mkPackageOption pkgs [ "python3Packages" "pytorch" ] {
275275 extraDescription = "This is an example and doesn't actually do anything.";
···66 and builds all derivations (or at least a reasonable subset) affected by
77 these overrides.
8899- By default, it checks `configuration-{common,nix,ghc-8.10.x}.nix`. You can
99+ By default, it checks `configuration-{common,nix,ghc-9.8.x}.nix`. You can
1010 invoke it like this:
11111212 nix-build maintainers/scripts/haskell/test-configurations.nix --keep-going
···5050 files ? [
5151 "configuration-common.nix"
5252 "configuration-nix.nix"
5353- "configuration-ghc-8.10.x.nix"
5353+ "configuration-ghc-9.8.x.nix"
5454 ],
5555 nixpkgsPath ? ../../..,
5656 config ? {
···7474 haskellPackages = mkOption {
7575 default = pkgs.haskellPackages;
7676 defaultText = literalExpression "pkgs.haskellPackages";
7777- example = literalExpression "pkgs.haskell.packages.ghc810";
7777+ example = literalExpression "pkgs.haskell.packages.ghc910";
7878 type = types.attrs;
7979 description = ''
8080 haskellPackages used to build Xmonad and other packages.
-546
pkgs/development/compilers/ghc/8.10.7-binary.nix
···11-{
22- lib,
33- stdenv,
44- fetchurl,
55- perl,
66- gcc,
77- ncurses5,
88- ncurses6,
99- gmp,
1010- libiconv,
1111- numactl,
1212- llvmPackages,
1313- coreutils,
1414- rcodesign,
1515- targetPackages,
1616-1717- # minimal = true; will remove files that aren't strictly necessary for
1818- # regular builds and GHC bootstrapping.
1919- # This is "useful" for staying within hydra's output limits for at least the
2020- # aarch64-linux architecture.
2121- minimal ? false,
2222-}:
2323-2424-# Prebuilt only does native
2525-assert stdenv.targetPlatform == stdenv.hostPlatform;
2626-2727-let
2828- downloadsUrl = "https://downloads.haskell.org/ghc";
2929-3030- # Copy sha256 from https://downloads.haskell.org/~ghc/8.10.7/SHA256SUMS
3131- version = "8.10.7";
3232-3333- # Information about available bindists that we use in the build.
3434- #
3535- # # Bindist library checking
3636- #
3737- # The field `archSpecificLibraries` also provides a way for us get notified
3838- # early when the upstream bindist changes its dependencies (e.g. because a
3939- # newer Debian version is used that uses a new `ncurses` version).
4040- #
4141- # Usage:
4242- #
4343- # * You can find the `fileToCheckFor` of libraries by running `readelf -d`
4444- # on the compiler binary (`exePathForLibraryCheck`).
4545- # * To skip library checking for an architecture,
4646- # set `exePathForLibraryCheck = null`.
4747- # * To skip file checking for a specific arch specific library,
4848- # set `fileToCheckFor = null`.
4949- ghcBinDists = {
5050- # Binary distributions for the default libc (e.g. glibc, or libSystem on Darwin)
5151- # nixpkgs uses for the respective system.
5252- defaultLibc = {
5353- i686-linux = {
5454- variantSuffix = "";
5555- src = {
5656- url = "${downloadsUrl}/${version}/ghc-${version}-i386-deb9-linux.tar.xz";
5757- sha256 = "fbfc1ef194f4e7a4c0da8c11cc69b17458a4b928b609b3622c97acc4acd5c5ab";
5858- };
5959- exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
6060- archSpecificLibraries = [
6161- {
6262- nixPackage = gmp;
6363- fileToCheckFor = null;
6464- }
6565- # The i686-linux bindist provided by GHC HQ is currently built on Debian 9,
6666- # which link it against `libtinfo.so.5` (ncurses 5).
6767- # Other bindists are linked `libtinfo.so.6` (ncurses 6).
6868- {
6969- nixPackage = ncurses5;
7070- fileToCheckFor = "libtinfo.so.5";
7171- }
7272- ];
7373- };
7474- x86_64-linux = {
7575- variantSuffix = "";
7676- src = {
7777- url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-deb10-linux.tar.xz";
7878- sha256 = "a13719bca87a0d3ac0c7d4157a4e60887009a7f1a8dbe95c4759ec413e086d30";
7979- };
8080- exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
8181- archSpecificLibraries = [
8282- {
8383- nixPackage = gmp;
8484- fileToCheckFor = null;
8585- }
8686- {
8787- nixPackage = ncurses6;
8888- fileToCheckFor = "libtinfo.so.6";
8989- }
9090- ];
9191- };
9292- armv7l-linux = {
9393- variantSuffix = "";
9494- src = {
9595- url = "${downloadsUrl}/${version}/ghc-${version}-armv7-deb10-linux.tar.xz";
9696- sha256 = "3949c31bdf7d3b4afb765ea8246bca4ca9707c5d988d9961a244f0da100956a2";
9797- };
9898- exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
9999- archSpecificLibraries = [
100100- {
101101- nixPackage = gmp;
102102- fileToCheckFor = null;
103103- }
104104- {
105105- nixPackage = ncurses6;
106106- fileToCheckFor = "libtinfo.so.6";
107107- }
108108- ];
109109- };
110110- aarch64-linux = {
111111- variantSuffix = "";
112112- src = {
113113- url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-deb10-linux.tar.xz";
114114- sha256 = "fad2417f9b295233bf8ade79c0e6140896359e87be46cb61cd1d35863d9d0e55";
115115- };
116116- exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
117117- archSpecificLibraries = [
118118- {
119119- nixPackage = gmp;
120120- fileToCheckFor = null;
121121- }
122122- {
123123- nixPackage = ncurses6;
124124- fileToCheckFor = "libtinfo.so.6";
125125- }
126126- {
127127- nixPackage = numactl;
128128- fileToCheckFor = null;
129129- }
130130- ];
131131- };
132132- x86_64-darwin = {
133133- variantSuffix = "";
134134- src = {
135135- url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz";
136136- sha256 = "287db0f9c338c9f53123bfa8731b0996803ee50f6ee847fe388092e5e5132047";
137137- };
138138- exePathForLibraryCheck = null; # we don't have a library check for darwin yet
139139- archSpecificLibraries = [
140140- {
141141- nixPackage = gmp;
142142- fileToCheckFor = null;
143143- }
144144- {
145145- nixPackage = ncurses6;
146146- fileToCheckFor = null;
147147- }
148148- {
149149- nixPackage = libiconv;
150150- fileToCheckFor = null;
151151- }
152152- ];
153153- };
154154- aarch64-darwin = {
155155- variantSuffix = "";
156156- src = {
157157- url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-apple-darwin.tar.xz";
158158- sha256 = "dc469fc3c35fd2a33a5a575ffce87f13de7b98c2d349a41002e200a56d9bba1c";
159159- };
160160- exePathForLibraryCheck = null; # we don't have a library check for darwin yet
161161- archSpecificLibraries = [
162162- {
163163- nixPackage = gmp;
164164- fileToCheckFor = null;
165165- }
166166- {
167167- nixPackage = ncurses6;
168168- fileToCheckFor = null;
169169- }
170170- {
171171- nixPackage = libiconv;
172172- fileToCheckFor = null;
173173- }
174174- ];
175175- };
176176- };
177177- # Binary distributions for the musl libc for the respective system.
178178- musl = {
179179- x86_64-linux = {
180180- variantSuffix = "-musl-integer-simple";
181181- src = {
182182- url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-alpine3.10-linux-integer-simple.tar.xz";
183183- sha256 = "16903df850ef73d5246f2ff169cbf57ecab76c2ac5acfa9928934282cfad575c";
184184- };
185185- exePathForLibraryCheck = "bin/ghc";
186186- archSpecificLibraries = [
187187- # No `gmp` here, since this is an `integer-simple` bindist.
188188-189189- # In contrast to glibc builds, the musl-bindist uses `libncursesw.so.*`
190190- # instead of `libtinfo.so.*.`
191191- {
192192- nixPackage = ncurses6;
193193- fileToCheckFor = "libncursesw.so.6";
194194- }
195195- ];
196196- isHadrian = true;
197197- };
198198- };
199199- };
200200-201201- distSetName = if stdenv.hostPlatform.isMusl then "musl" else "defaultLibc";
202202-203203- binDistUsed =
204204- ghcBinDists.${distSetName}.${stdenv.hostPlatform.system}
205205- or (throw "cannot bootstrap GHC on this platform ('${stdenv.hostPlatform.system}' with libc '${distSetName}')");
206206-207207- useLLVM = !(import ./common-have-ncg.nix { inherit lib stdenv version; });
208208-209209- libPath = lib.makeLibraryPath (
210210- # Add arch-specific libraries.
211211- map ({ nixPackage, ... }: nixPackage) binDistUsed.archSpecificLibraries
212212- );
213213-214214- libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY" + "LD_LIBRARY_PATH";
215215-216216- runtimeDeps = [
217217- targetPackages.stdenv.cc
218218- targetPackages.stdenv.cc.bintools
219219- coreutils # for cat
220220- ]
221221- ++ lib.optionals useLLVM [
222222- (lib.getBin llvmPackages.llvm)
223223- ]
224224- # On darwin, we need unwrapped bintools as well (for otool)
225225- ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [
226226- targetPackages.stdenv.cc.bintools.bintools
227227- ];
228228-229229-in
230230-231231-stdenv.mkDerivation {
232232- inherit version;
233233- pname = "ghc-binary${binDistUsed.variantSuffix}";
234234-235235- src = fetchurl binDistUsed.src;
236236-237237- # Note that for GHC 8.10 versions >= 8.10.6, the GHC HQ musl bindist
238238- # uses `integer-simple` and has no `gmp` dependency:
239239- # https://gitlab.haskell.org/ghc/ghc/-/commit/8306501020cd66f683ad9c215fa8e16c2d62357d
240240- # Related nixpkgs issues:
241241- # * https://github.com/NixOS/nixpkgs/pull/130441#issuecomment-922452843
242242- # TODO: When this file is copied to `ghc-9.*-binary.nix`, determine whether
243243- # the GHC 9 branch also switched from `gmp` to `integer-simple` via the
244244- # currently-open issue:
245245- # https://gitlab.haskell.org/ghc/ghc/-/issues/20059
246246- # and update this comment accordingly.
247247-248248- nativeBuildInputs = [
249249- perl
250250- ]
251251- # Upstream binaries may not be linker-signed, which invalidates their signatures
252252- # because `install_name_tool` will only replace a signature if it is both
253253- # an ad hoc signature and the signature is flagged as linker-signed.
254254- #
255255- # rcodesign is used to replace the signature instead of sigtool because it
256256- # supports setting the linker-signed flag, which will ensure future processing
257257- # of the binaries does not invalidate their signatures.
258258- ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ rcodesign ];
259259-260260- # Set LD_LIBRARY_PATH or equivalent so that the programs running as part
261261- # of the bindist installer can find the libraries they expect.
262262- # Cannot patchelf beforehand due to relative RPATHs that anticipate
263263- # the final install location.
264264- ${libEnvVar} = libPath;
265265-266266- postUnpack =
267267- # Verify our assumptions of which `libtinfo.so` (ncurses) version is used,
268268- # so that we know when ghc bindists upgrade that and we need to update the
269269- # version used in `libPath`.
270270- lib.optionalString (binDistUsed.exePathForLibraryCheck != null)
271271- # Note the `*` glob because some GHCs have a suffix when unpacked, e.g.
272272- # the musl bindist has dir `ghc-VERSION-x86_64-unknown-linux/`.
273273- # As a result, don't shell-quote this glob when splicing the string.
274274- (
275275- let
276276- buildExeGlob = ''ghc-${version}*/"${binDistUsed.exePathForLibraryCheck}"'';
277277- in
278278- lib.concatStringsSep "\n" [
279279- (''
280280- shopt -u nullglob
281281- echo "Checking that ghc binary exists in bindist at ${buildExeGlob}"
282282- if ! test -e ${buildExeGlob}; then
283283- 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;
284284- fi
285285- '')
286286- (lib.concatMapStringsSep "\n" (
287287- { fileToCheckFor, nixPackage }:
288288- lib.optionalString (fileToCheckFor != null) ''
289289- echo "Checking bindist for ${fileToCheckFor} to ensure that is still used"
290290- if ! readelf -d ${buildExeGlob} | grep "${fileToCheckFor}"; then
291291- 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;
292292- fi
293293-294294- echo "Checking that the nix package ${nixPackage} contains ${fileToCheckFor}"
295295- if ! test -e "${lib.getLib nixPackage}/lib/${fileToCheckFor}"; then
296296- 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;
297297- fi
298298- ''
299299- ) binDistUsed.archSpecificLibraries)
300300- ]
301301- )
302302- # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
303303- # during linking
304304- + lib.optionalString stdenv.hostPlatform.isDarwin (
305305- ''
306306- export NIX_LDFLAGS+=" -no_dtrace_dof"
307307- # not enough room in the object files for the full path to libiconv :(
308308- for exe in $(find . -type f -executable); do
309309- isScript $exe && continue
310310- ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
311311- install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $exe
312312- ''
313313- + lib.optionalString stdenv.hostPlatform.isAarch64 ''
314314- # Resign the binary and set the linker-signed flag. Ignore failures when the file is an object file.
315315- # Object files don’t have signatures, so ignoring the failures is harmless.
316316- rcodesign sign --code-signature-flags linker-signed $exe || true
317317- ''
318318- + ''
319319- done
320320- ''
321321- )
322322- +
323323-324324- # Some scripts used during the build need to have their shebangs patched
325325- ''
326326- patchShebangs ghc-${version}/utils/
327327- patchShebangs ghc-${version}/configure
328328- test -d ghc-${version}/inplace/bin && \
329329- patchShebangs ghc-${version}/inplace/bin
330330- ''
331331- +
332332- # We have to patch the GMP paths for the integer-gmp package.
333333- # Note that musl bindists do not contain them,
334334- # see: https://gitlab.haskell.org/ghc/ghc/-/issues/20073#note_363231
335335- # However, musl bindists >= 8.10.6 use `integer-simple`, not `gmp`.
336336- ''
337337- find . -name integer-gmp.buildinfo \
338338- -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
339339- ''
340340- + lib.optionalString stdenv.hostPlatform.isDarwin ''
341341- find . -name base.buildinfo \
342342- -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
343343- ''
344344- +
345345- # Some platforms do HAVE_NUMA so -lnuma requires it in library-dirs in rts/package.conf.in
346346- # FFI_LIB_DIR is a good indication of places it must be needed.
347347- lib.optionalString
348348- (
349349- lib.meta.availableOn stdenv.hostPlatform numactl
350350- && builtins.any ({ nixPackage, ... }: nixPackage == numactl) binDistUsed.archSpecificLibraries
351351- )
352352- ''
353353- find . -name package.conf.in \
354354- -exec sed -i "s@FFI_LIB_DIR@FFI_LIB_DIR ${numactl.out}/lib@g" {} \;
355355- ''
356356- +
357357- # Rename needed libraries and binaries, fix interpreter
358358- lib.optionalString stdenv.hostPlatform.isLinux ''
359359- find . -type f -executable -exec patchelf \
360360- --interpreter ${stdenv.cc.bintools.dynamicLinker} {} \;
361361- ''
362362- +
363363- # The hadrian install Makefile uses 'xxx' as a temporary placeholder in path
364364- # substitution. Which can break the build if the store path / prefix happens
365365- # to contain this string. This will be fixed with 9.4 bindists.
366366- # https://gitlab.haskell.org/ghc/ghc/-/issues/21402
367367- ''
368368- # Detect hadrian Makefile by checking for the target that has the problem
369369- if grep '^update_package_db' ghc-${version}*/Makefile > /dev/null; then
370370- echo Hadrian bindist, applying workaround for xxx path substitution.
371371- # based on https://gitlab.haskell.org/ghc/ghc/-/commit/dd5fecb0e2990b192d92f4dfd7519ecb33164fad.patch
372372- substituteInPlace ghc-${version}*/Makefile --replace 'xxx' '\0xxx\0'
373373- else
374374- echo Not a hadrian bindist, not applying xxx path workaround.
375375- fi
376376- '';
377377-378378- # fix for `configure: error: Your linker is affected by binutils #16177`
379379- preConfigure = lib.optionalString stdenv.targetPlatform.isAarch32 "LD=ld.gold";
380380-381381- configurePlatforms = [ ];
382382- configureFlags = [
383383- "--with-gmp-includes=${lib.getDev gmp}/include"
384384- # Note `--with-gmp-libraries` does nothing for GHC bindists:
385385- # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6124
386386- ]
387387- ++ lib.optional stdenv.hostPlatform.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"
388388- # From: https://github.com/NixOS/nixpkgs/pull/43369/commits
389389- ++ lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
390390-391391- # No building is necessary, but calling make without flags ironically
392392- # calls install-strip ...
393393- dontBuild = true;
394394-395395- # GHC tries to remove xattrs when installing to work around Gatekeeper
396396- # (see https://gitlab.haskell.org/ghc/ghc/-/issues/17418). This step normally
397397- # succeeds in nixpkgs because xattrs are not allowed in the store, but it
398398- # can fail when a file has the `com.apple.provenance` xattr, and it can’t be
399399- # modified (such as target of the symlink to `libiconv.dylib`).
400400- # The `com.apple.provenance` xattr is a new feature of macOS as of macOS 13.
401401- # See: https://eclecticlight.co/2023/03/13/ventura-has-changed-app-quarantine-with-a-new-xattr/
402402- makeFlags = lib.optionals stdenv.buildPlatform.isDarwin [ "XATTR=/does-not-exist" ];
403403-404404- # Patch scripts to include runtime dependencies in $PATH.
405405- postInstall = ''
406406- for i in "$out/bin/"*; do
407407- test ! -h "$i" || continue
408408- isScript "$i" || continue
409409- sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i"
410410- done
411411- '';
412412-413413- # Apparently necessary for the ghc Alpine (musl) bindist:
414414- # When we strip, and then run the
415415- # patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
416416- # below, running ghc (e.g. during `installCheckPhase)` gives some apparently
417417- # corrupted rpath or whatever makes the loader work on nonsensical strings:
418418- # running install tests
419419- # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: : symbol not found
420420- # 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
421421- # 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
422422- # 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
423423- # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: �: symbol not found
424424- # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: �?: symbol not found
425425- # 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
426426- # This is extremely bogus and should be investigated.
427427- dontStrip = if stdenv.hostPlatform.isMusl then true else false; # `if` for explicitness
428428-429429- # On Linux, use patchelf to modify the executables so that they can
430430- # find editline/gmp.
431431- postFixup =
432432- lib.optionalString stdenv.hostPlatform.isLinux (
433433- if stdenv.hostPlatform.isAarch64 then
434434- # Keep rpath as small as possible on aarch64 for patchelf#244. All Elfs
435435- # are 2 directories deep from $out/lib, so pooling symlinks there makes
436436- # a short rpath.
437437- ''
438438- (cd $out/lib; ln -s ${ncurses6.out}/lib/libtinfo.so.6)
439439- (cd $out/lib; ln -s ${gmp.out}/lib/libgmp.so.10)
440440- (cd $out/lib; ln -s ${numactl.out}/lib/libnuma.so.1)
441441- for p in $(find "$out/lib" -type f -name "*\.so*"); do
442442- (cd $out/lib; ln -s $p)
443443- done
444444-445445- for p in $(find "$out/lib" -type f -executable); do
446446- if isELF "$p"; then
447447- echo "Patchelfing $p"
448448- patchelf --set-rpath "\$ORIGIN:\$ORIGIN/../.." $p
449449- fi
450450- done
451451- ''
452452- else
453453- ''
454454- for p in $(find "$out" -type f -executable); do
455455- if isELF "$p"; then
456456- echo "Patchelfing $p"
457457- patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
458458- fi
459459- done
460460- ''
461461- )
462462- + lib.optionalString stdenv.hostPlatform.isDarwin ''
463463- # not enough room in the object files for the full path to libiconv :(
464464- for exe in $(find "$out" -type f -executable); do
465465- isScript $exe && continue
466466- ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
467467- install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $exe
468468- done
469469-470470- for file in $(find "$out" -name setup-config); do
471471- substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
472472- done
473473- ''
474474- + lib.optionalString minimal ''
475475- # Remove profiling files
476476- find $out -type f -name '*.p_o' -delete
477477- find $out -type f -name '*.p_hi' -delete
478478- find $out -type f -name '*_p.a' -delete
479479- # `-f` because e.g. musl bindist does not have this file.
480480- rm -f $out/lib/ghc-*/bin/ghc-iserv-prof
481481- # Hydra will redistribute this derivation, so we have to keep the docs for
482482- # legal reasons (retaining the legal notices etc)
483483- # As a last resort we could unpack the docs separately and symlink them in.
484484- # They're in $out/share/{doc,man}.
485485- '';
486486-487487- # GHC cannot currently produce outputs that are ready for `-pie` linking.
488488- # Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
489489- # See:
490490- # * https://github.com/NixOS/nixpkgs/issues/129247
491491- # * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
492492- hardeningDisable = [ "pie" ];
493493-494494- doInstallCheck = true;
495495- installCheckPhase = ''
496496- # Sanity check, can ghc create executables?
497497- cd $TMP
498498- mkdir test-ghc; cd test-ghc
499499- cat > main.hs << EOF
500500- {-# LANGUAGE TemplateHaskell #-}
501501- module Main where
502502- main = putStrLn \$([|"yes"|])
503503- EOF
504504- env -i $out/bin/ghc --make main.hs || exit 1
505505- echo compilation ok
506506- [ $(./main) == "yes" ]
507507- '';
508508-509509- passthru = {
510510- targetPrefix = "";
511511- enableShared = true;
512512-513513- inherit llvmPackages;
514514-515515- # Our Cabal compiler name
516516- haskellCompilerName = "ghc-${version}";
517517- }
518518- # We duplicate binDistUsed here since we have a sensible default even if no bindist is available,
519519- # this makes sure that getting the `meta` attribute doesn't throw even on unsupported platforms.
520520- // lib.optionalAttrs (ghcBinDists.${distSetName}.${stdenv.hostPlatform.system}.isHadrian or false) {
521521- # Normal GHC derivations expose the hadrian derivation used to build them
522522- # here. In the case of bindists we just make sure that the attribute exists,
523523- # as it is used for checking if a GHC derivation has been built with hadrian.
524524- # The isHadrian mechanism will become obsolete with GHCs that use hadrian
525525- # exclusively, i.e. 9.6 (and 9.4?).
526526- hadrian = null;
527527- };
528528-529529- meta = rec {
530530- homepage = "http://haskell.org/ghc";
531531- description = "Glasgow Haskell Compiler";
532532- license = lib.licenses.bsd3;
533533- # HACK: since we can't encode the libc / abi in platforms, we need
534534- # to make the platform list dependent on the evaluation platform
535535- # in order to avoid eval errors with musl which supports less
536536- # platforms than the default libcs (i. e. glibc / libSystem).
537537- # This is done for the benefit of Hydra, so `packagePlatforms`
538538- # won't return any platforms that would cause an evaluation
539539- # failure for `pkgsMusl.haskell.compiler.ghc8107Binary`, as
540540- # long as the evaluator runs on a platform that supports
541541- # `pkgsMusl`.
542542- platforms = builtins.attrNames ghcBinDists.${distSetName};
543543- maintainers = with lib.maintainers; [ ];
544544- teams = [ lib.teams.haskell ];
545545- };
546546-}
-681
pkgs/development/compilers/ghc/8.10.7.nix
···11-let
22- version = "8.10.7";
33-in
44-55-{
66- lib,
77- stdenv,
88- pkgsBuildTarget,
99- pkgsHostTarget,
1010- buildPackages,
1111- targetPackages,
1212-1313- # build-tools
1414- bootPkgs,
1515- autoreconfHook,
1616- autoconf,
1717- automake,
1818- coreutils,
1919- fetchpatch,
2020- fetchurl,
2121- perl,
2222- python3,
2323- m4,
2424- sphinx,
2525- xattr,
2626- autoSignDarwinBinariesHook,
2727- bash,
2828-2929- libiconv ? null,
3030- ncurses,
3131-3232- # GHC can be built with system libffi or a bundled one.
3333- # we explicitly use libffi-3.3 here because 3.4 removes a flag that causes
3434- # problems for ghc-8.10.7's RTS. See #324384.
3535- # Save for aarch_darwin since libffi-3.3 is broken there but the issue isn't present anyway
3636- libffi ? null,
3737- libffi_3_3 ? null,
3838-3939- useLLVM ? !(import ./common-have-ncg.nix { inherit lib stdenv version; }),
4040- # LLVM is conceptually a run-time-only dependency, but for
4141- # non-x86, we need LLVM to bootstrap later stages, so it becomes a
4242- # build-time dependency too.
4343- buildTargetLlvmPackages,
4444- llvmPackages,
4545-4646- # If enabled, GHC will be built with the GPL-free but slower integer-simple
4747- # library instead of the faster but GPLed integer-gmp library.
4848- enableIntegerSimple ?
4949- !(lib.meta.availableOn stdenv.hostPlatform gmp && lib.meta.availableOn stdenv.targetPlatform gmp),
5050- gmp,
5151-5252- # If enabled, use -fPIC when compiling static libs.
5353- enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform,
5454-5555- # Exceeds Hydra output limit (at the time of writing ~3GB) when cross compiled to riscv64.
5656- # A riscv64 cross-compiler fits into the limit comfortably.
5757- enableProfiledLibs ? !stdenv.hostPlatform.isRiscV64,
5858-5959- # Whether to build dynamic libs for the standard library (on the target
6060- # platform). Static libs are always built.
6161- enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt,
6262-6363- # Whether to build terminfo.
6464- enableTerminfo ?
6565- !(
6666- stdenv.targetPlatform.isWindows
6767- # terminfo can't be built for cross
6868- || (stdenv.buildPlatform != stdenv.hostPlatform)
6969- || (stdenv.hostPlatform != stdenv.targetPlatform)
7070- ),
7171-7272- # Enable NUMA support in RTS
7373- enableNuma ? lib.meta.availableOn stdenv.targetPlatform numactl,
7474- numactl,
7575-7676- # What flavour to build. An empty string indicates no
7777- # specific flavour and falls back to ghc default values.
7878- ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) (
7979- if useLLVM then "perf-cross" else "perf-cross-ncg"
8080- ),
8181-8282- # Whether to build sphinx documentation.
8383- enableDocs ? (
8484- # Docs disabled if we are building on musl because it's a large task to keep
8585- # all `sphinx` dependencies building in this environment.
8686- !stdenv.buildPlatform.isMusl
8787- ),
8888-8989- enableHaddockProgram ?
9090- # Disabled for cross; see note [HADDOCK_DOCS].
9191- (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform),
9292-9393- # Whether to disable the large address space allocator
9494- # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
9595- disableLargeAddressSpace ? stdenv.targetPlatform.isiOS,
9696-9797- # Whether to build an unregisterised version of GHC.
9898- # GHC will normally auto-detect whether it can do a registered build, but this
9999- # option will force it to do an unregistered build when set to true.
100100- # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised
101101- enableUnregisterised ? false,
102102-}@args:
103103-104104-assert !enableIntegerSimple -> gmp != null;
105105-106106-# Cross cannot currently build the `haddock` program for silly reasons,
107107-# see note [HADDOCK_DOCS].
108108-assert
109109- (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform)
110110- -> !enableHaddockProgram;
111111-112112-# GHC does not support building when all 3 platforms are different.
113113-assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform;
114114-115115-let
116116- inherit (stdenv) buildPlatform hostPlatform targetPlatform;
117117-118118- # TODO(@Ericson2314) Make unconditional
119119- targetPrefix = lib.optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-";
120120-121121- buildMK = ''
122122- BuildFlavour = ${ghcFlavour}
123123- ifneq \"\$(BuildFlavour)\" \"\"
124124- include mk/flavours/\$(BuildFlavour).mk
125125- endif
126126- BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
127127- BUILD_SPHINX_PDF = NO
128128-129129- WITH_TERMINFO = ${if enableTerminfo then "YES" else "NO"}
130130- ''
131131- +
132132- # Note [HADDOCK_DOCS]:
133133- # Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
134134- # program is built (which we generally always want to have a complete GHC install)
135135- # and whether it is run on the GHC sources to generate hyperlinked source code
136136- # (which is impossible for cross-compilation); see:
137137- # https://gitlab.haskell.org/ghc/ghc/-/issues/20077
138138- # This implies that currently a cross-compiled GHC will never have a `haddock`
139139- # program, so it can never generate haddocks for any packages.
140140- # If this is solved in the future, we'd like to unconditionally
141141- # build the haddock program (removing the `enableHaddockProgram` option).
142142- ''
143143- HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
144144- # Build haddocks for boot packages with hyperlinking
145145- EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump
146146-147147- DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
148148- INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"}
149149- ''
150150- + lib.optionalString (targetPlatform != hostPlatform) ''
151151- Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
152152- CrossCompilePrefix = ${targetPrefix}
153153- ''
154154- + lib.optionalString (!enableProfiledLibs) ''
155155- BUILD_PROF_LIBS = NO
156156- ''
157157- + lib.optionalString enableRelocatedStaticLibs ''
158158- GhcLibHcOpts += -fPIC
159159- GhcRtsHcOpts += -fPIC
160160- ''
161161- + lib.optionalString targetPlatform.useAndroidPrebuilt ''
162162- EXTRA_CC_OPTS += -std=gnu99
163163- ''
164164- # While split sections are now enabled by default in ghc 8.8 for windows,
165165- # they seem to lead to `too many sections` errors when building base for
166166- # profiling.
167167- + lib.optionalString targetPlatform.isWindows ''
168168- SplitSections = NO
169169- '';
170170-171171- # Splicer will pull out correct variations
172172- libDeps =
173173- platform:
174174- lib.optional enableTerminfo ncurses
175175- ++ [ args.${libffi_name} ]
176176- ++ lib.optional (!enableIntegerSimple) gmp
177177- ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
178178-179179- # TODO(@sternenseemann): is buildTarget LLVM unnecessary?
180180- # GHC doesn't seem to have {LLC,OPT}_HOST
181181- toolsForTarget = [
182182- pkgsBuildTarget.targetPackages.stdenv.cc
183183- ]
184184- ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
185185-186186- buildCC = buildPackages.stdenv.cc;
187187- targetCC = builtins.head toolsForTarget;
188188- installCC = pkgsHostTarget.targetPackages.stdenv.cc;
189189-190190- # toolPath calculates the absolute path to the name tool associated with a
191191- # given `stdenv.cc` derivation, i.e. it picks the correct derivation to take
192192- # the tool from (cc, cc.bintools, cc.bintools.bintools) and adds the correct
193193- # subpath of the tool.
194194- toolPath =
195195- name: cc:
196196- let
197197- tools =
198198- {
199199- "cc" = cc;
200200- "c++" = cc;
201201- as = cc.bintools;
202202-203203- ar = cc.bintools;
204204- ranlib = cc.bintools;
205205- nm = cc.bintools;
206206- readelf = cc.bintools;
207207- objdump = cc.bintools;
208208-209209- ld = cc.bintools;
210210- "ld.gold" = cc.bintools;
211211-212212- otool = cc.bintools.bintools;
213213-214214- # GHC needs install_name_tool on all darwin platforms. The same one can
215215- # be used on both platforms. It is safe to use with linker-generated
216216- # signatures because it will update the signatures automatically after
217217- # modifying the target binary.
218218- install_name_tool = cc.bintools.bintools;
219219-220220- # strip on darwin is wrapped to enable deterministic mode.
221221- strip =
222222- # TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
223223- if stdenv.targetPlatform.isDarwin then cc.bintools else cc.bintools.bintools;
224224-225225- # clang is used as an assembler on darwin with the LLVM backend
226226- clang = cc;
227227- }
228228- .${name};
229229- in
230230- "${tools}/bin/${tools.targetPrefix}${name}";
231231-232232- # Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
233233- # But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
234234- # see #84670 and #49071 for more background.
235235- useLdGold =
236236- targetPlatform.linker == "gold"
237237- || (
238238- targetPlatform.linker == "bfd"
239239- && (targetCC.bintools.bintools.hasGold or false)
240240- && !targetPlatform.isMusl
241241- );
242242-243243- # Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
244244- variantSuffix = lib.concatStrings [
245245- (lib.optionalString stdenv.hostPlatform.isMusl "-musl")
246246- (lib.optionalString enableIntegerSimple "-integer-simple")
247247- ];
248248-249249- libffi_name =
250250- if stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64 then "libffi" else "libffi_3_3";
251251-252252- # These libraries are library dependencies of the standard libraries bundled
253253- # by GHC (core libs) users will link their compiled artifacts again. Thus,
254254- # they should be taken from targetPackages.
255255- #
256256- # We need to use pkgsHostTarget if we are cross compiling a native GHC compiler,
257257- # though (when native compiling GHC, pkgsHostTarget == targetPackages):
258258- #
259259- # 1. targetPackages would be empty(-ish) in this situation since we can't
260260- # execute cross compiled compilers in order to obtain the libraries
261261- # that would be in targetPackages.
262262- # 2. pkgsHostTarget is fine to use since hostPlatform == targetPlatform in this
263263- # situation.
264264- # 3. The core libs used by the final GHC (stage 2) for user artifacts are also
265265- # used to build stage 2 GHC itself, i.e. the core libs are both host and
266266- # target.
267267- targetLibs =
268268- let
269269- basePackageSet = if hostPlatform != targetPlatform then targetPackages else pkgsHostTarget;
270270- in
271271- {
272272- inherit (basePackageSet) gmp ncurses numactl;
273273- # dynamic inherits are not possible in Nix
274274- libffi = basePackageSet.${libffi_name};
275275- };
276276-277277-in
278278-279279-stdenv.mkDerivation (
280280- rec {
281281- inherit version;
282282- pname = "${targetPrefix}ghc${variantSuffix}";
283283-284284- src = fetchurl {
285285- url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
286286- sha256 = "e3eef6229ce9908dfe1ea41436befb0455fefb1932559e860ad4c606b0d03c9d";
287287- };
288288-289289- enableParallelBuilding = true;
290290-291291- outputs = [
292292- "out"
293293- "doc"
294294- ];
295295-296296- patches = [
297297- # Fix docs build with sphinx >= 6.0
298298- # https://gitlab.haskell.org/ghc/ghc/-/issues/22766
299299- (fetchpatch {
300300- name = "ghc-docs-sphinx-6.0.patch";
301301- url = "https://gitlab.haskell.org/ghc/ghc/-/commit/10e94a556b4f90769b7fd718b9790d58ae566600.patch";
302302- sha256 = "0kmhfamr16w8gch0lgln2912r8aryjky1hfcda3jkcwa5cdzgjdv";
303303- })
304304-305305- # Determine size of time related types using hsc2hs instead of assuming CLong.
306306- # Prevents failures when e.g. stat(2)ing on 32bit systems with 64bit time_t etc.
307307- # https://github.com/haskell/ghcup-hs/issues/1107
308308- # https://gitlab.haskell.org/ghc/ghc/-/issues/25095
309309- # Note that in normal situations this shouldn't be the case since nixpkgs
310310- # doesn't set -D_FILE_OFFSET_BITS=64 and friends (yet).
311311- (fetchpatch {
312312- name = "unix-fix-ctimeval-size-32-bit.patch";
313313- url = "https://github.com/haskell/unix/commit/8183e05b97ce870dd6582a3677cc82459ae566ec.patch";
314314- sha256 = "17q5yyigqr5kxlwwzb95sx567ysfxlw6bp3j4ji20lz0947aw6gv";
315315- stripLen = 1;
316316- extraPrefix = "libraries/unix/";
317317- })
318318-319319- # See upstream patch at
320320- # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4885. Since we build
321321- # from source distributions, the auto-generated configure script needs to be
322322- # patched as well, therefore we use an in-tree patch instead of pulling the
323323- # upstream patch. Don't forget to check backport status of the upstream patch
324324- # when adding new GHC releases in nixpkgs.
325325- ./respect-ar-path.patch
326326-327327- # fix hyperlinked haddock sources: https://github.com/haskell/haddock/pull/1482
328328- (fetchpatch {
329329- url = "https://patch-diff.githubusercontent.com/raw/haskell/haddock/pull/1482.patch";
330330- sha256 = "sha256-8w8QUCsODaTvknCDGgTfFNZa8ZmvIKaKS+2ZJZ9foYk=";
331331- extraPrefix = "utils/haddock/";
332332- stripLen = 1;
333333- })
334334-335335- # cabal passes incorrect --host= when cross-compiling
336336- # https://github.com/haskell/cabal/issues/5887
337337- (fetchpatch {
338338- url = "https://raw.githubusercontent.com/input-output-hk/haskell.nix/122bd81150386867da07fdc9ad5096db6719545a/overlays/patches/ghc/cabal-host.patch";
339339- sha256 = "sha256:0yd0sajgi24sc1w5m55lkg2lp6kfkgpp3lgija2c8y3cmkwfpdc1";
340340- })
341341-342342- # In order to build ghcjs packages, the Cabal of the ghc used for the ghcjs
343343- # needs to be patched. Ref https://github.com/haskell/cabal/pull/7575
344344- (fetchpatch {
345345- url = "https://github.com/haskell/cabal/commit/369c4a0a54ad08a9e6b0d3bd303fedd7b5e5a336.patch";
346346- sha256 = "120f11hwyaqa0pq9g5l1300crqij49jg0rh83hnp9sa49zfdwx1n";
347347- stripLen = 3;
348348- extraPrefix = "libraries/Cabal/Cabal/";
349349- })
350350-351351- # We need to be able to set AR_STAGE0 and LD_STAGE0 when cross-compiling
352352- (fetchpatch {
353353- url = "https://gitlab.haskell.org/ghc/ghc/-/commit/8f7dd5710b80906ea7a3e15b7bb56a883a49fed8.patch";
354354- hash = "sha256-C636Nq2U8YOG/av7XQmG3L1rU0bmC9/7m7Hty5pm5+s=";
355355- })
356356-357357- # Backport part of <https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7111> to 8.10.7
358358- # The change we are interested in is that Cabal no longer sets include-dirs
359359- # for the GHCi library delegating to the system search path or (in our case)
360360- # cc-wrapper. Without this patch, the target libffi ends up in there (which
361361- # we provide via --with-ffi-includes) which breaks bootstrapping e.g. when
362362- # cross compiling GHC. Without include-dirs, cc-wrapper and splicing will
363363- # correctly pick the suitable libffi out of the build environment.
364364- (fetchpatch {
365365- name = "ghci-no-libffi-include.patch";
366366- url = "https://gitlab.haskell.org/ghc/ghc/-/commit/b2721819f391ab49871271283f32df54810c4387.patch";
367367- sha256 = "1rmv3132xhxbka97v0rx7r6larx5f5nnvs4mgm9q3rmgpjyd1vf9";
368368- includes = [ "libraries/ghci/ghci.cabal.in" ];
369369- })
370370-371371- # Correctly record libnuma's library and include directories in the
372372- # package db. This fixes linking whenever stdenv and propagation won't
373373- # quite pass the correct -L flags to the linker, e.g. when using GHC
374374- # outside of stdenv/nixpkgs or build->build compilation in pkgsStatic.
375375- ./ghc-8.10-9.2-rts-package-db-libnuma-dirs.patch
376376- ]
377377- ++ lib.optionals stdenv.hostPlatform.isDarwin [
378378- # Make Block.h compile with c++ compilers. Remove with the next release
379379- (fetchpatch {
380380- url = "https://gitlab.haskell.org/ghc/ghc/-/commit/97d0b0a367e4c6a52a17c3299439ac7de129da24.patch";
381381- sha256 = "0r4zjj0bv1x1m2dgxp3adsf2xkr94fjnyj1igsivd9ilbs5ja0b5";
382382- })
383383- ]
384384- ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
385385- # Prevent the paths module from emitting symbols that we don't use
386386- # when building with separate outputs.
387387- #
388388- # These cause problems as they're not eliminated by GHC's dead code
389389- # elimination on aarch64-darwin. (see
390390- # https://github.com/NixOS/nixpkgs/issues/140774 for details).
391391- ./Cabal-3.2-3.4-paths-fix-cycle-aarch64-darwin.patch
392392- ];
393393-394394- postPatch = "patchShebangs .";
395395-396396- # GHC is a bit confused on its cross terminology.
397397- # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
398398- preConfigure = ''
399399- for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
400400- export "''${env#TARGET_}=''${!env}"
401401- done
402402- # Stage0 (build->build) which builds stage 1
403403- export GHC="${bootPkgs.ghc}/bin/ghc"
404404- # GHC is a bit confused on its cross terminology, as these would normally be
405405- # the *host* tools.
406406- export CC="${toolPath "cc" targetCC}"
407407- export CXX="${toolPath "c++" targetCC}"
408408- # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
409409- export LD="${toolPath "ld${lib.optionalString useLdGold ".gold"}" targetCC}"
410410- export AS="${toolPath "as" targetCC}"
411411- export AR="${toolPath "ar" targetCC}"
412412- export NM="${toolPath "nm" targetCC}"
413413- export RANLIB="${toolPath "ranlib" targetCC}"
414414- export READELF="${toolPath "readelf" targetCC}"
415415- export STRIP="${toolPath "strip" targetCC}"
416416- export OBJDUMP="${toolPath "objdump" targetCC}"
417417- ''
418418- + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
419419- export OTOOL="${toolPath "otool" targetCC}"
420420- export INSTALL_NAME_TOOL="${toolPath "install_name_tool" targetCC}"
421421- ''
422422- + lib.optionalString useLLVM ''
423423- export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
424424- export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
425425- ''
426426- + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
427427- # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
428428- # The executable we specify via $CLANG is used as an assembler (exclusively, it seems, but this isn't
429429- # clarified in any user facing documentation). As such, it'll be called on assembly produced by $CC
430430- # which usually comes from the darwin stdenv. To prevent a situation where $CLANG doesn't understand
431431- # the assembly it is given, we need to make sure that it matches the LLVM version of $CC if possible.
432432- # It is unclear (at the time of writing 2024-09-01) whether $CC should match the LLVM version we use
433433- # for llc and opt which would require using a custom darwin stdenv for targetCC.
434434- export CLANG="${
435435- if targetCC.isClang then
436436- toolPath "clang" targetCC
437437- else
438438- "${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
439439- }"
440440- ''
441441- + ''
442442- # No need for absolute paths since these tools only need to work during the build
443443- export CC_STAGE0="$CC_FOR_BUILD"
444444- export LD_STAGE0="$LD_FOR_BUILD"
445445- export AR_STAGE0="$AR_FOR_BUILD"
446446-447447- echo -n "${buildMK}" > mk/build.mk
448448- sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
449449- ''
450450- + lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
451451- export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
452452- ''
453453- + lib.optionalString stdenv.hostPlatform.isDarwin ''
454454- export NIX_LDFLAGS+=" -no_dtrace_dof"
455455-456456- # GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7
457457- export XATTR=${lib.getBin xattr}/bin/xattr
458458- ''
459459- + lib.optionalString targetPlatform.useAndroidPrebuilt ''
460460- 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
461461- ''
462462- + lib.optionalString targetPlatform.isMusl ''
463463- echo "patching llvm-targets for musl targets..."
464464- echo "Cloning these existing '*-linux-gnu*' targets:"
465465- grep linux-gnu llvm-targets | sed 's/^/ /'
466466- echo "(go go gadget sed)"
467467- sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
468468- echo "llvm-targets now contains these '*-linux-musl*' targets:"
469469- grep linux-musl llvm-targets | sed 's/^/ /'
470470-471471- echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
472472- # (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
473473- for x in configure aclocal.m4; do
474474- substituteInPlace $x \
475475- --replace '*-android*|*-gnueabi*)' \
476476- '*-android*|*-gnueabi*|*-musleabi*)'
477477- done
478478- '';
479479-480480- # Although it is usually correct to pass --host, we don't do that here because
481481- # GHC's usage of build, host, and target is non-standard.
482482- # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling
483483- # TODO(@Ericson2314): Always pass "--target" and always prefix.
484484- configurePlatforms = [
485485- "build"
486486- ]
487487- ++ lib.optional (buildPlatform != hostPlatform || targetPlatform != hostPlatform) "target";
488488-489489- # `--with` flags for libraries needed for RTS linker
490490- configureFlags = [
491491- "--datadir=$doc/share/doc/ghc"
492492- ]
493493- ++ lib.optionals enableTerminfo [
494494- "--with-curses-includes=${lib.getDev targetLibs.ncurses}/include"
495495- "--with-curses-libraries=${lib.getLib targetLibs.ncurses}/lib"
496496- ]
497497- ++ lib.optionals (args.${libffi_name} != null) [
498498- "--with-system-libffi"
499499- "--with-ffi-includes=${targetLibs.libffi.dev}/include"
500500- "--with-ffi-libraries=${targetLibs.libffi.out}/lib"
501501- ]
502502- ++ lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
503503- "--with-gmp-includes=${targetLibs.gmp.dev}/include"
504504- "--with-gmp-libraries=${targetLibs.gmp.out}/lib"
505505- ]
506506- ++
507507- lib.optionals
508508- (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows)
509509- [
510510- "--with-iconv-includes=${libiconv}/include"
511511- "--with-iconv-libraries=${libiconv}/lib"
512512- ]
513513- ++ lib.optionals (targetPlatform != hostPlatform) [
514514- "--enable-bootstrap-with-devel-snapshot"
515515- ]
516516- ++ lib.optionals useLdGold [
517517- "CFLAGS=-fuse-ld=gold"
518518- "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
519519- "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
520520- ]
521521- ++ lib.optionals (disableLargeAddressSpace) [
522522- "--disable-large-address-space"
523523- ]
524524- ++ lib.optionals enableNuma [
525525- "--enable-numa"
526526- "--with-libnuma-includes=${lib.getDev targetLibs.numactl}/include"
527527- "--with-libnuma-libraries=${lib.getLib targetLibs.numactl}/lib"
528528- ]
529529- ++ lib.optionals enableUnregisterised [
530530- "--enable-unregisterised"
531531- ];
532532-533533- # Make sure we never relax`$PATH` and hooks support for compatibility.
534534- strictDeps = true;
535535-536536- # Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
537537- dontAddExtraLibs = true;
538538-539539- nativeBuildInputs = [
540540- perl
541541- autoreconfHook
542542- autoconf
543543- automake
544544- m4
545545- python3
546546- bootPkgs.alex
547547- bootPkgs.happy
548548- bootPkgs.hscolour
549549- bootPkgs.ghc-settings-edit
550550- ]
551551- ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
552552- autoSignDarwinBinariesHook
553553- ]
554554- ++ lib.optionals enableDocs [
555555- sphinx
556556- ];
557557-558558- # Everything the stage0 compiler needs to build stage1: CC, bintools, extra libs.
559559- # See also GHC, {CC,LD,AR}_STAGE0 in preConfigure.
560560- depsBuildBuild = [
561561- # N.B. We do not declare bootPkgs.ghc in any of the stdenv.mkDerivation
562562- # dependency lists to prevent the bintools setup hook from adding ghc's
563563- # lib directory to the linker flags. Instead we tell configure about it
564564- # via the GHC environment variable.
565565- buildCC
566566- # stage0 builds terminfo unconditionally, so we always need ncurses
567567- ncurses
568568- ];
569569- # For building runtime libs
570570- depsBuildTarget = toolsForTarget;
571571-572572- # Prevent stage0 ghc from leaking into the final result. This was an issue
573573- # with GHC 9.6.
574574- disallowedReferences = [
575575- bootPkgs.ghc
576576- ];
577577-578578- buildInputs = [ bash ] ++ (libDeps hostPlatform);
579579-580580- # stage1 GHC doesn't need to link against libnuma, so it's target specific
581581- depsTargetTarget = map lib.getDev (
582582- libDeps targetPlatform ++ lib.optionals enableNuma [ targetLibs.numactl ]
583583- );
584584- depsTargetTargetPropagated = map (lib.getOutput "out") (
585585- libDeps targetPlatform ++ lib.optionals enableNuma [ targetLibs.numactl ]
586586- );
587587-588588- # required, because otherwise all symbols from HSffi.o are stripped, and
589589- # that in turn causes GHCi to abort
590590- stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
591591-592592- checkTarget = "test";
593593-594594- # GHC cannot currently produce outputs that are ready for `-pie` linking.
595595- # Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
596596- # See:
597597- # * https://github.com/NixOS/nixpkgs/issues/129247
598598- # * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
599599- hardeningDisable = [
600600- "format"
601601- "pie"
602602- ];
603603-604604- # big-parallel allows us to build with more than 2 cores on
605605- # Hydra which already warrants a significant speedup
606606- requiredSystemFeatures = [ "big-parallel" ];
607607-608608- postInstall = ''
609609- settingsFile="$out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings"
610610-611611- # Make the installed GHC use the host->target tools.
612612- ghc-settings-edit "$settingsFile" \
613613- "C compiler command" "${toolPath "cc" installCC}" \
614614- "Haskell CPP command" "${toolPath "cc" installCC}" \
615615- "C++ compiler command" "${toolPath "c++" installCC}" \
616616- "ld command" "${toolPath "ld${lib.optionalString useLdGold ".gold"}" installCC}" \
617617- "Merge objects command" "${toolPath "ld${lib.optionalString useLdGold ".gold"}" installCC}" \
618618- "ar command" "${toolPath "ar" installCC}" \
619619- "ranlib command" "${toolPath "ranlib" installCC}"
620620- ''
621621- + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
622622- ghc-settings-edit "$settingsFile" \
623623- "otool command" "${toolPath "otool" installCC}" \
624624- "install_name_tool command" "${toolPath "install_name_tool" installCC}"
625625- ''
626626- + lib.optionalString useLLVM ''
627627- ghc-settings-edit "$settingsFile" \
628628- "LLVM llc command" "${lib.getBin llvmPackages.llvm}/bin/llc" \
629629- "LLVM opt command" "${lib.getBin llvmPackages.llvm}/bin/opt"
630630- ''
631631- + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
632632- ghc-settings-edit "$settingsFile" \
633633- "LLVM clang command" "${
634634- # See comment for CLANG in preConfigure
635635- if installCC.isClang then
636636- toolPath "clang" installCC
637637- else
638638- "${llvmPackages.clang}/bin/${llvmPackages.clang.targetPrefix}clang"
639639- }"
640640- ''
641641- + ''
642642-643643- # Install the bash completion file.
644644- install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
645645- '';
646646-647647- passthru = {
648648- inherit bootPkgs targetPrefix;
649649-650650- inherit llvmPackages;
651651- inherit enableShared;
652652-653653- # This is used by the haskell builder to query
654654- # the presence of the haddock program.
655655- hasHaddock = enableHaddockProgram;
656656-657657- # Our Cabal compiler name
658658- haskellCompilerName = "ghc-${version}";
659659-660660- bootstrapAvailable = lib.meta.availableOn stdenv.buildPlatform bootPkgs.ghc;
661661- };
662662-663663- meta = {
664664- homepage = "http://haskell.org/ghc";
665665- description = "Glasgow Haskell Compiler";
666666- maintainers = with lib.maintainers; [
667667- guibou
668668- ];
669669- teams = [ lib.teams.haskell ];
670670- timeout = 24 * 3600;
671671- platforms = lib.platforms.all;
672672- inherit (bootPkgs.ghc.meta) license;
673673- };
674674-675675- }
676676- // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
677677- dontStrip = true;
678678- dontPatchELF = true;
679679- noAuditTmpdir = true;
680680- }
681681-)
···309309 # package db. This fixes linking whenever stdenv and propagation won't
310310 # quite pass the correct -L flags to the linker, e.g. when using GHC
311311 # outside of stdenv/nixpkgs or build->build compilation in pkgsStatic.
312312- (
313313- if lib.versionAtLeast version "9.4" then
314314- ./ghc-9.4-rts-package-db-libnuma-dirs.patch
315315- else
316316- ./ghc-8.10-9.2-rts-package-db-libnuma-dirs.patch
317317- )
312312+ ./ghc-9.4-rts-package-db-libnuma-dirs.patch
318313 ]
319314320315 # Before GHC 9.6, GHC, when used to compile C sources (i.e. to drive the CC), would first
···333328 #
334329 # https://gitlab.haskell.org/ghc/ghc/-/issues/25608#note_622589
335330 # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6877
336336- ++ (
337337- if lib.versionAtLeast version "9.4" then
338338- [
339339- # Need to use this patch so the next one applies, passes file location info to the cc phase
340340- (fetchpatch {
341341- name = "ghc-add-location-to-cc-phase.patch";
342342- url = "https://gitlab.haskell.org/ghc/ghc/-/commit/4a7256a75af2fc0318bef771a06949ffb3939d5a.patch";
343343- hash = "sha256-DnTI+i1zMebeWvw75D59vMaEEBb2Nr9HusxTyhmdy2M=";
344344- })
345345- # Makes Cc phase directly generate object files instead of assembly
346346- (fetchpatch {
347347- name = "ghc-cc-directly-emit-object.patch";
348348- url = "https://gitlab.haskell.org/ghc/ghc/-/commit/96811ba491495b601ec7d6a32bef8563b0292109.patch";
349349- hash = "sha256-G8u7/MK/tGOEN8Wxccxj/YIOP7mL2G9Co1WKdHXOo6I=";
350350- })
351351- ]
352352- else
353353- [
354354- # TODO(@sternenseemann): backport changes to GHC < 9.4 if possible
355355- ]
356356- )
331331+ ++ [
332332+ # Need to use this patch so the next one applies, passes file location info to the cc phase
333333+ (fetchpatch {
334334+ name = "ghc-add-location-to-cc-phase.patch";
335335+ url = "https://gitlab.haskell.org/ghc/ghc/-/commit/4a7256a75af2fc0318bef771a06949ffb3939d5a.patch";
336336+ hash = "sha256-DnTI+i1zMebeWvw75D59vMaEEBb2Nr9HusxTyhmdy2M=";
337337+ })
338338+ # Makes Cc phase directly generate object files instead of assembly
339339+ (fetchpatch {
340340+ name = "ghc-cc-directly-emit-object.patch";
341341+ url = "https://gitlab.haskell.org/ghc/ghc/-/commit/96811ba491495b601ec7d6a32bef8563b0292109.patch";
342342+ hash = "sha256-G8u7/MK/tGOEN8Wxccxj/YIOP7mL2G9Co1WKdHXOo6I=";
343343+ })
344344+ ]
357345358346 ++ [
359347 # Don't generate code that doesn't compile when --enable-relocatable is passed to Setup.hs
···366354 })
367355 ]
368356369369- # fix hyperlinked haddock sources: https://github.com/haskell/haddock/pull/1482
370370- ++ lib.optionals (lib.versionOlder version "9.4") [
371371- (fetchpatch {
372372- url = "https://patch-diff.githubusercontent.com/raw/haskell/haddock/pull/1482.patch";
373373- sha256 = "sha256-8w8QUCsODaTvknCDGgTfFNZa8ZmvIKaKS+2ZJZ9foYk=";
374374- extraPrefix = "utils/haddock/";
375375- stripLen = 1;
376376- })
377377- ]
378378-379357 # Fixes stack overrun in rts which crashes an process whenever
380358 # freeHaskellFunPtr is called with nixpkgs' hardening flags.
381359 # https://gitlab.haskell.org/ghc/ghc/-/issues/25485
382360 # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13599
383361 # TODO: patch doesn't apply for < 9.4, but may still be necessary?
384384- ++ lib.optionals (lib.versionAtLeast version "9.4") [
362362+ ++ [
385363 (fetchpatch {
386364 name = "ghc-rts-adjustor-fix-i386-stack-overrun.patch";
387365 url = "https://gitlab.haskell.org/ghc/ghc/-/commit/39bb6e583d64738db51441a556d499aa93a4fc4a.patch";
···389367 })
390368 ]
391369392392- ++ lib.optionals (lib.versionOlder version "9.4.6") [
393393- # Fix docs build with sphinx >= 6.0
394394- # https://gitlab.haskell.org/ghc/ghc/-/issues/22766
395395- (fetchpatch {
396396- name = "ghc-docs-sphinx-6.0.patch";
397397- url = "https://gitlab.haskell.org/ghc/ghc/-/commit/10e94a556b4f90769b7fd718b9790d58ae566600.patch";
398398- sha256 = "0kmhfamr16w8gch0lgln2912r8aryjky1hfcda3jkcwa5cdzgjdv";
399399- })
400400- ]
401401-402370 ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
403371 # Prevent the paths module from emitting symbols that we don't use
404372 # when building with separate outputs.
···466434 export AR_STAGE0="$AR_FOR_BUILD"
467435468436 echo -n "${buildMK}" > mk/build.mk
469469- ''
470470- + lib.optionalString (lib.versionAtLeast version "9.4") ''
471437 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
472438 ''
473439 + lib.optionalString (stdenv.hostPlatform.isLinux && hostPlatform.libc == "glibc") ''
···503469 --replace '*-android*|*-gnueabi*)' \
504470 '*-android*|*-gnueabi*|*-musleabi*)'
505471 done
506506- ''
507507- # HACK: allow bootstrapping with GHC 8.10 which works fine, as we don't have
508508- # binary 9.0 packaged. Bootstrapping with 9.2 is broken without hadrian.
509509- + lib.optionalString (lib.versions.majorMinor version == "9.4") ''
510510- substituteInPlace configure --replace \
511511- 'MinBootGhcVersion="9.0"' \
512512- 'MinBootGhcVersion="8.10"'
513472 '';
514473515474 # Although it is usually correct to pass --host, we don't do that here because
···19711971 # https://github.com/serokell/haskell-crypto/issues/25
19721972 crypto-sodium = dontCheck super.crypto-sodium;
1973197319741974- # Polyfill for GHCs from the integer-simple days that don't bundle ghc-bignum
19751975- ghc-bignum = super.ghc-bignum or self.mkDerivation {
19761976- pname = "ghc-bignum";
19771977- version = "1.0";
19781978- sha256 = "0xl848q8z6qx2bi6xil0d35lra7wshwvysyfblki659d7272b1im";
19791979- description = "GHC BigNum library";
19801980- license = lib.licenses.bsd3;
19811981- # ghc-bignum is not buildable if none of the three backends
19821982- # is explicitly enabled. We enable Native for now as it doesn't
19831983- # depend on anything else as opposed to GMP and FFI.
19841984- # Apply patch which fixes a compilation failure we encountered.
19851985- # Will need to be kept until we can drop ghc-bignum entirely,
19861986- # i. e. if GHC 8.10.* and 8.8.* have been removed.
19871987- configureFlags = [
19881988- "-f"
19891989- "Native"
19901990- ];
19911991- patches = [
19921992- (fetchpatch {
19931993- url = "https://gitlab.haskell.org/ghc/ghc/-/commit/08d1588bf38d83140a86817a7a615db486357d4f.patch";
19941994- sha256 = "sha256-Y9WW0KDQ/qY2L9ObPvh1i/6lxXIlprbxzdSBDfiaMtE=";
19951995- relative = "libraries/ghc-bignum";
19961996- })
19971997- ];
19981998- };
19991999-20001974 # 2021-04-09: too strict time bound
20011975 # PR pending https://github.com/zohl/cereal-time/pull/2
20021976 cereal-time = doJailbreak super.cereal-time;
···26152589 # 2025-02-06: Allow tasty-quickcheck == 0.11.*
26162590 # https://github.com/google/ghc-source-gen/issues/120
26172591 ghc-source-gen = doJailbreak super.ghc-source-gen;
26182618- ghc-source-gen_0_4_5_0 = doJailbreak super.ghc-source-gen_0_4_5_0;
26192592 # https://github.com/byteverse/bytebuild/issues/20#issuecomment-2652113837
26202593 bytebuild = doJailbreak super.bytebuild;
26212594 # https://github.com/haskellari/lattices/issues/132