@@ -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"
@@ -433,7 +440,10 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
433
440
''
434
441
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
435
442
+ ''
436
- export LD="${ targetCC . bintools } /bin/${ targetCC . bintools . targetPrefix } ld${ lib . optionalString useLdGold ".gold" } "
443
+ export LD="${ if useLdLld then
444
+ "${ targetPackages . llvmPackages . bintools } /bin/${ targetPackages . llvmPackages . bintools . targetPrefix } ld.lld"
445
+ else
446
+ "${ targetCC . bintools } /bin/${ targetCC . bintools . targetPrefix } ld${ lib . optionalString useLdGold ".gold" } " } "
437
447
export AS="${ targetCC . bintools . bintools } /bin/${ targetCC . bintools . targetPrefix } as"
438
448
export AR="${ targetCC . bintools . bintools } /bin/${ targetCC . bintools . targetPrefix } ar"
439
449
export NM="${ targetCC . bintools . bintools } /bin/${ targetCC . bintools . targetPrefix } nm"
@@ -451,6 +461,8 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
451
461
# set LD explicitly if we want gold even if we aren't cross compiling
452
462
''
453
463
export LD="${ targetCC . bintools } /bin/ld.gold"
464
+ '' + lib . optionalString ( targetPlatform == hostPlatform && useLdLld ) ''
465
+ export LD="${ llvmPackages . bintools } /bin/ld.lld"
454
466
'' + lib . optionalString ( targetPlatform . isWindows ) ''
455
467
export DllWrap="${ targetCC . bintools . bintools } /bin/${ targetCC . bintools . targetPrefix } dllwrap"
456
468
export Windres="${ targetCC . bintools . bintools } /bin/${ targetCC . bintools . targetPrefix } windres"
@@ -517,7 +529,8 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
517
529
nativeBuildInputs = [
518
530
perl autoconf automake m4 python3 sphinx
519
531
ghc bootPkgs . alex bootPkgs . happy bootPkgs . hscolour
520
- ] ++ lib . optional ( patches != [ ] ) autoreconfHook ;
532
+ ] ++ lib . optional ( patches != [ ] ) autoreconfHook
533
+ ++ lib . optional useLdLld llvmPackages . bintools ;
521
534
522
535
# For building runtime libs
523
536
depsBuildTarget = toolsForTarget ;
@@ -668,7 +681,7 @@ haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
668
681
'' ;
669
682
670
683
passthru = {
671
- inherit bootPkgs targetPrefix libDir llvmPackages enableShared useLLVM hadrian hadrianProject ;
684
+ inherit bootPkgs targetPrefix libDir llvmPackages enableShared useLLVM useLdLld hadrian hadrianProject ;
672
685
673
686
# Our Cabal compiler name
674
687
haskellCompilerName = "ghc-${ version } " ;
0 commit comments