diff --git a/pkgs/development/compilers/ghc/8.10.4.nix b/pkgs/development/compilers/ghc/8.10.4.nix index 07784c426479..b0fb726e9c6f 100644 --- a/pkgs/development/compilers/ghc/8.10.4.nix +++ b/pkgs/development/compilers/ghc/8.10.4.nix @@ -122,7 +122,8 @@ let # Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues. # But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856 # see #84670 and #49071 for more background. - useLdGold = targetPlatform.linker == "gold" || (targetPlatform.linker == "bfd" && !targetPlatform.isMusl); + useLdGold = targetPlatform.linker == "gold" || + (targetPlatform.linker == "bfd" && (targetPackages.stdenv.cc.bintools.bintools.hasGold or false) && !targetPlatform.isMusl); runtimeDeps = [ targetPackages.stdenv.cc.bintools diff --git a/pkgs/development/compilers/ghc/8.8.4.nix b/pkgs/development/compilers/ghc/8.8.4.nix index bb2267c930de..74260af7d31c 100644 --- a/pkgs/development/compilers/ghc/8.8.4.nix +++ b/pkgs/development/compilers/ghc/8.8.4.nix @@ -131,7 +131,8 @@ let # Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues. # But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856 # see #84670 and #49071 for more background. - useLdGold = targetPlatform.linker == "gold" || (targetPlatform.linker == "bfd" && !targetPlatform.isMusl); + useLdGold = targetPlatform.linker == "gold" || + (targetPlatform.linker == "bfd" && (targetPackages.stdenv.cc.bintools.bintools.hasGold or false) && !targetPlatform.isMusl); runtimeDeps = [ targetPackages.stdenv.cc.bintools diff --git a/pkgs/development/compilers/ghc/9.0.1.nix b/pkgs/development/compilers/ghc/9.0.1.nix index 30a7f7a4f40a..37e03ccd4c9e 100644 --- a/pkgs/development/compilers/ghc/9.0.1.nix +++ b/pkgs/development/compilers/ghc/9.0.1.nix @@ -123,7 +123,8 @@ let # Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues. # But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856 # see #84670 and #49071 for more background. - useLdGold = targetPlatform.linker == "gold" || (targetPlatform.linker == "bfd" && !targetPlatform.isMusl); + useLdGold = targetPlatform.linker == "gold" || + (targetPlatform.linker == "bfd" && (targetPackages.stdenv.cc.bintools.bintools.hasGold or false) && !targetPlatform.isMusl); runtimeDeps = [ targetPackages.stdenv.cc.bintools diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix index 35c0bd76214d..7aaaaeb417b0 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -133,7 +133,8 @@ let # Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues. # But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856 # see #84670 and #49071 for more background. - useLdGold = targetPlatform.linker == "gold" || (targetPlatform.linker == "bfd" && !targetPlatform.isMusl); + useLdGold = targetPlatform.linker == "gold" || + (targetPlatform.linker == "bfd" && (targetPackages.stdenv.cc.bintools.bintools.hasGold or false) && !targetPlatform.isMusl); runtimeDeps = [ targetPackages.stdenv.cc.bintools diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix index d2b5f6e7ea3a..97f7a6dd8d03 100644 --- a/pkgs/development/tools/misc/binutils/default.nix +++ b/pkgs/development/tools/misc/binutils/default.nix @@ -1,16 +1,24 @@ +let + execFormatIsELF = platform: platform.parsed.kernel.execFormat.name == "elf"; +in + { stdenv, lib, buildPackages , fetchFromGitHub, fetchurl, zlib, autoreconfHook, gettext # Enabling all targets increases output size to a multiple. , withAllTargets ? false, libbfd, libopcodes , enableShared ? !stdenv.hostPlatform.isStatic , noSysDirs -, gold ? true +, gold ? execFormatIsELF stdenv.targetPlatform , bison ? null , flex , texinfo , perl }: +# configure silently disables ld.gold if it's unsupported, +# so we need to make sure that intent matches result ourselves. +assert gold -> execFormatIsELF stdenv.targetPlatform; + # Note: this package is used for bootstrapping fetchurl, and thus # cannot use fetchpatch! All mutable patches (generated by GitHub or # cgit) that are needed here should be included directly in Nixpkgs as @@ -168,6 +176,7 @@ stdenv.mkDerivation { passthru = { inherit targetPrefix; + hasGold = gold; isGNU = true; };