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

@ -18,21 +18,21 @@ let
clangVersion = (builtins.parseDrvName clang.name).version; clangVersion = (builtins.parseDrvName clang.name).version;
clangName = (builtins.parseDrvName clang.name).name; clangName = (builtins.parseDrvName clang.name).name;
in in
stdenv.mkDerivation { stdenv.mkDerivation {
name = name =
(if name != "" then name else clangName + "-wrapper") + (if name != "" then name else clangName + "-wrapper") +
(if clang != null && clangVersion != "" then "-" + clangVersion else ""); (if clang != null && clangVersion != "" then "-" + clangVersion else "");
builder = ./builder.sh; builder = ./builder.sh;
setupHook = ./setup-hook.sh; setupHook = ./setup-hook.sh;
clangWrapper = ./clang-wrapper.sh; clangWrapper = ./clang-wrapper.sh;
ldWrapper = ./ld-wrapper.sh; ldWrapper = ./ld-wrapper.sh;
utils = ./utils.sh; utils = ./utils.sh;
addFlags = ./add-flags; addFlags = ./add-flags;
inherit nativeTools nativeLibc nativePrefix clang clangVersion libcxx; inherit nativeTools nativeLibc nativePrefix clang clangVersion libcxx;
libcxxabi = libcxx.abi or null; libcxxabi = libcxx.abi or null;
@ -42,7 +42,7 @@ stdenv.mkDerivation {
binutils = if nativeTools then null else binutils; binutils = if nativeTools then null else binutils;
# The wrapper scripts use 'cat', so we may need coreutils # The wrapper scripts use 'cat', so we may need coreutils
coreutils = if nativeTools then null else coreutils; coreutils = if nativeTools then null else coreutils;
langC = true; langC = true;
langCC = true; langCC = true;
shell = if shell == "" then stdenv.shell else shell = if shell == "" then stdenv.shell else
@ -65,7 +65,7 @@ stdenv.mkDerivation {
if stdenv.lib.hasSuffix "pc-gnu" stdenv.cross.config then "ld.so.1" else if stdenv.lib.hasSuffix "pc-gnu" stdenv.cross.config then "ld.so.1" else
abort "don't know the name of the dynamic linker for this platform"); abort "don't know the name of the dynamic linker for this platform");
}; };
meta = meta =
let clang_ = if clang != null then clang else {}; in let clang_ = if clang != null then clang else {}; in
(if clang_ ? meta then removeAttrs clang.meta ["priority"] else {}) // (if clang_ ? meta then removeAttrs clang.meta ["priority"] else {}) //

View File

@ -29,7 +29,7 @@ stdenv.mkDerivation {
name = name =
(if name != "" then name else gccName + "-wrapper") + (if name != "" then name else gccName + "-wrapper") +
(if gcc != null && gccVersion != "" then "-" + gccVersion else ""); (if gcc != null && gccVersion != "" then "-" + gccVersion else "");
builder = ./builder.sh; builder = ./builder.sh;
setupHook = ./setup-hook.sh; setupHook = ./setup-hook.sh;
gccWrapper = ./gcc-wrapper.sh; gccWrapper = ./gcc-wrapper.sh;
@ -39,13 +39,13 @@ stdenv.mkDerivation {
ldSolarisWrapper = ./ld-solaris-wrapper.sh; ldSolarisWrapper = ./ld-solaris-wrapper.sh;
utils = ./utils.sh; utils = ./utils.sh;
addFlags = ./add-flags; addFlags = ./add-flags;
inherit nativeTools nativeLibc nativePrefix gcc; inherit nativeTools nativeLibc nativePrefix gcc;
libc = if nativeLibc then null else libc; libc = if nativeLibc then null else libc;
binutils = if nativeTools then null else binutils; binutils = if nativeTools then null else binutils;
# The wrapper scripts use 'cat', so we may need coreutils # The wrapper scripts use 'cat', so we may need coreutils
coreutils = if nativeTools then null else coreutils; coreutils = if nativeTools then null else coreutils;
langC = if nativeTools then true else gcc.langC; langC = if nativeTools then true else gcc.langC;
langCC = if nativeTools then true else gcc.langCC; langCC = if nativeTools then true else gcc.langCC;
langFortran = if nativeTools then false else gcc ? langFortran; langFortran = if nativeTools then false else gcc ? langFortran;
@ -72,7 +72,7 @@ stdenv.mkDerivation {
if stdenv.lib.hasSuffix "pc-gnu" stdenv.cross.config then "ld.so.1" else if stdenv.lib.hasSuffix "pc-gnu" stdenv.cross.config then "ld.so.1" else
abort "don't know the name of the dynamic linker for this platform"); abort "don't know the name of the dynamic linker for this platform");
}; };
meta = meta =
let gcc_ = if gcc != null then gcc else {}; in let gcc_ = if gcc != null then gcc else {}; in
(if gcc_ ? meta then removeAttrs gcc.meta ["priority"] else {}) // (if gcc_ ? meta then removeAttrs gcc.meta ["priority"] else {}) //

