3
0
Fork 0
forked from mirrors/nixpkgs

Add a stdenv adapter ‘useGoldLinker’ to force use of Gold

This commit is contained in:
Eelco Dolstra 2014-02-04 16:58:12 +01:00
parent e060d9a2ff
commit 7703f04b75
5 changed files with 37 additions and 23 deletions

View file

@ -2,8 +2,7 @@
a new stdenv with different behaviour, e.g. using a different C
compiler. */
{dietlibc, fetchurl, runCommand}:
pkgs:
rec {
@ -57,13 +56,13 @@ rec {
NIX_GCC = import ../build-support/gcc-wrapper {
inherit stdenv;
libc = dietlibc;
libc = pkgs.dietlibc;
inherit (stdenv.gcc) gcc binutils nativeTools nativePrefix;
nativeLibc = false;
};
});
isDietLibC = true;
} // {inherit fetchurl;};
};
# Return a modified stdenv that uses klibc to create small
@ -80,7 +79,7 @@ rec {
configureFlags =
args.configureFlags or "" + " --disable-shared"; # brrr...
NIX_GCC = runCommand "klibc-wrapper" {} ''
NIX_GCC = pkgs.runCommand "klibc-wrapper" {} ''
mkdir -p $out/bin
ln -s ${klibc}/bin/klcc $out/bin/gcc
ln -s ${klibc}/bin/klcc $out/bin/cc
@ -90,7 +89,7 @@ rec {
});
isKlibc = true;
isStatic = true;
} // {inherit fetchurl;};
};
# Return a modified stdenv that tries to build statically linked
@ -103,7 +102,7 @@ rec {
+ " --disable-shared"; # brrr...
});
isStatic = true;
} // {inherit fetchurl;};
};
# Return a modified stdenv that builds static libraries instead of
@ -115,7 +114,7 @@ rec {
toString args.configureFlags or ""
+ " --enable-static --disable-shared";
});
} // {inherit fetchurl;};
};
# Return a modified stdenv that adds a cross compiler to the
@ -277,7 +276,7 @@ rec {
*/
replaceMaintainersField = stdenv: pkgs: maintainers: stdenv //
{ mkDerivation = args:
pkgs.lib.recursiveUpdate
stdenv.lib.recursiveUpdate
(stdenv.mkDerivation args)
{ meta.maintainers = maintainers; };
};
@ -354,4 +353,17 @@ rec {
});
};
/* Modify a stdenv so that it used the Gold linker. */
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'; });
}

View file

@ -11,6 +11,8 @@
rec {
lib = import ../../../lib;
bootstrapFiles =
if system == "i686-linux" then import ./bootstrap/i686
else if system == "x86_64-linux" then import ./bootstrap/x86_64
@ -134,9 +136,9 @@ rec {
# A helper function to call gcc-wrapper.
wrapGCC =
{gcc ? bootstrapTools, libc, binutils, coreutils, shell ? "", name ? "bootstrap-gcc-wrapper"}:
{ gcc ? bootstrapTools, libc, binutils, coreutils, shell ? "", name ? "bootstrap-gcc-wrapper" }:
import ../../build-support/gcc-wrapper {
lib.makeOverridable (import ../../build-support/gcc-wrapper) {
nativeTools = false;
nativeLibc = false;
inherit gcc binutils coreutils libc shell name;

View file

@ -97,7 +97,7 @@ let
(import ../build-support/trivial-builders.nix { inherit (pkgs) stdenv; inherit (pkgs.xorg) lndir; });
stdenvAdapters =
import ../stdenv/adapters.nix { inherit (pkgs) dietlibc fetchurl runCommand; };
import ../stdenv/adapters.nix pkgs;
# Allow packages to be overriden globally via the `packageOverrides'
@ -3060,9 +3060,9 @@ let
inherit stdenv coreutils zlib;
};
wrapClang = wrapClangWith (import ../build-support/clang-wrapper) glibc;
wrapClang = wrapClangWith (makeOverridable (import ../build-support/clang-wrapper)) glibc;
wrapGCC = wrapGCCWith (import ../build-support/gcc-wrapper) glibc;
wrapGCC = wrapGCCWith (makeOverridable (import ../build-support/gcc-wrapper)) glibc;
wrapGCCCross =
{gcc, libc, binutils, cross, shell ? "", name ? "gcc-cross-wrapper"}: