@@ -76,7 +76,7 @@ let self =
76
76
# don't use gold with with musl. Still seems to be
77
77
# affected by 22266.
78
78
&& ! stdenv . targetPlatform . isMusl )
79
-
79
+ , useLdLld ? false
80
80
, ghc-version ? src-spec . version
81
81
, ghc-version-date ? null
82
82
, ghc-commit-id ? null
@@ -95,6 +95,8 @@ assert !(enableIntegerSimple || enableNativeBignum) -> gmp != null;
95
95
assert enableNativeBignum -> ! enableIntegerSimple ;
96
96
assert enableIntegerSimple -> ! enableNativeBignum ;
97
97
98
+ assert ! ( useLdGold && useLdLld ) ;
99
+
98
100
let
99
101
src = src-spec . file or ( fetchurl { inherit ( src-spec ) url sha256 ; } ) ;
100
102
212
214
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
213
215
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
214
216
"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"
215
222
] ++ lib . optionals enableDWARF [
216
223
"--enable-dwarf-unwind"
217
224
"--with-libdw-includes=${ lib . getDev elfutils } /include"
@@ -449,7 +456,10 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
449
456
''
450
457
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
451
458
+ ''
452
- export LD="${ targetCC . bintools } /bin/${ targetCC . bintools . targetPrefix } ld${ lib . optionalString useLdGold ".gold" } "
459
+ export LD="${ if useLdLld then
460
+ "${ targetPackages . llvmPackages . bintools } /bin/${ targetPackages . llvmPackages . bintools . targetPrefix } ld.lld"
461
+ else
462
+ "${ targetCC . bintools } /bin/${ targetCC . bintools . targetPrefix } ld${ lib . optionalString useLdGold ".gold" } " } "
453
463
export AS="${ targetCC . bintools . bintools } /bin/${ targetCC . bintools . targetPrefix } as"
454
464
export AR="${ targetCC . bintools . bintools } /bin/${ targetCC . bintools . targetPrefix } ar"
455
465
export NM="${ targetCC . bintools . bintools } /bin/${ targetCC . bintools . targetPrefix } nm"
@@ -467,6 +477,8 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
467
477
# set LD explicitly if we want gold even if we aren't cross compiling
468
478
''
469
479
export LD="${ targetCC . bintools } /bin/ld.gold"
480
+ '' + lib . optionalString ( targetPlatform == hostPlatform && useLdLld ) ''
481
+ export LD="${ llvmPackages . bintools } /bin/ld.lld"
470
482
'' + lib . optionalString ( targetPlatform . isWindows ) ''
471
483
export DllWrap="${ targetCC . bintools . bintools } /bin/${ targetCC . bintools . targetPrefix } dllwrap"
472
484
export Windres="${ targetCC . bintools . bintools } /bin/${ targetCC . bintools . targetPrefix } windres"
@@ -533,6 +545,7 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
533
545
nativeBuildInputs = [
534
546
perl autoconf automake m4 python3 sphinx
535
547
ghc bootPkgs . alex bootPkgs . happy bootPkgs . hscolour
548
+ llvmPackages . bintools
536
549
] ++ lib . optional ( patches != [ ] ) autoreconfHook ;
537
550
538
551
# For building runtime libs
@@ -684,7 +697,7 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
684
697
'' ;
685
698
686
699
passthru = {
687
- inherit bootPkgs targetPrefix libDir llvmPackages enableShared enableTerminfo useLLVM hadrian hadrianProject ;
700
+ inherit bootPkgs targetPrefix libDir llvmPackages enableShared enableTerminfo useLLVM useLdLld hadrian hadrianProject ;
688
701
689
702
# Our Cabal compiler name
690
703
haskellCompilerName = "ghc-${ version } " ;
0 commit comments