binutils-unwrapped: expose if built with ld.gold

ld.gold is “A new, faster, ELF only linker”. Thus we only should pass
the configure flag --with-gold if our target platform will actually
support gold (in which case binutil's configure script silently
disables it).

With this change, not only will configureFlags represent the actual
configuration more closely, but we can also expose if the binutils
derivation contains ld.gold via a passthru attr. Specifically this
means that:

    nix-repl> pkgsCross.mingwW64.stdenv.cc.bintools.bintools.hasGold
    false

The intended way to use this is to check
`stdenv.cc.bintools.bintools or false` which returns accurate results
regardless of the actual linker derivation.

TODO: maybe also add hasGold to binutils wrapper as it also symlinks
ld.gold in?
This commit is contained in:
sternenseemann 2021-08-03 13:25:59 +02:00
parent b6d8e46a57
commit 4c75874560

View file

@ -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
@ -163,6 +171,7 @@ stdenv.mkDerivation {
passthru = {
inherit targetPrefix;
hasGold = gold;
isGNU = true;
};