Merge pull request #147260 from NixOS/haskell-updates

haskellPackages: improve LLVM handling for GHC

authored by sterni and committed by GitHub 2222809b d6312c26

+257 -150
+23 -2
nixos/doc/manual/from_md/release-notes/rl-2205.section.xml
··· 24 24 </section> 25 25 <section xml:id="sec-release-22.05-incompatibilities"> 26 26 <title>Backward Incompatibilities</title> 27 - <para> 28 - </para> 27 + <itemizedlist spacing="compact"> 28 + <listitem> 29 + <para> 30 + <literal>pkgs.ghc</literal> now refers to 31 + <literal>pkgs.targetPackages.haskellPackages.ghc</literal>. 32 + This <emphasis>only</emphasis> makes a difference if you are 33 + cross-compiling and will ensure that 34 + <literal>pkgs.ghc</literal> always runs on the host platform 35 + and compiles for the target platform (similar to 36 + <literal>pkgs.gcc</literal> for example). 37 + <literal>haskellPackages.ghc</literal> still behaves as 38 + before, running on the build platform and compiling for the 39 + host platform (similar to <literal>stdenv.cc</literal>). This 40 + means you don’t have to adjust your derivations if you use 41 + <literal>haskellPackages.callPackage</literal>, but when using 42 + <literal>pkgs.callPackage</literal> and taking 43 + <literal>ghc</literal> as an input, you should now use 44 + <literal>buildPackages.ghc</literal> instead to ensure cross 45 + compilation keeps working (or switch to 46 + <literal>haskellPackages.callPackage</literal>). 47 + </para> 48 + </listitem> 49 + </itemizedlist> 29 50 </section> 30 51 <section xml:id="sec-release-22.05-notable-changes"> 31 52 <title>Other Notable Changes</title>
+12
nixos/doc/manual/release-notes/rl-2205.section.md
··· 10 10 11 11 ## Backward Incompatibilities {#sec-release-22.05-incompatibilities} 12 12 13 + * `pkgs.ghc` now refers to `pkgs.targetPackages.haskellPackages.ghc`. 14 + This *only* makes a difference if you are cross-compiling and will 15 + ensure that `pkgs.ghc` always runs on the host platform and compiles 16 + for the target platform (similar to `pkgs.gcc` for example). 17 + `haskellPackages.ghc` still behaves as before, running on the build 18 + platform and compiling for the host platform (similar to `stdenv.cc`). 19 + This means you don't have to adjust your derivations if you use 20 + `haskellPackages.callPackage`, but when using `pkgs.callPackage` and 21 + taking `ghc` as an input, you should now use `buildPackages.ghc` 22 + instead to ensure cross compilation keeps working (or switch to 23 + `haskellPackages.callPackage`). 24 + 13 25 ## Other Notable Changes {#sec-release-22.05-notable-changes}
+30 -4
pkgs/development/compilers/ghc/8.10.2-binary.nix
··· 3 3 , ncurses5 4 4 , ncurses6, gmp, libiconv, numactl 5 5 , llvmPackages 6 + , coreutils 7 + , targetPackages 6 8 7 9 # minimal = true; will remove files that aren't strictly necessary for 8 10 # regular builds and GHC bootstrapping. ··· 140 142 libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY" 141 143 + "LD_LIBRARY_PATH"; 142 144 145 + runtimeDeps = [ 146 + targetPackages.stdenv.cc 147 + targetPackages.stdenv.cc.bintools 148 + coreutils # for cat 149 + ] 150 + ++ lib.optionals useLLVM [ 151 + (lib.getBin llvmPackages.llvm) 152 + ] 153 + # On darwin, we need unwrapped bintools as well (for otool) 154 + ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [ 155 + targetPackages.stdenv.cc.bintools.bintools 156 + ]; 157 + 143 158 in 144 159 145 160 stdenv.mkDerivation rec { ··· 156 171 157 172 nativeBuildInputs = [ perl ]; 158 173 propagatedBuildInputs = 159 - lib.optionals useLLVM [ llvmPackages.llvm ] 160 174 # Because musl bindists currently provide no way to tell where 161 175 # libgmp is (see not [musl bindists have no .buildinfo]), we need 162 176 # to propagate `gmp`, otherwise programs built by this ghc will ··· 177 191 # fixing the above-mentioned release issue, 178 192 # and for GHC >= 9.* it is not clear as of writing whether that switch 179 193 # will be made there too. 180 - ++ lib.optionals stdenv.hostPlatform.isMusl [ gmp ]; # musl bindist needs this 194 + lib.optionals stdenv.hostPlatform.isMusl [ gmp ]; # musl bindist needs this 181 195 182 196 # Set LD_LIBRARY_PATH or equivalent so that the programs running as part 183 197 # of the bindist installer can find the libraries they expect. ··· 278 292 # calls install-strip ... 279 293 dontBuild = true; 280 294 295 + # Patch scripts to include runtime dependencies in $PATH. 296 + postInstall = '' 297 + for i in "$out/bin/"*; do 298 + test ! -h "$i" || continue 299 + isScript "$i" || continue 300 + sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i" 301 + done 302 + ''; 303 + 281 304 # Apparently necessary for the ghc Alpine (musl) bindist: 282 305 # When we strip, and then run the 283 306 # patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p ··· 360 383 361 384 doInstallCheck = true; 362 385 installCheckPhase = '' 363 - unset ${libEnvVar} 364 386 # Sanity check, can ghc create executables? 365 387 cd $TMP 366 388 mkdir test-ghc; cd test-ghc ··· 369 391 module Main where 370 392 main = putStrLn \$([|"yes"|]) 371 393 EOF 372 - $out/bin/ghc --make main.hs || exit 1 394 + # can't use env -i here because otherwise we don't find -lgmp on musl 395 + env ${libEnvVar}= PATH= \ 396 + $out/bin/ghc --make main.hs || exit 1 373 397 echo compilation ok 374 398 [ $(./main) == "yes" ] 375 399 ''; ··· 377 401 passthru = { 378 402 targetPrefix = ""; 379 403 enableShared = true; 404 + 405 + inherit llvmPackages; 380 406 381 407 # Our Cabal compiler name 382 408 haskellCompilerName = "ghc-${version}";
+27 -5
pkgs/development/compilers/ghc/8.10.7-binary.nix
··· 3 3 , ncurses5 4 4 , ncurses6, gmp, libiconv, numactl 5 5 , llvmPackages 6 + , coreutils 7 + , targetPackages 6 8 7 9 # minimal = true; will remove files that aren't strictly necessary for 8 10 # regular builds and GHC bootstrapping. ··· 155 157 libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY" 156 158 + "LD_LIBRARY_PATH"; 157 159 160 + runtimeDeps = [ 161 + targetPackages.stdenv.cc 162 + targetPackages.stdenv.cc.bintools 163 + coreutils # for cat 164 + ] 165 + ++ lib.optionals useLLVM [ 166 + (lib.getBin llvmPackages.llvm) 167 + ] 168 + # On darwin, we need unwrapped bintools as well (for otool) 169 + ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [ 170 + targetPackages.stdenv.cc.bintools.bintools 171 + ]; 172 + 158 173 in 159 174 160 175 stdenv.mkDerivation rec { ··· 175 190 # and update this comment accordingly. 176 191 177 192 nativeBuildInputs = [ perl ]; 178 - propagatedBuildInputs = 179 - lib.optionals useLLVM [ llvmPackages.llvm ] 180 - ; 181 193 182 194 # Set LD_LIBRARY_PATH or equivalent so that the programs running as part 183 195 # of the bindist installer can find the libraries they expect. ··· 278 290 # calls install-strip ... 279 291 dontBuild = true; 280 292 293 + # Patch scripts to include runtime dependencies in $PATH. 294 + postInstall = '' 295 + for i in "$out/bin/"*; do 296 + test ! -h "$i" || continue 297 + isScript "$i" || continue 298 + sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i" 299 + done 300 + ''; 301 + 281 302 # Apparently necessary for the ghc Alpine (musl) bindist: 282 303 # When we strip, and then run the 283 304 # patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p ··· 360 381 361 382 doInstallCheck = true; 362 383 installCheckPhase = '' 363 - unset ${libEnvVar} 364 384 # Sanity check, can ghc create executables? 365 385 cd $TMP 366 386 mkdir test-ghc; cd test-ghc ··· 369 389 module Main where 370 390 main = putStrLn \$([|"yes"|]) 371 391 EOF 372 - $out/bin/ghc --make main.hs || exit 1 392 + env -i $out/bin/ghc --make main.hs || exit 1 373 393 echo compilation ok 374 394 [ $(./main) == "yes" ] 375 395 ''; ··· 377 397 passthru = { 378 398 targetPrefix = ""; 379 399 enableShared = true; 400 + 401 + inherit llvmPackages; 380 402 381 403 # Our Cabal compiler name 382 404 haskellCompilerName = "ghc-${version}";
+19 -20
pkgs/development/compilers/ghc/8.10.7.nix
··· 11 11 , # GHC can be built with system libffi or a bundled one. 12 12 libffi ? null 13 13 14 - , useLLVM ? !stdenv.targetPlatform.isx86 14 + , useLLVM ? !(stdenv.targetPlatform.isx86 15 + || stdenv.targetPlatform.isPowerPC 16 + || stdenv.targetPlatform.isSparc) 15 17 , # LLVM is conceptually a run-time-only depedendency, but for 16 18 # non-x86, we need LLVM to bootstrap later stages, so it becomes a 17 19 # build-time dependency too. ··· 120 122 ++ lib.optional (!enableIntegerSimple) gmp 121 123 ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv; 122 124 125 + # TODO(@sternenseemann): is buildTarget LLVM unnecessary? 126 + # GHC doesn't seem to have {LLC,OPT}_HOST 123 127 toolsForTarget = [ 124 128 pkgsBuildTarget.targetPackages.stdenv.cc 125 129 ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; ··· 131 135 # see #84670 and #49071 for more background. 132 136 useLdGold = targetPlatform.linker == "gold" || 133 137 (targetPlatform.linker == "bfd" && (targetPackages.stdenv.cc.bintools.bintools.hasGold or false) && !targetPlatform.isMusl); 134 - 135 - runtimeDeps = [ 136 - targetPackages.stdenv.cc.bintools 137 - coreutils 138 - ] 139 - # On darwin, we need unwrapped bintools as well (for otool) 140 - ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [ 141 - targetPackages.stdenv.cc.bintools.bintools 142 - ]; 143 138 144 139 # Makes debugging easier to see which variant is at play in `nix-store -q --tree`. 145 140 variantSuffix = lib.concatStrings [ ··· 196 191 postPatch = "patchShebangs ."; 197 192 198 193 # GHC is a bit confused on its cross terminology. 194 + # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths 199 195 preConfigure = '' 200 196 for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do 201 197 export "''${env#TARGET_}=''${!env}" ··· 212 208 export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" 213 209 export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" 214 210 export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" 211 + '' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") '' 212 + export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool" 213 + export INSTALL_NAME_TOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}install_name_tool" 214 + '' + lib.optionalString useLLVM '' 215 + export LLC="${lib.getBin llvmPackages.llvm}/bin/llc" 216 + export OPT="${lib.getBin llvmPackages.llvm}/bin/opt" 217 + '' + lib.optionalString (targetCC.isClang || (useLLVM && stdenv.targetPlatform.isDarwin)) (let 218 + # LLVM backend on Darwin needs clang, if we are already using clang, might as well set the environment variable. 219 + # See also https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm 220 + clang = if targetCC.isClang then targetCC else llvmPackages.clang; 221 + in '' 222 + export CLANG="${clang}/bin/${clang.targetPrefix}clang" 223 + '') + '' 215 224 216 225 echo -n "${buildMK}" > mk/build.mk 217 226 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure ··· 290 299 291 300 buildInputs = [ perl bash ] ++ (libDeps hostPlatform); 292 301 293 - propagatedBuildInputs = [ targetPackages.stdenv.cc ] 294 - ++ lib.optional useLLVM llvmPackages.llvm; 295 - 296 302 depsTargetTarget = map lib.getDev (libDeps targetPlatform); 297 303 depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform); 298 304 ··· 320 326 postInstall = '' 321 327 # Install the bash completion file. 322 328 install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc 323 - 324 - # Patch scripts to include "readelf" and "cat" in $PATH. 325 - for i in "$out/bin/"*; do 326 - test ! -h $i || continue 327 - egrep --quiet '^#!' <(head -n 1 $i) || continue 328 - sed -i -e '2i export PATH="$PATH:${lib.makeBinPath runtimeDeps}"' $i 329 - done 330 329 ''; 331 330 332 331 passthru = {
+28 -5
pkgs/development/compilers/ghc/8.6.5-binary.nix
··· 2 2 , fetchurl, perl, gcc 3 3 , ncurses5, ncurses6, gmp, glibc, libiconv 4 4 , llvmPackages 5 + , coreutils 6 + , targetPackages 5 7 }: 6 8 7 9 # Prebuilt only does native ··· 30 32 31 33 downloadsUrl = "https://downloads.haskell.org/ghc"; 32 34 35 + runtimeDeps = [ 36 + targetPackages.stdenv.cc 37 + targetPackages.stdenv.cc.bintools 38 + coreutils # for cat 39 + ] 40 + ++ lib.optionals useLLVM [ 41 + (lib.getBin llvmPackages.llvm) 42 + ] 43 + # On darwin, we need unwrapped bintools as well (for otool) 44 + ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [ 45 + targetPackages.stdenv.cc.bintools.bintools 46 + ]; 47 + 33 48 in 34 49 35 50 stdenv.mkDerivation rec { ··· 62 77 or (throw "cannot bootstrap GHC on this platform")); 63 78 64 79 nativeBuildInputs = [ perl ]; 65 - propagatedBuildInputs = lib.optionals useLLVM [ llvmPackages.llvm ]; 66 80 67 81 # Cannot patchelf beforehand due to relative RPATHs that anticipate 68 82 # the final install location/ ··· 130 144 # calls install-strip ... 131 145 dontBuild = true; 132 146 147 + # Patch scripts to include runtime dependencies in $PATH. 148 + postInstall = '' 149 + for i in "$out/bin/"*; do 150 + test ! -h "$i" || continue 151 + isScript "$i" || continue 152 + sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i" 153 + done 154 + ''; 155 + 133 156 # On Linux, use patchelf to modify the executables so that they can 134 157 # find editline/gmp. 135 158 postFixup = lib.optionalString stdenv.isLinux '' ··· 163 186 164 187 doInstallCheck = true; 165 188 installCheckPhase = '' 166 - unset ${libEnvVar} 167 189 # Sanity check, can ghc create executables? 168 190 cd $TMP 169 191 mkdir test-ghc; cd test-ghc ··· 172 194 module Main where 173 195 main = putStrLn \$([|"yes"|]) 174 196 EOF 175 - $out/bin/ghc --make main.hs || exit 1 197 + env -i $out/bin/ghc --make main.hs || exit 1 176 198 echo compilation ok 177 199 [ $(./main) == "yes" ] 178 200 ''; ··· 181 203 targetPrefix = ""; 182 204 enableShared = true; 183 205 206 + inherit llvmPackages; 207 + 184 208 # Our Cabal compiler name 185 209 haskellCompilerName = "ghc-${version}"; 186 210 }; 187 211 188 212 meta = rec { 189 213 license = lib.licenses.bsd3; 190 - platforms = ["x86_64-linux" "aarch64-linux" "i686-linux" "x86_64-darwin"]; 191 - hydraPlatforms = builtins.filter (p: p != "aarch64-linux") platforms; 214 + platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"]; 192 215 # build segfaults, use ghc8102Binary which has proper musl support instead 193 216 broken = stdenv.hostPlatform.isMusl; 194 217 maintainers = with lib.maintainers; [
+27 -21
pkgs/development/compilers/ghc/8.8.4.nix
··· 10 10 , # GHC can be built with system libffi or a bundled one. 11 11 libffi ? null 12 12 13 - , useLLVM ? !stdenv.targetPlatform.isx86 13 + , useLLVM ? !(stdenv.targetPlatform.isx86 14 + || stdenv.targetPlatform.isPowerPC 15 + || stdenv.targetPlatform.isSparc) 14 16 , # LLVM is conceptually a run-time-only depedendency, but for 15 17 # non-x86, we need LLVM to bootstrap later stages, so it becomes a 16 18 # build-time dependency too. ··· 128 130 ++ lib.optional (!enableIntegerSimple) gmp 129 131 ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv; 130 132 133 + # TODO(@sternenseemann): is buildTarget LLVM unnecessary? 134 + # GHC doesn't seem to have {LLC,OPT}_HOST 131 135 toolsForTarget = [ 132 136 pkgsBuildTarget.targetPackages.stdenv.cc 133 137 ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; ··· 139 143 # see #84670 and #49071 for more background. 140 144 useLdGold = targetPlatform.linker == "gold" || 141 145 (targetPlatform.linker == "bfd" && (targetPackages.stdenv.cc.bintools.bintools.hasGold or false) && !targetPlatform.isMusl); 142 - 143 - runtimeDeps = [ 144 - targetPackages.stdenv.cc.bintools 145 - coreutils 146 - ] 147 - # On darwin, we need unwrapped bintools as well (for otool) 148 - ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [ 149 - targetPackages.stdenv.cc.bintools.bintools 150 - ]; 151 146 152 147 # Makes debugging easier to see which variant is at play in `nix-store -q --tree`. 153 148 variantSuffix = lib.concatStrings [ ··· 197 192 postPatch = "patchShebangs ."; 198 193 199 194 # GHC is a bit confused on its cross terminology. 195 + # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths 200 196 preConfigure = 201 197 # Aarch64 allow backward bootstrapping since earlier versions are unstable. 202 198 # Same for musl, as earlier versions do not provide a musl bindist for bootstrapping. ··· 220 216 export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" 221 217 export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" 222 218 export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" 219 + '' + lib.optionalString useLLVM '' 220 + export LLC="${lib.getBin llvmPackages.llvm}/bin/llc" 221 + export OPT="${lib.getBin llvmPackages.llvm}/bin/opt" 222 + '' + lib.optionalString (targetCC.isClang || (useLLVM && stdenv.targetPlatform.isDarwin)) (let 223 + # LLVM backend on Darwin needs clang, if we are already using clang, might as well set the environment variable. 224 + # See also https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm 225 + clang = if targetCC.isClang then targetCC else llvmPackages.clang; 226 + in '' 227 + export CLANG="${clang}/bin/${clang.targetPrefix}clang" 228 + '') + '' 223 229 224 230 echo -n "${buildMK dontStrip}" > mk/build.mk 225 231 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure ··· 293 299 294 300 buildInputs = [ perl bash ] ++ (libDeps hostPlatform); 295 301 296 - propagatedBuildInputs = [ targetPackages.stdenv.cc ] 297 - ++ lib.optional useLLVM llvmPackages.llvm; 298 - 299 302 depsTargetTarget = map lib.getDev (libDeps targetPlatform); 300 303 depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform); 301 304 ··· 319 322 postInstall = '' 320 323 # Install the bash completion file. 321 324 install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc 322 - 323 - # Patch scripts to include "readelf" and "cat" in $PATH. 324 - for i in "$out/bin/"*; do 325 - test ! -h $i || continue 326 - egrep --quiet '^#!' <(head -n 1 $i) || continue 327 - sed -i -e '2i export PATH="$PATH:${lib.makeBinPath runtimeDeps}"' $i 328 - done 329 325 ''; 330 326 331 327 passthru = { ··· 345 341 guibou 346 342 ] ++ lib.teams.haskell.members; 347 343 timeout = 24 * 3600; 348 - inherit (ghc.meta) license platforms; 344 + inherit (ghc.meta) license; 345 + # hardcode platforms because the bootstrap GHC differs depending on the platform, 346 + # with differing platforms available for each of them; See HACK comment in 347 + # 8.10.2-binary.nix for an explanation of the musl special casing. 348 + platforms = [ 349 + "x86_64-linux" 350 + ] ++ lib.optionals (!hostPlatform.isMusl) [ 351 + "i686-linux" 352 + "aarch64-linux" 353 + "x86_64-darwin" 354 + ]; 349 355 # integer-simple builds are broken with musl when bootstrapping using 350 356 # GHC 8.10.2 and below, however it is not possible to reverse bootstrap 351 357 # GHC 8.8.4 with GHC 8.10.7.
+19 -20
pkgs/development/compilers/ghc/9.0.1.nix
··· 12 12 , # GHC can be built with system libffi or a bundled one. 13 13 libffi ? null 14 14 15 - , useLLVM ? !stdenv.targetPlatform.isx86 15 + , useLLVM ? !(stdenv.targetPlatform.isx86 16 + || stdenv.targetPlatform.isPowerPC 17 + || stdenv.targetPlatform.isSparc) 16 18 , # LLVM is conceptually a run-time-only depedendency, but for 17 19 # non-x86, we need LLVM to bootstrap later stages, so it becomes a 18 20 # build-time dependency too. ··· 115 117 ++ lib.optional (!enableIntegerSimple) gmp 116 118 ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv; 117 119 120 + # TODO(@sternenseemann): is buildTarget LLVM unnecessary? 121 + # GHC doesn't seem to have {LLC,OPT}_HOST 118 122 toolsForTarget = [ 119 123 pkgsBuildTarget.targetPackages.stdenv.cc 120 124 ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; ··· 127 131 useLdGold = targetPlatform.linker == "gold" || 128 132 (targetPlatform.linker == "bfd" && (targetPackages.stdenv.cc.bintools.bintools.hasGold or false) && !targetPlatform.isMusl); 129 133 130 - runtimeDeps = [ 131 - targetPackages.stdenv.cc.bintools 132 - coreutils 133 - ] 134 - # On darwin, we need unwrapped bintools as well (for otool) 135 - ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [ 136 - targetPackages.stdenv.cc.bintools.bintools 137 - ]; 138 - 139 134 # Makes debugging easier to see which variant is at play in `nix-store -q --tree`. 140 135 variantSuffix = lib.concatStrings [ 141 136 (lib.optionalString stdenv.hostPlatform.isMusl "-musl") ··· 162 157 LANG = "en_US.UTF-8"; 163 158 164 159 # GHC is a bit confused on its cross terminology. 160 + # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths 165 161 preConfigure = '' 166 162 for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do 167 163 export "''${env#TARGET_}=''${!env}" ··· 178 174 export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" 179 175 export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" 180 176 export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" 177 + '' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") '' 178 + export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool" 179 + export INSTALL_NAME_TOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}install_name_tool" 180 + '' + lib.optionalString useLLVM '' 181 + export LLC="${lib.getBin llvmPackages.llvm}/bin/llc" 182 + export OPT="${lib.getBin llvmPackages.llvm}/bin/opt" 183 + '' + lib.optionalString (targetCC.isClang || (useLLVM && stdenv.targetPlatform.isDarwin)) (let 184 + # LLVM backend on Darwin needs clang, if we are already using clang, might as well set the environment variable. 185 + # See also https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm 186 + clang = if targetCC.isClang then targetCC else llvmPackages.clang; 187 + in '' 188 + export CLANG="${clang}/bin/${clang.targetPrefix}clang" 189 + '') + '' 181 190 182 191 echo -n "${buildMK}" > mk/build.mk 183 192 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure ··· 255 264 256 265 buildInputs = [ perl bash ] ++ (libDeps hostPlatform); 257 266 258 - propagatedBuildInputs = [ targetPackages.stdenv.cc ] 259 - ++ lib.optional useLLVM llvmPackages.llvm; 260 - 261 267 depsTargetTarget = map lib.getDev (libDeps targetPlatform); 262 268 depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform); 263 269 ··· 285 291 postInstall = '' 286 292 # Install the bash completion file. 287 293 install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc 288 - 289 - # Patch scripts to include "readelf" and "cat" in $PATH. 290 - for i in "$out/bin/"*; do 291 - test ! -h $i || continue 292 - egrep --quiet '^#!' <(head -n 1 $i) || continue 293 - sed -i -e '2i export PATH="$PATH:${lib.makeBinPath runtimeDeps}"' $i 294 - done 295 294 ''; 296 295 297 296 passthru = {
+20 -20
pkgs/development/compilers/ghc/9.2.1.nix
··· 12 12 , # GHC can be built with system libffi or a bundled one. 13 13 libffi ? null 14 14 15 - , useLLVM ? !stdenv.targetPlatform.isx86 15 + , useLLVM ? !(stdenv.targetPlatform.isx86 16 + || stdenv.targetPlatform.isPowerPC 17 + || stdenv.targetPlatform.isSparc 18 + || (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin)) 16 19 , # LLVM is conceptually a run-time-only depedendency, but for 17 20 # non-x86, we need LLVM to bootstrap later stages, so it becomes a 18 21 # build-time dependency too. ··· 115 118 ++ lib.optional (!enableIntegerSimple) gmp 116 119 ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv; 117 120 121 + # TODO(@sternenseemann): is buildTarget LLVM unnecessary? 122 + # GHC doesn't seem to have {LLC,OPT}_HOST 118 123 toolsForTarget = [ 119 124 pkgsBuildTarget.targetPackages.stdenv.cc 120 125 ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; ··· 126 131 # see #84670 and #49071 for more background. 127 132 useLdGold = targetPlatform.linker == "gold" || (targetPlatform.linker == "bfd" && !targetPlatform.isMusl); 128 133 129 - runtimeDeps = [ 130 - targetPackages.stdenv.cc.bintools 131 - coreutils 132 - ] 133 - # On darwin, we need unwrapped bintools as well (for otool) 134 - ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [ 135 - targetPackages.stdenv.cc.bintools.bintools 136 - ]; 137 - 138 134 # Makes debugging easier to see which variant is at play in `nix-store -q --tree`. 139 135 variantSuffix = lib.concatStrings [ 140 136 (lib.optionalString stdenv.hostPlatform.isMusl "-musl") ··· 161 157 LANG = "en_US.UTF-8"; 162 158 163 159 # GHC is a bit confused on its cross terminology. 160 + # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths 164 161 preConfigure = '' 165 162 for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do 166 163 export "''${env#TARGET_}=''${!env}" ··· 177 174 export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" 178 175 export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" 179 176 export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" 177 + '' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") '' 178 + export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool" 179 + export INSTALL_NAME_TOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}install_name_tool" 180 + '' + lib.optionalString useLLVM '' 181 + export LLC="${lib.getBin llvmPackages.llvm}/bin/llc" 182 + export OPT="${lib.getBin llvmPackages.llvm}/bin/opt" 183 + '' + lib.optionalString (targetCC.isClang || (useLLVM && stdenv.targetPlatform.isDarwin)) (let 184 + # LLVM backend on Darwin needs clang, if we are already using clang, might as well set the environment variable. 185 + # See also https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm 186 + clang = if targetCC.isClang then targetCC else llvmPackages.clang; 187 + in '' 188 + export CLANG="${clang}/bin/${clang.targetPrefix}clang" 189 + '') + '' 180 190 181 191 echo -n "${buildMK}" > mk/build.mk 182 192 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure ··· 258 268 259 269 buildInputs = [ perl bash ] ++ (libDeps hostPlatform); 260 270 261 - propagatedBuildInputs = [ targetPackages.stdenv.cc ] 262 - ++ lib.optional useLLVM llvmPackages.llvm; 263 - 264 271 depsTargetTarget = map lib.getDev (libDeps targetPlatform); 265 272 depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform); 266 273 ··· 288 295 postInstall = '' 289 296 # Install the bash completion file. 290 297 install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc 291 - 292 - # Patch scripts to include "readelf" and "cat" in $PATH. 293 - for i in "$out/bin/"*; do 294 - test ! -h $i || continue 295 - egrep --quiet '^#!' <(head -n 1 $i) || continue 296 - sed -i -e '2i export PATH="$PATH:${lib.makeBinPath runtimeDeps}"' $i 297 - done 298 298 ''; 299 299 300 300 passthru = {
+20 -20
pkgs/development/compilers/ghc/head.nix
··· 17 17 !stdenv.targetPlatform.isWindows 18 18 , elfutils # for DWARF support 19 19 20 - , useLLVM ? !stdenv.targetPlatform.isx86 || stdenv.targetPlatform.isiOS 20 + , useLLVM ? !(stdenv.targetPlatform.isx86 21 + || stdenv.targetPlatform.isPowerPC 22 + || stdenv.targetPlatform.isSparc 23 + || (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin)) 21 24 , # LLVM is conceptually a run-time-only depedendency, but for 22 25 # non-x86, we need LLVM to bootstrap later stages, so it becomes a 23 26 # build-time dependency too. ··· 128 131 ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv 129 132 ++ lib.optional enableDwarf elfutils; 130 133 134 + # TODO(@sternenseemann): is buildTarget LLVM unnecessary? 135 + # GHC doesn't seem to have {LLC,OPT}_HOST 131 136 toolsForTarget = [ 132 137 pkgsBuildTarget.targetPackages.stdenv.cc 133 138 ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; ··· 140 145 useLdGold = targetPlatform.linker == "gold" || 141 146 (targetPlatform.linker == "bfd" && (targetPackages.stdenv.cc.bintools.bintools.hasGold or false) && !targetPlatform.isMusl); 142 147 143 - runtimeDeps = [ 144 - targetPackages.stdenv.cc.bintools 145 - coreutils 146 - ] 147 - # On darwin, we need unwrapped bintools as well (for otool) 148 - ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [ 149 - targetPackages.stdenv.cc.bintools.bintools 150 - ]; 151 - 152 148 # Makes debugging easier to see which variant is at play in `nix-store -q --tree`. 153 149 variantSuffix = lib.concatStrings [ 154 150 (lib.optionalString stdenv.hostPlatform.isMusl "-musl") ··· 174 170 postPatch = "patchShebangs ."; 175 171 176 172 # GHC is a bit confused on its cross terminology. 173 + # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths 177 174 preConfigure = '' 178 175 for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do 179 176 export "''${env#TARGET_}=''${!env}" ··· 191 188 export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" 192 189 export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" 193 190 export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" 191 + '' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") '' 192 + export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool" 193 + export INSTALL_NAME_TOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}install_name_tool" 194 + '' + lib.optionalString useLLVM '' 195 + export LLC="${lib.getBin llvmPackages.llvm}/bin/llc" 196 + export OPT="${lib.getBin llvmPackages.llvm}/bin/opt" 197 + '' + lib.optionalString (targetCC.isClang || (useLLVM && stdenv.targetPlatform.isDarwin)) (let 198 + # LLVM backend on Darwin needs clang, if we are already using clang, might as well set the environment variable. 199 + # See also https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm 200 + clang = if targetCC.isClang then targetCC else llvmPackages.clang; 201 + in '' 202 + export CLANG="${clang}/bin/${clang.targetPrefix}clang" 203 + '') + '' 194 204 195 205 # otherwise haddock fails when generating the compiler docs 196 206 export LANG=C.UTF-8 ··· 278 288 279 289 buildInputs = [ perl bash ] ++ (libDeps hostPlatform); 280 290 281 - propagatedBuildInputs = [ targetPackages.stdenv.cc ] 282 - ++ lib.optional useLLVM llvmPackages.llvm; 283 - 284 291 depsTargetTarget = map lib.getDev (libDeps targetPlatform); 285 292 depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform); 286 293 ··· 308 315 postInstall = '' 309 316 # Install the bash completion file. 310 317 install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc 311 - 312 - # Patch scripts to include "readelf" and "cat" in $PATH. 313 - for i in "$out/bin/"*; do 314 - test ! -h $i || continue 315 - egrep --quiet '^#!' <(head -n 1 $i) || continue 316 - sed -i -e '2i export PATH="$PATH:${lib.makeBinPath runtimeDeps}"' $i 317 - done 318 318 ''; 319 319 320 320 passthru = {
+1 -2
pkgs/development/haskell-modules/configuration-ghc-8.10.x.nix
··· 4 4 5 5 self: super: { 6 6 7 - # This compiler version needs llvm 9.x. 8 - llvmPackages = pkgs.lib.dontRecurseIntoAttrs pkgs.llvmPackages_9; 7 + llvmPackages = pkgs.lib.dontRecurseIntoAttrs self.ghc.llvmPackages; 9 8 10 9 # Disable GHC 8.10.x core libraries. 11 10 array = null;
+1 -2
pkgs/development/haskell-modules/configuration-ghc-8.6.x.nix
··· 4 4 5 5 self: super: { 6 6 7 - # This compiler version needs llvm 6.x. 8 - llvmPackages = pkgs.lib.dontRecurseIntoAttrs pkgs.llvmPackages_6; 7 + llvmPackages = pkgs.lib.dontRecurseIntoAttrs self.ghc.llvmPackages; 9 8 10 9 # Disable GHC 8.6.x core libraries. 11 10 array = null;
+1 -2
pkgs/development/haskell-modules/configuration-ghc-8.8.x.nix
··· 4 4 5 5 self: super: { 6 6 7 - # This compiler version needs llvm 7.x. 8 - llvmPackages = pkgs.lib.dontRecurseIntoAttrs pkgs.llvmPackages_7; 7 + llvmPackages = pkgs.lib.dontRecurseIntoAttrs self.ghc.llvmPackages; 9 8 10 9 # Disable GHC 8.8.x core libraries. 11 10 array = null;
+1 -2
pkgs/development/haskell-modules/configuration-ghc-9.0.x.nix
··· 4 4 5 5 self: super: { 6 6 7 - # This compiler version needs llvm 10.x. 8 - llvmPackages = pkgs.lib.dontRecurseIntoAttrs pkgs.llvmPackages_10; 7 + llvmPackages = pkgs.lib.dontRecurseIntoAttrs self.ghc.llvmPackages; 9 8 10 9 # Disable GHC 9.0.x core libraries. 11 10 array = null;
+1 -2
pkgs/development/haskell-modules/configuration-ghc-9.2.x.nix
··· 4 4 5 5 self: super: { 6 6 7 - # This compiler version needs llvm 10.x. 8 - llvmPackages = pkgs.lib.dontRecurseIntoAttrs pkgs.llvmPackages_10; 7 + llvmPackages = pkgs.lib.dontRecurseIntoAttrs self.ghc.llvmPackages; 9 8 10 9 # Disable GHC 9.2.x core libraries. 11 10 array = null;
+1 -1
pkgs/development/haskell-modules/configuration-ghc-head.nix
··· 11 11 12 12 self: super: { 13 13 14 - llvmPackages = pkgs.lib.dontRecurseIntoAttrs pkgs.llvmPackages_10; 14 + llvmPackages = pkgs.lib.dontRecurseIntoAttrs self.ghc.llvmPackages; 15 15 16 16 # Disable GHC 8.7.x core libraries. 17 17 array = null;
+4 -10
pkgs/development/haskell-modules/with-packages-wrapper.nix
··· 1 1 { lib, stdenv, ghc, llvmPackages, packages, symlinkJoin, makeWrapper 2 - # Include LLVM by default if GHC doesn't have native code generation support 3 - # See https://gitlab.haskell.org/ghc/ghc/-/wikis/platforms 4 - , useLLVM ? !(lib.any lib.id ([ 5 - stdenv.targetPlatform.isx86 6 - stdenv.targetPlatform.isPowerPC 7 - stdenv.targetPlatform.isSparc 8 - ] ++ lib.optionals (lib.versionAtLeast ghc.version "9.2") [ 9 - (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin) 10 - # TODO(@sternenseemann): Is armv7a supported for iOS? 11 - ])) 2 + # GHC will have LLVM available if necessary for the respective target, 3 + # so useLLVM only needs to be changed if -fllvm is to be used for a 4 + # platform that has NCG support 5 + , useLLVM ? false 12 6 , postBuild ? "" 13 7 , ghcLibdir ? null # only used by ghcjs, when resolving plugins 14 8 }:
+9 -1
pkgs/top-level/all-packages.nix
··· 12074 12074 # current default compiler is”, if you bump this: 12075 12075 haskellPackages = dontRecurseIntoAttrs haskell.packages.ghc8107; 12076 12076 12077 - inherit (haskellPackages) ghc; 12077 + # haskellPackages.ghc is build->host (it exposes the compiler used to build the 12078 + # set, similarly to stdenv.cc), but pkgs.ghc should be host->target to be more 12079 + # consistent with the gcc, gnat, clang etc. derivations 12080 + # 12081 + # We use targetPackages.haskellPackages.ghc if available since this also has 12082 + # the withPackages wrapper available. In the final cross-compiled package set 12083 + # however, targetPackages won't be populated, so we need to fall back to the 12084 + # plain, cross-compiled compiler (which is only theoretical at the moment). 12085 + ghc = targetPackages.haskellPackages.ghc or haskell.compiler.ghc8107; 12078 12086 12079 12087 cabal-install = haskell.lib.compose.justStaticExecutables haskellPackages.cabal-install; 12080 12088
+13 -11
pkgs/top-level/haskell-packages.nix
··· 50 50 51 51 compiler = { 52 52 53 - ghc865Binary = callPackage ../development/compilers/ghc/8.6.5-binary.nix { }; 53 + ghc865Binary = callPackage ../development/compilers/ghc/8.6.5-binary.nix { 54 + llvmPackages = pkgs.llvmPackages_6; 55 + }; 54 56 55 57 ghc8102Binary = callPackage ../development/compilers/ghc/8.10.2-binary.nix { 56 58 llvmPackages = pkgs.llvmPackages_9; ··· 62 64 }; 63 65 64 66 ghc8107Binary = callPackage ../development/compilers/ghc/8.10.7-binary.nix { 65 - llvmPackages = pkgs.llvmPackages_11; 67 + llvmPackages = pkgs.llvmPackages_12; 66 68 }; 67 69 68 70 ghc8107BinaryMinimal = callPackage ../development/compilers/ghc/8.10.7-binary.nix { 69 - llvmPackages = pkgs.llvmPackages_11; 71 + llvmPackages = pkgs.llvmPackages_12; 70 72 minimal = true; 71 73 }; 72 74 ··· 96 98 # https://github.com/xattr/xattr/issues/44 and 97 99 # https://github.com/xattr/xattr/issues/55 are solved. 98 100 inherit (buildPackages.darwin) xattr autoSignDarwinBinariesHook; 99 - buildTargetLlvmPackages = pkgsBuildTarget.llvmPackages_9; 100 - llvmPackages = pkgs.llvmPackages_9; 101 + buildTargetLlvmPackages = pkgsBuildTarget.llvmPackages_12; 102 + llvmPackages = pkgs.llvmPackages_12; 101 103 }; 102 104 ghc901 = callPackage ../development/compilers/ghc/9.0.1.nix { 103 105 bootPkgs = ··· 109 111 packages.ghc8107Binary; 110 112 inherit (buildPackages.python3Packages) sphinx; 111 113 inherit (buildPackages.darwin) autoSignDarwinBinariesHook; 112 - buildTargetLlvmPackages = pkgsBuildTarget.llvmPackages_10; 113 - llvmPackages = pkgs.llvmPackages_10; 114 + buildTargetLlvmPackages = pkgsBuildTarget.llvmPackages_9; 115 + llvmPackages = pkgs.llvmPackages_9; 114 116 }; 115 117 ghc921 = callPackage ../development/compilers/ghc/9.2.1.nix { 116 118 bootPkgs = ··· 124 126 # https://github.com/xattr/xattr/issues/44 and 125 127 # https://github.com/xattr/xattr/issues/55 are solved. 126 128 inherit (buildPackages.darwin) xattr autoSignDarwinBinariesHook; 127 - buildTargetLlvmPackages = pkgsBuildTarget.llvmPackages_10; 128 - llvmPackages = pkgs.llvmPackages_10; 129 + buildTargetLlvmPackages = pkgsBuildTarget.llvmPackages_12; 130 + llvmPackages = pkgs.llvmPackages_12; 129 131 }; 130 132 ghcHEAD = callPackage ../development/compilers/ghc/head.nix { 131 133 bootPkgs = packages.ghc8107Binary; ··· 134 136 # https://github.com/xattr/xattr/issues/44 and 135 137 # https://github.com/xattr/xattr/issues/55 are solved. 136 138 inherit (buildPackages.darwin) xattr autoSignDarwinBinariesHook; 137 - buildTargetLlvmPackages = pkgsBuildTarget.llvmPackages_10; 138 - llvmPackages = pkgs.llvmPackages_10; 139 + buildTargetLlvmPackages = pkgsBuildTarget.llvmPackages_12; 140 + llvmPackages = pkgs.llvmPackages_12; 139 141 libffi = pkgs.libffi; 140 142 }; 141 143