@@ -76,7 +76,7 @@ let self =
7676 # don't use gold with with musl. Still seems to be
7777 # affected by 22266.
7878 && ! stdenv . targetPlatform . isMusl )
79-
79+ , useLdLld ? false
8080, ghc-version ? src-spec . version
8181, ghc-version-date ? null
8282, ghc-commit-id ? null
@@ -95,6 +95,8 @@ assert !(enableIntegerSimple || enableNativeBignum) -> gmp != null;
9595assert enableNativeBignum -> ! enableIntegerSimple ;
9696assert enableIntegerSimple -> ! enableNativeBignum ;
9797
98+ assert ! ( useLdGold && useLdLld ) ;
99+
98100let
99101 src = src-spec . file or ( fetchurl { inherit ( src-spec ) url sha256 ; } ) ;
100102
212214 "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
213215 "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
214216 "CONF_LD_LINKER_OPTS_STAGE2=-fuse-ld=gold" # See: <https://gitlab.haskell.org/ghc/ghc/-/issues/22550#note_466656>
217+ ] ++ lib . optionals useLdLld [
218+ "LD=${ llvmPackages . bintools } /bin/ld.lld"
219+ "CFLAGS=-fuse-ld=lld"
220+ "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=lld"
221+ "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=lld"
215222 ] ++ lib . optionals enableDWARF [
216223 "--enable-dwarf-unwind"
217224 "--with-libdw-includes=${ lib . getDev elfutils } /include"
@@ -467,6 +474,8 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
467474 # set LD explicitly if we want gold even if we aren't cross compiling
468475 ''
469476 export LD="${ targetCC . bintools } /bin/ld.gold"
477+ '' + lib . optionalString useLdLld ''
478+ export LD="${ llvmPackages . bintools } /bin/ld.lld"
470479 '' + lib . optionalString ( targetPlatform . isWindows ) ''
471480 export DllWrap="${ targetCC . bintools . bintools } /bin/${ targetCC . bintools . targetPrefix } dllwrap"
472481 export Windres="${ targetCC . bintools . bintools } /bin/${ targetCC . bintools . targetPrefix } windres"
@@ -533,6 +542,7 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
533542 nativeBuildInputs = [
534543 perl autoconf automake m4 python3 sphinx
535544 ghc bootPkgs . alex bootPkgs . happy bootPkgs . hscolour
545+ llvmPackages . bintools
536546 ] ++ lib . optional ( patches != [ ] ) autoreconfHook ;
537547
538548 # For building runtime libs
@@ -684,7 +694,7 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
684694 '' ;
685695
686696 passthru = {
687- inherit bootPkgs targetPrefix libDir llvmPackages enableShared enableTerminfo useLLVM hadrian hadrianProject ;
697+ inherit bootPkgs targetPrefix libDir llvmPackages enableShared enableTerminfo useLLVM useLdLld hadrian hadrianProject ;
688698
689699 # Our Cabal compiler name
690700 haskellCompilerName = "ghc-${ version } " ;
0 commit comments