View File

@ -2,8 +2,7 @@
a new stdenv with different behaviour, e.g. using a different C a new stdenv with different behaviour, e.g. using a different C
compiler. */ compiler. */
{dietlibc, fetchurl, runCommand}: pkgs:
rec { rec {
@ -57,13 +56,13 @@ rec {
NIX_GCC = import ../build-support/gcc-wrapper { NIX_GCC = import ../build-support/gcc-wrapper {
inherit stdenv; inherit stdenv;
libc = dietlibc; libc = pkgs.dietlibc;
inherit (stdenv.gcc) gcc binutils nativeTools nativePrefix; inherit (stdenv.gcc) gcc binutils nativeTools nativePrefix;
nativeLibc = false; nativeLibc = false;
}; };
}); });
isDietLibC = true; isDietLibC = true;
} // {inherit fetchurl;}; };
# Return a modified stdenv that uses klibc to create small # Return a modified stdenv that uses klibc to create small
@ -80,7 +79,7 @@ rec {
configureFlags = configureFlags =
args.configureFlags or "" + " --disable-shared"; # brrr... args.configureFlags or "" + " --disable-shared"; # brrr...
NIX_GCC = runCommand "klibc-wrapper" {} '' NIX_GCC = pkgs.runCommand "klibc-wrapper" {} ''
mkdir -p $out/bin mkdir -p $out/bin
ln -s ${klibc}/bin/klcc $out/bin/gcc ln -s ${klibc}/bin/klcc $out/bin/gcc
ln -s ${klibc}/bin/klcc $out/bin/cc ln -s ${klibc}/bin/klcc $out/bin/cc
@ -90,7 +89,7 @@ rec {
}); });
isKlibc = true; isKlibc = true;
isStatic = true; isStatic = true;
} // {inherit fetchurl;}; };
# Return a modified stdenv that tries to build statically linked # Return a modified stdenv that tries to build statically linked
@ -103,7 +102,7 @@ rec {
+ " --disable-shared"; # brrr... + " --disable-shared"; # brrr...
}); });
isStatic = true; isStatic = true;
} // {inherit fetchurl;}; };
# Return a modified stdenv that builds static libraries instead of # Return a modified stdenv that builds static libraries instead of
@ -115,7 +114,7 @@ rec {
toString args.configureFlags or "" toString args.configureFlags or ""
+ " --enable-static --disable-shared"; + " --enable-static --disable-shared";
}); });
} // {inherit fetchurl;}; };
# Return a modified stdenv that adds a cross compiler to the # Return a modified stdenv that adds a cross compiler to the
@ -277,7 +276,7 @@ rec {
*/ */
replaceMaintainersField = stdenv: pkgs: maintainers: stdenv // replaceMaintainersField = stdenv: pkgs: maintainers: stdenv //
{ mkDerivation = args: { mkDerivation = args:
pkgs.lib.recursiveUpdate stdenv.lib.recursiveUpdate
(stdenv.mkDerivation args) (stdenv.mkDerivation args)
{ meta.maintainers = maintainers; }; { 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 { rec {
lib = import ../../../lib;
bootstrapFiles = bootstrapFiles =
if system == "i686-linux" then import ./bootstrap/i686 if system == "i686-linux" then import ./bootstrap/i686
else if system == "x86_64-linux" then import ./bootstrap/x86_64 else if system == "x86_64-linux" then import ./bootstrap/x86_64
@ -134,9 +136,9 @@ rec {
# A helper function to call gcc-wrapper. # A helper function to call gcc-wrapper.
wrapGCC = 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; nativeTools = false;
nativeLibc = false; nativeLibc = false;
inherit gcc binutils coreutils libc shell name; 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; }); (import ../build-support/trivial-builders.nix { inherit (pkgs) stdenv; inherit (pkgs.xorg) lndir; });
stdenvAdapters = stdenvAdapters =
import ../stdenv/adapters.nix { inherit (pkgs) dietlibc fetchurl runCommand; }; import ../stdenv/adapters.nix pkgs;
# Allow packages to be overriden globally via the `packageOverrides' # Allow packages to be overriden globally via the `packageOverrides'
@ -3060,9 +3060,9 @@ let
inherit stdenv coreutils zlib; 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 = wrapGCCCross =
{gcc, libc, binutils, cross, shell ? "", name ? "gcc-cross-wrapper"}: {gcc, libc, binutils, cross, shell ? "", name ? "gcc-cross-wrapper"}: