From 7703f04b751084aecca9eeda4517ce7c053a4000 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 4 Feb 2014 16:58:12 +0100 Subject: [PATCH] =?UTF-8?q?Add=20a=20stdenv=20adapter=20=E2=80=98useGoldLi?= =?UTF-8?q?nker=E2=80=99=20to=20force=20use=20of=20Gold?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/build-support/clang-wrapper/default.nix | 10 +++---- pkgs/build-support/gcc-wrapper/default.nix | 8 +++--- pkgs/stdenv/adapters.nix | 30 ++++++++++++++------ pkgs/stdenv/linux/default.nix | 6 ++-- pkgs/top-level/all-packages.nix | 6 ++-- 5 files changed, 37 insertions(+), 23 deletions(-) diff --git a/pkgs/build-support/clang-wrapper/default.nix b/pkgs/build-support/clang-wrapper/default.nix index 05b8194697e1..49ee34e99263 100644 --- a/pkgs/build-support/clang-wrapper/default.nix +++ b/pkgs/build-support/clang-wrapper/default.nix @@ -18,21 +18,21 @@ let clangVersion = (builtins.parseDrvName clang.name).version; clangName = (builtins.parseDrvName clang.name).name; - + in stdenv.mkDerivation { name = (if name != "" then name else clangName + "-wrapper") + (if clang != null && clangVersion != "" then "-" + clangVersion else ""); - + builder = ./builder.sh; setupHook = ./setup-hook.sh; clangWrapper = ./clang-wrapper.sh; ldWrapper = ./ld-wrapper.sh; utils = ./utils.sh; addFlags = ./add-flags; - + inherit nativeTools nativeLibc nativePrefix clang clangVersion libcxx; libcxxabi = libcxx.abi or null; @@ -42,7 +42,7 @@ stdenv.mkDerivation { binutils = if nativeTools then null else binutils; # The wrapper scripts use 'cat', so we may need coreutils coreutils = if nativeTools then null else coreutils; - + langC = true; langCC = true; 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 abort "don't know the name of the dynamic linker for this platform"); }; - + meta = let clang_ = if clang != null then clang else {}; in (if clang_ ? meta then removeAttrs clang.meta ["priority"] else {}) // diff --git a/pkgs/build-support/gcc-wrapper/default.nix b/pkgs/build-support/gcc-wrapper/default.nix index 58dde3485ca0..1f521f405850 100644 --- a/pkgs/build-support/gcc-wrapper/default.nix +++ b/pkgs/build-support/gcc-wrapper/default.nix @@ -29,7 +29,7 @@ stdenv.mkDerivation { name = (if name != "" then name else gccName + "-wrapper") + (if gcc != null && gccVersion != "" then "-" + gccVersion else ""); - + builder = ./builder.sh; setupHook = ./setup-hook.sh; gccWrapper = ./gcc-wrapper.sh; @@ -39,13 +39,13 @@ stdenv.mkDerivation { ldSolarisWrapper = ./ld-solaris-wrapper.sh; utils = ./utils.sh; addFlags = ./add-flags; - + inherit nativeTools nativeLibc nativePrefix gcc; libc = if nativeLibc then null else libc; binutils = if nativeTools then null else binutils; # The wrapper scripts use 'cat', so we may need coreutils coreutils = if nativeTools then null else coreutils; - + langC = if nativeTools then true else gcc.langC; langCC = if nativeTools then true else gcc.langCC; 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 abort "don't know the name of the dynamic linker for this platform"); }; - + meta = let gcc_ = if gcc != null then gcc else {}; in (if gcc_ ? meta then removeAttrs gcc.meta ["priority"] else {}) // diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index 662f3307b463..85063621815c 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -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'; }); + } diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index 408c362bedbc..3d424c904ba4 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -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; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 243c021d16d5..785e22f95e98 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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"}: