gcc-wrapper: Wrap ld.gold

This ensures that gcc's ‘-fuse-ld=gold’ flag works.
This commit is contained in:
Eelco Dolstra 2014-10-10 14:01:38 +02:00
parent 3e0a348728
commit ffbdcbfe29
2 changed files with 15 additions and 13 deletions

View File

@ -143,6 +143,14 @@ stdenv.mkDerivation {
wrap ld ${./ld-wrapper.sh} $ld
if [ -e $binutils/bin/ld.gold ]; then
wrap ld.gold ${./ld-wrapper.sh} $binutils/bin/ld.gold
fi
if [ -e $binutils/bin/ld.bfd ]; then
wrap ld.bfd ${./ld-wrapper.sh} $binutils/bin/ld.bfd
fi
if [ -e $gccPath/gcc ]; then
wrap gcc ${./gcc-wrapper.sh} $gccPath/gcc
ln -s gcc $out/bin/cc

View File

@ -285,19 +285,13 @@ rec {
};
/* Modify a stdenv so that it uses the Gold linker. FIXME: should
use -fuse-ld=gold instead, but then the ld-wrapper won't be
invoked. */
useGoldLinker = stdenv:
let
binutils = stdenv.gcc.binutils;
binutils' = pkgs.runCommand "${binutils.name}-gold" { }
''
mkdir -p $out/bin
ln -s ${binutils}/bin/* $out/bin/
ln -sfn ${binutils}/bin/ld.gold $out/bin/ld
''; # */
in overrideGCC stdenv (stdenv.gcc.override { binutils = binutils'; });
/* Modify a stdenv so that it uses the Gold linker. */
useGoldLinker = stdenv: stdenv //
{ mkDerivation = args: stdenv.mkDerivation (args // {
dontStrip = true;
NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_COMPILE or "") + " -fuse-ld=gold";
});
};
dropCxx = drv: drv.override {
stdenv = if pkgs.stdenv.isDarwin