diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix index 31c86c785c2df..1b53afce42ed9 100644 --- a/pkgs/development/tools/misc/binutils/default.nix +++ b/pkgs/development/tools/misc/binutils/default.nix @@ -2,8 +2,13 @@ , fetchurl, zlib , buildPlatform, hostPlatform, targetPlatform , noSysDirs, gold ? true, bison ? null + # Which ld implementation to use by default? +, defaultLd ? null }: +assert (builtins.elem defaultLd ["bfd" "gold" null]); +assert defaultLd == "gold" -> gold; + let # Note to whoever is upgrading this: 2.29 is broken. # ('nix-build pkgs/stdenv/linux/make-bootstrap-tools.nix -A test' segfaults on aarch64) @@ -102,7 +107,8 @@ stdenv.mkDerivation rec { "--enable-deterministic-archives" "--disable-werror" "--enable-fix-loongson2f-nop" - ] ++ optionals gold [ "--enable-gold" "--enable-plugins" ]; + ] ++ optionals gold [ "--enable-gold" "--enable-plugins" ] + ++ optional (defaultLd == "gold") "--enable-gold=default"; enableParallelBuilding = true; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 3008f2975eaf3..611c0b6fc5220 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7158,6 +7158,7 @@ with pkgs; binutils-unwrapped = callPackage ../development/tools/misc/binutils { # FHS sys dirs presumably only have stuff for the build platform noSysDirs = (targetPlatform != buildPlatform) || noSysDirs; + defaultLd = config.defaultLd or null; }; binutils-raw = wrapBintoolsWith { libc = if targetPlatform != hostPlatform then libcCross else stdenv.cc.libc; @@ -7167,6 +7168,7 @@ with pkgs; binutils_nogold = lowPrio (binutils-raw.override { bintools = binutils-raw.bintools.override { gold = false; + defaultLd = "bfd"; }; });