···2424 </section>
2525 <section xml:id="sec-release-22.05-incompatibilities">
2626 <title>Backward Incompatibilities</title>
2727- <para>
2828- </para>
2727+ <itemizedlist spacing="compact">
2828+ <listitem>
2929+ <para>
3030+ <literal>pkgs.ghc</literal> now refers to
3131+ <literal>pkgs.targetPackages.haskellPackages.ghc</literal>.
3232+ This <emphasis>only</emphasis> makes a difference if you are
3333+ cross-compiling and will ensure that
3434+ <literal>pkgs.ghc</literal> always runs on the host platform
3535+ and compiles for the target platform (similar to
3636+ <literal>pkgs.gcc</literal> for example).
3737+ <literal>haskellPackages.ghc</literal> still behaves as
3838+ before, running on the build platform and compiling for the
3939+ host platform (similar to <literal>stdenv.cc</literal>). This
4040+ means you don’t have to adjust your derivations if you use
4141+ <literal>haskellPackages.callPackage</literal>, but when using
4242+ <literal>pkgs.callPackage</literal> and taking
4343+ <literal>ghc</literal> as an input, you should now use
4444+ <literal>buildPackages.ghc</literal> instead to ensure cross
4545+ compilation keeps working (or switch to
4646+ <literal>haskellPackages.callPackage</literal>).
4747+ </para>
4848+ </listitem>
4949+ </itemizedlist>
2950 </section>
3051 <section xml:id="sec-release-22.05-notable-changes">
3152 <title>Other Notable Changes</title>
+12
nixos/doc/manual/release-notes/rl-2205.section.md
···10101111## Backward Incompatibilities {#sec-release-22.05-incompatibilities}
12121313+* `pkgs.ghc` now refers to `pkgs.targetPackages.haskellPackages.ghc`.
1414+ This *only* makes a difference if you are cross-compiling and will
1515+ ensure that `pkgs.ghc` always runs on the host platform and compiles
1616+ for the target platform (similar to `pkgs.gcc` for example).
1717+ `haskellPackages.ghc` still behaves as before, running on the build
1818+ platform and compiling for the host platform (similar to `stdenv.cc`).
1919+ This means you don't have to adjust your derivations if you use
2020+ `haskellPackages.callPackage`, but when using `pkgs.callPackage` and
2121+ taking `ghc` as an input, you should now use `buildPackages.ghc`
2222+ instead to ensure cross compilation keeps working (or switch to
2323+ `haskellPackages.callPackage`).
2424+1325## Other Notable Changes {#sec-release-22.05-notable-changes}
+30-4
pkgs/development/compilers/ghc/8.10.2-binary.nix
···33, ncurses5
44, ncurses6, gmp, libiconv, numactl
55, llvmPackages
66+, coreutils
77+, targetPackages
6879 # minimal = true; will remove files that aren't strictly necessary for
810 # regular builds and GHC bootstrapping.
···140142 libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY"
141143 + "LD_LIBRARY_PATH";
142144145145+ runtimeDeps = [
146146+ targetPackages.stdenv.cc
147147+ targetPackages.stdenv.cc.bintools
148148+ coreutils # for cat
149149+ ]
150150+ ++ lib.optionals useLLVM [
151151+ (lib.getBin llvmPackages.llvm)
152152+ ]
153153+ # On darwin, we need unwrapped bintools as well (for otool)
154154+ ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [
155155+ targetPackages.stdenv.cc.bintools.bintools
156156+ ];
157157+143158in
144159145160stdenv.mkDerivation rec {
···156171157172 nativeBuildInputs = [ perl ];
158173 propagatedBuildInputs =
159159- lib.optionals useLLVM [ llvmPackages.llvm ]
160174 # Because musl bindists currently provide no way to tell where
161175 # libgmp is (see not [musl bindists have no .buildinfo]), we need
162176 # to propagate `gmp`, otherwise programs built by this ghc will
···177191 # fixing the above-mentioned release issue,
178192 # and for GHC >= 9.* it is not clear as of writing whether that switch
179193 # will be made there too.
180180- ++ lib.optionals stdenv.hostPlatform.isMusl [ gmp ]; # musl bindist needs this
194194+ lib.optionals stdenv.hostPlatform.isMusl [ gmp ]; # musl bindist needs this
181195182196 # Set LD_LIBRARY_PATH or equivalent so that the programs running as part
183197 # of the bindist installer can find the libraries they expect.
···278292 # calls install-strip ...
279293 dontBuild = true;
280294295295+ # Patch scripts to include runtime dependencies in $PATH.
296296+ postInstall = ''
297297+ for i in "$out/bin/"*; do
298298+ test ! -h "$i" || continue
299299+ isScript "$i" || continue
300300+ sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i"
301301+ done
302302+ '';
303303+281304 # Apparently necessary for the ghc Alpine (musl) bindist:
282305 # When we strip, and then run the
283306 # patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
···360383361384 doInstallCheck = true;
362385 installCheckPhase = ''
363363- unset ${libEnvVar}
364386 # Sanity check, can ghc create executables?
365387 cd $TMP
366388 mkdir test-ghc; cd test-ghc
···369391 module Main where
370392 main = putStrLn \$([|"yes"|])
371393 EOF
372372- $out/bin/ghc --make main.hs || exit 1
394394+ # can't use env -i here because otherwise we don't find -lgmp on musl
395395+ env ${libEnvVar}= PATH= \
396396+ $out/bin/ghc --make main.hs || exit 1
373397 echo compilation ok
374398 [ $(./main) == "yes" ]
375399 '';
···377401 passthru = {
378402 targetPrefix = "";
379403 enableShared = true;
404404+405405+ inherit llvmPackages;
380406381407 # Our Cabal compiler name
382408 haskellCompilerName = "ghc-${version}";
+27-5
pkgs/development/compilers/ghc/8.10.7-binary.nix
···33, ncurses5
44, ncurses6, gmp, libiconv, numactl
55, llvmPackages
66+, coreutils
77+, targetPackages
6879 # minimal = true; will remove files that aren't strictly necessary for
810 # regular builds and GHC bootstrapping.
···155157 libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY"
156158 + "LD_LIBRARY_PATH";
157159160160+ runtimeDeps = [
161161+ targetPackages.stdenv.cc
162162+ targetPackages.stdenv.cc.bintools
163163+ coreutils # for cat
164164+ ]
165165+ ++ lib.optionals useLLVM [
166166+ (lib.getBin llvmPackages.llvm)
167167+ ]
168168+ # On darwin, we need unwrapped bintools as well (for otool)
169169+ ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [
170170+ targetPackages.stdenv.cc.bintools.bintools
171171+ ];
172172+158173in
159174160175stdenv.mkDerivation rec {
···175190 # and update this comment accordingly.
176191177192 nativeBuildInputs = [ perl ];
178178- propagatedBuildInputs =
179179- lib.optionals useLLVM [ llvmPackages.llvm ]
180180- ;
181193182194 # Set LD_LIBRARY_PATH or equivalent so that the programs running as part
183195 # of the bindist installer can find the libraries they expect.
···278290 # calls install-strip ...
279291 dontBuild = true;
280292293293+ # Patch scripts to include runtime dependencies in $PATH.
294294+ postInstall = ''
295295+ for i in "$out/bin/"*; do
296296+ test ! -h "$i" || continue
297297+ isScript "$i" || continue
298298+ sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i"
299299+ done
300300+ '';
301301+281302 # Apparently necessary for the ghc Alpine (musl) bindist:
282303 # When we strip, and then run the
283304 # patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
···360381361382 doInstallCheck = true;
362383 installCheckPhase = ''
363363- unset ${libEnvVar}
364384 # Sanity check, can ghc create executables?
365385 cd $TMP
366386 mkdir test-ghc; cd test-ghc
···369389 module Main where
370390 main = putStrLn \$([|"yes"|])
371391 EOF
372372- $out/bin/ghc --make main.hs || exit 1
392392+ env -i $out/bin/ghc --make main.hs || exit 1
373393 echo compilation ok
374394 [ $(./main) == "yes" ]
375395 '';
···377397 passthru = {
378398 targetPrefix = "";
379399 enableShared = true;
400400+401401+ inherit llvmPackages;
380402381403 # Our Cabal compiler name
382404 haskellCompilerName = "ghc-${version}";
+19-20
pkgs/development/compilers/ghc/8.10.7.nix
···1111, # GHC can be built with system libffi or a bundled one.
1212 libffi ? null
13131414-, useLLVM ? !stdenv.targetPlatform.isx86
1414+, useLLVM ? !(stdenv.targetPlatform.isx86
1515+ || stdenv.targetPlatform.isPowerPC
1616+ || stdenv.targetPlatform.isSparc)
1517, # LLVM is conceptually a run-time-only depedendency, but for
1618 # non-x86, we need LLVM to bootstrap later stages, so it becomes a
1719 # build-time dependency too.
···120122 ++ lib.optional (!enableIntegerSimple) gmp
121123 ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
122124125125+ # TODO(@sternenseemann): is buildTarget LLVM unnecessary?
126126+ # GHC doesn't seem to have {LLC,OPT}_HOST
123127 toolsForTarget = [
124128 pkgsBuildTarget.targetPackages.stdenv.cc
125129 ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
···131135 # see #84670 and #49071 for more background.
132136 useLdGold = targetPlatform.linker == "gold" ||
133137 (targetPlatform.linker == "bfd" && (targetPackages.stdenv.cc.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
134134-135135- runtimeDeps = [
136136- targetPackages.stdenv.cc.bintools
137137- coreutils
138138- ]
139139- # On darwin, we need unwrapped bintools as well (for otool)
140140- ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [
141141- targetPackages.stdenv.cc.bintools.bintools
142142- ];
143138144139 # Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
145140 variantSuffix = lib.concatStrings [
···196191 postPatch = "patchShebangs .";
197192198193 # GHC is a bit confused on its cross terminology.
194194+ # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
199195 preConfigure = ''
200196 for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
201197 export "''${env#TARGET_}=''${!env}"
···212208 export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
213209 export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
214210 export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
211211+ '' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
212212+ export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
213213+ export INSTALL_NAME_TOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}install_name_tool"
214214+ '' + lib.optionalString useLLVM ''
215215+ export LLC="${lib.getBin llvmPackages.llvm}/bin/llc"
216216+ export OPT="${lib.getBin llvmPackages.llvm}/bin/opt"
217217+ '' + lib.optionalString (targetCC.isClang || (useLLVM && stdenv.targetPlatform.isDarwin)) (let
218218+ # LLVM backend on Darwin needs clang, if we are already using clang, might as well set the environment variable.
219219+ # See also https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
220220+ clang = if targetCC.isClang then targetCC else llvmPackages.clang;
221221+ in ''
222222+ export CLANG="${clang}/bin/${clang.targetPrefix}clang"
223223+ '') + ''
215224216225 echo -n "${buildMK}" > mk/build.mk
217226 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
···290299291300 buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
292301293293- propagatedBuildInputs = [ targetPackages.stdenv.cc ]
294294- ++ lib.optional useLLVM llvmPackages.llvm;
295295-296302 depsTargetTarget = map lib.getDev (libDeps targetPlatform);
297303 depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
298304···320326 postInstall = ''
321327 # Install the bash completion file.
322328 install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
323323-324324- # Patch scripts to include "readelf" and "cat" in $PATH.
325325- for i in "$out/bin/"*; do
326326- test ! -h $i || continue
327327- egrep --quiet '^#!' <(head -n 1 $i) || continue
328328- sed -i -e '2i export PATH="$PATH:${lib.makeBinPath runtimeDeps}"' $i
329329- done
330329 '';
331330332331 passthru = {
+28-5
pkgs/development/compilers/ghc/8.6.5-binary.nix
···22, fetchurl, perl, gcc
33, ncurses5, ncurses6, gmp, glibc, libiconv
44, llvmPackages
55+, coreutils
66+, targetPackages
57}:
6879# Prebuilt only does native
···30323133 downloadsUrl = "https://downloads.haskell.org/ghc";
32343535+ runtimeDeps = [
3636+ targetPackages.stdenv.cc
3737+ targetPackages.stdenv.cc.bintools
3838+ coreutils # for cat
3939+ ]
4040+ ++ lib.optionals useLLVM [
4141+ (lib.getBin llvmPackages.llvm)
4242+ ]
4343+ # On darwin, we need unwrapped bintools as well (for otool)
4444+ ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [
4545+ targetPackages.stdenv.cc.bintools.bintools
4646+ ];
4747+3348in
34493550stdenv.mkDerivation rec {
···6277 or (throw "cannot bootstrap GHC on this platform"));
63786479 nativeBuildInputs = [ perl ];
6565- propagatedBuildInputs = lib.optionals useLLVM [ llvmPackages.llvm ];
66806781 # Cannot patchelf beforehand due to relative RPATHs that anticipate
6882 # the final install location/
···130144 # calls install-strip ...
131145 dontBuild = true;
132146147147+ # Patch scripts to include runtime dependencies in $PATH.
148148+ postInstall = ''
149149+ for i in "$out/bin/"*; do
150150+ test ! -h "$i" || continue
151151+ isScript "$i" || continue
152152+ sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i"
153153+ done
154154+ '';
155155+133156 # On Linux, use patchelf to modify the executables so that they can
134157 # find editline/gmp.
135158 postFixup = lib.optionalString stdenv.isLinux ''
···163186164187 doInstallCheck = true;
165188 installCheckPhase = ''
166166- unset ${libEnvVar}
167189 # Sanity check, can ghc create executables?
168190 cd $TMP
169191 mkdir test-ghc; cd test-ghc
···172194 module Main where
173195 main = putStrLn \$([|"yes"|])
174196 EOF
175175- $out/bin/ghc --make main.hs || exit 1
197197+ env -i $out/bin/ghc --make main.hs || exit 1
176198 echo compilation ok
177199 [ $(./main) == "yes" ]
178200 '';
···181203 targetPrefix = "";
182204 enableShared = true;
183205206206+ inherit llvmPackages;
207207+184208 # Our Cabal compiler name
185209 haskellCompilerName = "ghc-${version}";
186210 };
187211188212 meta = rec {
189213 license = lib.licenses.bsd3;
190190- platforms = ["x86_64-linux" "aarch64-linux" "i686-linux" "x86_64-darwin"];
191191- hydraPlatforms = builtins.filter (p: p != "aarch64-linux") platforms;
214214+ platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"];
192215 # build segfaults, use ghc8102Binary which has proper musl support instead
193216 broken = stdenv.hostPlatform.isMusl;
194217 maintainers = with lib.maintainers; [
+27-21
pkgs/development/compilers/ghc/8.8.4.nix
···1010, # GHC can be built with system libffi or a bundled one.
1111 libffi ? null
12121313-, useLLVM ? !stdenv.targetPlatform.isx86
1313+, useLLVM ? !(stdenv.targetPlatform.isx86
1414+ || stdenv.targetPlatform.isPowerPC
1515+ || stdenv.targetPlatform.isSparc)
1416, # LLVM is conceptually a run-time-only depedendency, but for
1517 # non-x86, we need LLVM to bootstrap later stages, so it becomes a
1618 # build-time dependency too.
···128130 ++ lib.optional (!enableIntegerSimple) gmp
129131 ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
130132133133+ # TODO(@sternenseemann): is buildTarget LLVM unnecessary?
134134+ # GHC doesn't seem to have {LLC,OPT}_HOST
131135 toolsForTarget = [
132136 pkgsBuildTarget.targetPackages.stdenv.cc
133137 ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
···139143 # see #84670 and #49071 for more background.
140144 useLdGold = targetPlatform.linker == "gold" ||
141145 (targetPlatform.linker == "bfd" && (targetPackages.stdenv.cc.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
142142-143143- runtimeDeps = [
144144- targetPackages.stdenv.cc.bintools
145145- coreutils
146146- ]
147147- # On darwin, we need unwrapped bintools as well (for otool)
148148- ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [
149149- targetPackages.stdenv.cc.bintools.bintools
150150- ];
151146152147 # Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
153148 variantSuffix = lib.concatStrings [
···197192 postPatch = "patchShebangs .";
198193199194 # GHC is a bit confused on its cross terminology.
195195+ # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
200196 preConfigure =
201197 # Aarch64 allow backward bootstrapping since earlier versions are unstable.
202198 # Same for musl, as earlier versions do not provide a musl bindist for bootstrapping.
···220216 export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
221217 export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
222218 export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
219219+ '' + lib.optionalString useLLVM ''
220220+ export LLC="${lib.getBin llvmPackages.llvm}/bin/llc"
221221+ export OPT="${lib.getBin llvmPackages.llvm}/bin/opt"
222222+ '' + lib.optionalString (targetCC.isClang || (useLLVM && stdenv.targetPlatform.isDarwin)) (let
223223+ # LLVM backend on Darwin needs clang, if we are already using clang, might as well set the environment variable.
224224+ # See also https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
225225+ clang = if targetCC.isClang then targetCC else llvmPackages.clang;
226226+ in ''
227227+ export CLANG="${clang}/bin/${clang.targetPrefix}clang"
228228+ '') + ''
223229224230 echo -n "${buildMK dontStrip}" > mk/build.mk
225231 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
···293299294300 buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
295301296296- propagatedBuildInputs = [ targetPackages.stdenv.cc ]
297297- ++ lib.optional useLLVM llvmPackages.llvm;
298298-299302 depsTargetTarget = map lib.getDev (libDeps targetPlatform);
300303 depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
301304···319322 postInstall = ''
320323 # Install the bash completion file.
321324 install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
322322-323323- # Patch scripts to include "readelf" and "cat" in $PATH.
324324- for i in "$out/bin/"*; do
325325- test ! -h $i || continue
326326- egrep --quiet '^#!' <(head -n 1 $i) || continue
327327- sed -i -e '2i export PATH="$PATH:${lib.makeBinPath runtimeDeps}"' $i
328328- done
329325 '';
330326331327 passthru = {
···345341 guibou
346342 ] ++ lib.teams.haskell.members;
347343 timeout = 24 * 3600;
348348- inherit (ghc.meta) license platforms;
344344+ inherit (ghc.meta) license;
345345+ # hardcode platforms because the bootstrap GHC differs depending on the platform,
346346+ # with differing platforms available for each of them; See HACK comment in
347347+ # 8.10.2-binary.nix for an explanation of the musl special casing.
348348+ platforms = [
349349+ "x86_64-linux"
350350+ ] ++ lib.optionals (!hostPlatform.isMusl) [
351351+ "i686-linux"
352352+ "aarch64-linux"
353353+ "x86_64-darwin"
354354+ ];
349355 # integer-simple builds are broken with musl when bootstrapping using
350356 # GHC 8.10.2 and below, however it is not possible to reverse bootstrap
351357 # GHC 8.8.4 with GHC 8.10.7.
+19-20
pkgs/development/compilers/ghc/9.0.1.nix
···1212, # GHC can be built with system libffi or a bundled one.
1313 libffi ? null
14141515-, useLLVM ? !stdenv.targetPlatform.isx86
1515+, useLLVM ? !(stdenv.targetPlatform.isx86
1616+ || stdenv.targetPlatform.isPowerPC
1717+ || stdenv.targetPlatform.isSparc)
1618, # LLVM is conceptually a run-time-only depedendency, but for
1719 # non-x86, we need LLVM to bootstrap later stages, so it becomes a
1820 # build-time dependency too.
···115117 ++ lib.optional (!enableIntegerSimple) gmp
116118 ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
117119120120+ # TODO(@sternenseemann): is buildTarget LLVM unnecessary?
121121+ # GHC doesn't seem to have {LLC,OPT}_HOST
118122 toolsForTarget = [
119123 pkgsBuildTarget.targetPackages.stdenv.cc
120124 ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
···127131 useLdGold = targetPlatform.linker == "gold" ||
128132 (targetPlatform.linker == "bfd" && (targetPackages.stdenv.cc.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
129133130130- runtimeDeps = [
131131- targetPackages.stdenv.cc.bintools
132132- coreutils
133133- ]
134134- # On darwin, we need unwrapped bintools as well (for otool)
135135- ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [
136136- targetPackages.stdenv.cc.bintools.bintools
137137- ];
138138-139134 # Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
140135 variantSuffix = lib.concatStrings [
141136 (lib.optionalString stdenv.hostPlatform.isMusl "-musl")
···162157 LANG = "en_US.UTF-8";
163158164159 # GHC is a bit confused on its cross terminology.
160160+ # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
165161 preConfigure = ''
166162 for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
167163 export "''${env#TARGET_}=''${!env}"
···178174 export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
179175 export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
180176 export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
177177+ '' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
178178+ export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
179179+ export INSTALL_NAME_TOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}install_name_tool"
180180+ '' + lib.optionalString useLLVM ''
181181+ export LLC="${lib.getBin llvmPackages.llvm}/bin/llc"
182182+ export OPT="${lib.getBin llvmPackages.llvm}/bin/opt"
183183+ '' + lib.optionalString (targetCC.isClang || (useLLVM && stdenv.targetPlatform.isDarwin)) (let
184184+ # LLVM backend on Darwin needs clang, if we are already using clang, might as well set the environment variable.
185185+ # See also https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
186186+ clang = if targetCC.isClang then targetCC else llvmPackages.clang;
187187+ in ''
188188+ export CLANG="${clang}/bin/${clang.targetPrefix}clang"
189189+ '') + ''
181190182191 echo -n "${buildMK}" > mk/build.mk
183192 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
···255264256265 buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
257266258258- propagatedBuildInputs = [ targetPackages.stdenv.cc ]
259259- ++ lib.optional useLLVM llvmPackages.llvm;
260260-261267 depsTargetTarget = map lib.getDev (libDeps targetPlatform);
262268 depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
263269···285291 postInstall = ''
286292 # Install the bash completion file.
287293 install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
288288-289289- # Patch scripts to include "readelf" and "cat" in $PATH.
290290- for i in "$out/bin/"*; do
291291- test ! -h $i || continue
292292- egrep --quiet '^#!' <(head -n 1 $i) || continue
293293- sed -i -e '2i export PATH="$PATH:${lib.makeBinPath runtimeDeps}"' $i
294294- done
295294 '';
296295297296 passthru = {
+20-20
pkgs/development/compilers/ghc/9.2.1.nix
···1212, # GHC can be built with system libffi or a bundled one.
1313 libffi ? null
14141515-, useLLVM ? !stdenv.targetPlatform.isx86
1515+, useLLVM ? !(stdenv.targetPlatform.isx86
1616+ || stdenv.targetPlatform.isPowerPC
1717+ || stdenv.targetPlatform.isSparc
1818+ || (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin))
1619, # LLVM is conceptually a run-time-only depedendency, but for
1720 # non-x86, we need LLVM to bootstrap later stages, so it becomes a
1821 # build-time dependency too.
···115118 ++ lib.optional (!enableIntegerSimple) gmp
116119 ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
117120121121+ # TODO(@sternenseemann): is buildTarget LLVM unnecessary?
122122+ # GHC doesn't seem to have {LLC,OPT}_HOST
118123 toolsForTarget = [
119124 pkgsBuildTarget.targetPackages.stdenv.cc
120125 ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
···126131 # see #84670 and #49071 for more background.
127132 useLdGold = targetPlatform.linker == "gold" || (targetPlatform.linker == "bfd" && !targetPlatform.isMusl);
128133129129- runtimeDeps = [
130130- targetPackages.stdenv.cc.bintools
131131- coreutils
132132- ]
133133- # On darwin, we need unwrapped bintools as well (for otool)
134134- ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [
135135- targetPackages.stdenv.cc.bintools.bintools
136136- ];
137137-138134 # Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
139135 variantSuffix = lib.concatStrings [
140136 (lib.optionalString stdenv.hostPlatform.isMusl "-musl")
···161157 LANG = "en_US.UTF-8";
162158163159 # GHC is a bit confused on its cross terminology.
160160+ # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
164161 preConfigure = ''
165162 for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
166163 export "''${env#TARGET_}=''${!env}"
···177174 export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
178175 export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
179176 export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
177177+ '' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
178178+ export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
179179+ export INSTALL_NAME_TOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}install_name_tool"
180180+ '' + lib.optionalString useLLVM ''
181181+ export LLC="${lib.getBin llvmPackages.llvm}/bin/llc"
182182+ export OPT="${lib.getBin llvmPackages.llvm}/bin/opt"
183183+ '' + lib.optionalString (targetCC.isClang || (useLLVM && stdenv.targetPlatform.isDarwin)) (let
184184+ # LLVM backend on Darwin needs clang, if we are already using clang, might as well set the environment variable.
185185+ # See also https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
186186+ clang = if targetCC.isClang then targetCC else llvmPackages.clang;
187187+ in ''
188188+ export CLANG="${clang}/bin/${clang.targetPrefix}clang"
189189+ '') + ''
180190181191 echo -n "${buildMK}" > mk/build.mk
182192 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
···258268259269 buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
260270261261- propagatedBuildInputs = [ targetPackages.stdenv.cc ]
262262- ++ lib.optional useLLVM llvmPackages.llvm;
263263-264271 depsTargetTarget = map lib.getDev (libDeps targetPlatform);
265272 depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
266273···288295 postInstall = ''
289296 # Install the bash completion file.
290297 install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
291291-292292- # Patch scripts to include "readelf" and "cat" in $PATH.
293293- for i in "$out/bin/"*; do
294294- test ! -h $i || continue
295295- egrep --quiet '^#!' <(head -n 1 $i) || continue
296296- sed -i -e '2i export PATH="$PATH:${lib.makeBinPath runtimeDeps}"' $i
297297- done
298298 '';
299299300300 passthru = {
+20-20
pkgs/development/compilers/ghc/head.nix
···1717 !stdenv.targetPlatform.isWindows
1818, elfutils # for DWARF support
19192020-, useLLVM ? !stdenv.targetPlatform.isx86 || stdenv.targetPlatform.isiOS
2020+, useLLVM ? !(stdenv.targetPlatform.isx86
2121+ || stdenv.targetPlatform.isPowerPC
2222+ || stdenv.targetPlatform.isSparc
2323+ || (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin))
2124, # LLVM is conceptually a run-time-only depedendency, but for
2225 # non-x86, we need LLVM to bootstrap later stages, so it becomes a
2326 # build-time dependency too.
···128131 ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv
129132 ++ lib.optional enableDwarf elfutils;
130133134134+ # TODO(@sternenseemann): is buildTarget LLVM unnecessary?
135135+ # GHC doesn't seem to have {LLC,OPT}_HOST
131136 toolsForTarget = [
132137 pkgsBuildTarget.targetPackages.stdenv.cc
133138 ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
···140145 useLdGold = targetPlatform.linker == "gold" ||
141146 (targetPlatform.linker == "bfd" && (targetPackages.stdenv.cc.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
142147143143- runtimeDeps = [
144144- targetPackages.stdenv.cc.bintools
145145- coreutils
146146- ]
147147- # On darwin, we need unwrapped bintools as well (for otool)
148148- ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [
149149- targetPackages.stdenv.cc.bintools.bintools
150150- ];
151151-152148 # Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
153149 variantSuffix = lib.concatStrings [
154150 (lib.optionalString stdenv.hostPlatform.isMusl "-musl")
···174170 postPatch = "patchShebangs .";
175171176172 # GHC is a bit confused on its cross terminology.
173173+ # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
177174 preConfigure = ''
178175 for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
179176 export "''${env#TARGET_}=''${!env}"
···191188 export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
192189 export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
193190 export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
191191+ '' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
192192+ export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
193193+ export INSTALL_NAME_TOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}install_name_tool"
194194+ '' + lib.optionalString useLLVM ''
195195+ export LLC="${lib.getBin llvmPackages.llvm}/bin/llc"
196196+ export OPT="${lib.getBin llvmPackages.llvm}/bin/opt"
197197+ '' + lib.optionalString (targetCC.isClang || (useLLVM && stdenv.targetPlatform.isDarwin)) (let
198198+ # LLVM backend on Darwin needs clang, if we are already using clang, might as well set the environment variable.
199199+ # See also https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
200200+ clang = if targetCC.isClang then targetCC else llvmPackages.clang;
201201+ in ''
202202+ export CLANG="${clang}/bin/${clang.targetPrefix}clang"
203203+ '') + ''
194204195205 # otherwise haddock fails when generating the compiler docs
196206 export LANG=C.UTF-8
···278288279289 buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
280290281281- propagatedBuildInputs = [ targetPackages.stdenv.cc ]
282282- ++ lib.optional useLLVM llvmPackages.llvm;
283283-284291 depsTargetTarget = map lib.getDev (libDeps targetPlatform);
285292 depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
286293···308315 postInstall = ''
309316 # Install the bash completion file.
310317 install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
311311-312312- # Patch scripts to include "readelf" and "cat" in $PATH.
313313- for i in "$out/bin/"*; do
314314- test ! -h $i || continue
315315- egrep --quiet '^#!' <(head -n 1 $i) || continue
316316- sed -i -e '2i export PATH="$PATH:${lib.makeBinPath runtimeDeps}"' $i
317317- done
318318 '';
319319320320 passthru = {
···11{ lib, stdenv, ghc, llvmPackages, packages, symlinkJoin, makeWrapper
22-# Include LLVM by default if GHC doesn't have native code generation support
33-# See https://gitlab.haskell.org/ghc/ghc/-/wikis/platforms
44-, useLLVM ? !(lib.any lib.id ([
55- stdenv.targetPlatform.isx86
66- stdenv.targetPlatform.isPowerPC
77- stdenv.targetPlatform.isSparc
88- ] ++ lib.optionals (lib.versionAtLeast ghc.version "9.2") [
99- (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin)
1010- # TODO(@sternenseemann): Is armv7a supported for iOS?
1111- ]))
22+# GHC will have LLVM available if necessary for the respective target,
33+# so useLLVM only needs to be changed if -fllvm is to be used for a
44+# platform that has NCG support
55+, useLLVM ? false
126, postBuild ? ""
137, ghcLibdir ? null # only used by ghcjs, when resolving plugins
148}:
+9-1
pkgs/top-level/all-packages.nix
···1207412074 # current default compiler is”, if you bump this:
1207512075 haskellPackages = dontRecurseIntoAttrs haskell.packages.ghc8107;
12076120761207712077- inherit (haskellPackages) ghc;
1207712077+ # haskellPackages.ghc is build->host (it exposes the compiler used to build the
1207812078+ # set, similarly to stdenv.cc), but pkgs.ghc should be host->target to be more
1207912079+ # consistent with the gcc, gnat, clang etc. derivations
1208012080+ #
1208112081+ # We use targetPackages.haskellPackages.ghc if available since this also has
1208212082+ # the withPackages wrapper available. In the final cross-compiled package set
1208312083+ # however, targetPackages won't be populated, so we need to fall back to the
1208412084+ # plain, cross-compiled compiler (which is only theoretical at the moment).
1208512085+ ghc = targetPackages.haskellPackages.ghc or haskell.compiler.ghc8107;
12078120861207912087 cabal-install = haskell.lib.compose.justStaticExecutables haskellPackages.cabal-install;
1208012088