about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn Ericson <Ericson2314@yahoo.com>2017-11-08 14:20:48 -0500
committerGitHub <noreply@github.com>2017-11-08 14:20:48 -0500
commit01018567653aaa58bedf6f7ca6a02c6d50910075 (patch)
tree89dcb477933b3f439ef9f43e22e01a2ed360cfb7
parent999bcd098da0fc6b16ae769dde95573e6b110844 (diff)
parent4d4f94cde4d3806ca063ebf7e6ba448b0feae355 (diff)
downloadnixlib-01018567653aaa58bedf6f7ca6a02c6d50910075.tar
nixlib-01018567653aaa58bedf6f7ca6a02c6d50910075.tar.gz
nixlib-01018567653aaa58bedf6f7ca6a02c6d50910075.tar.bz2
nixlib-01018567653aaa58bedf6f7ca6a02c6d50910075.tar.lz
nixlib-01018567653aaa58bedf6f7ca6a02c6d50910075.tar.xz
nixlib-01018567653aaa58bedf6f7ca6a02c6d50910075.tar.zst
nixlib-01018567653aaa58bedf6f7ca6a02c6d50910075.zip
Merge pull request #30549 from obsidiansystems/bintools
treewide: Introduce stdenv.cc.bintools
-rw-r--r--doc/cross-compilation.xml2
-rw-r--r--pkgs/applications/editors/jucipp/default.nix4
-rw-r--r--pkgs/build-support/cc-wrapper/default.nix5
-rw-r--r--pkgs/development/compilers/gcc/4.5/default.nix8
-rw-r--r--pkgs/development/compilers/gcc/4.8/default.nix8
-rw-r--r--pkgs/development/compilers/gcc/4.9/default.nix8
-rw-r--r--pkgs/development/compilers/gcc/5/default.nix13
-rw-r--r--pkgs/development/compilers/gcc/6/default.nix13
-rw-r--r--pkgs/development/compilers/gcc/7/default.nix13
-rw-r--r--pkgs/development/compilers/gcc/snapshot/default.nix13
-rw-r--r--pkgs/development/compilers/ghc/7.10.2.nix4
-rw-r--r--pkgs/development/compilers/ghc/7.10.3.nix4
-rw-r--r--pkgs/development/compilers/ghc/7.6.3.nix2
-rw-r--r--pkgs/development/compilers/ghc/8.0.2.nix4
-rw-r--r--pkgs/development/compilers/ghc/8.2.1.nix16
-rw-r--r--pkgs/development/compilers/ghc/head.nix4
-rw-r--r--pkgs/development/compilers/halvm/2.4.0.nix8
-rw-r--r--pkgs/development/compilers/rust/rustc.nix7
-rw-r--r--pkgs/development/compilers/swift/default.nix4
-rw-r--r--pkgs/development/tools/profiling/systemtap/default.nix6
-rw-r--r--pkgs/games/brogue/default.nix2
-rw-r--r--pkgs/games/steam/runtime.nix4
-rw-r--r--pkgs/servers/asterisk/default.nix4
-rw-r--r--pkgs/stdenv/booter.nix25
-rw-r--r--pkgs/tools/networking/htpdate/default.nix2
-rw-r--r--pkgs/tools/networking/p2p/gtk-gnutella/default.nix4
-rw-r--r--pkgs/top-level/all-packages.nix6
-rw-r--r--pkgs/top-level/splice.nix2
-rw-r--r--pkgs/top-level/stage.nix6
29 files changed, 109 insertions, 92 deletions
diff --git a/doc/cross-compilation.xml b/doc/cross-compilation.xml
index 77d020afa2df..9e9dd41c2881 100644
--- a/doc/cross-compilation.xml
+++ b/doc/cross-compilation.xml
@@ -184,7 +184,7 @@
       For now, feel free to use either method.
     </para>
     <note><para>
-      There is also a "backlink" <varname>__targetPackages</varname>, yielding a package set whose <varname>buildPackages</varname> is the current package set.
+      There is also a "backlink" <varname>targetPackages</varname>, yielding a package set whose <varname>buildPackages</varname> is the current package set.
       This is a hack, though, to accommodate compilers with lousy build systems.
       Please do not use this unless you are absolutely sure you are packaging such a compiler and there is no other way.
     </para></note>
diff --git a/pkgs/applications/editors/jucipp/default.nix b/pkgs/applications/editors/jucipp/default.nix
index ae4f1e6ad525..3d623d3f3bda 100644
--- a/pkgs/applications/editors/jucipp/default.nix
+++ b/pkgs/applications/editors/jucipp/default.nix
@@ -1,7 +1,7 @@
 { config, stdenv, fetchgit, makeWrapper, gnome3, at_spi2_core, libcxx,
   boost, epoxy, cmake, aspell, llvmPackages, libgit2, pkgconfig, pcre,
   libXdmcp, libxkbcommon, libpthreadstubs, wrapGAppsHook, aspellDicts,
-  coreutils, glibc, dbus_libs, openssl, libxml2, gnumake, binutils, ctags }:
+  coreutils, glibc, dbus_libs, openssl, libxml2, gnumake, ctags }:
 
 with stdenv.lib;
 
@@ -65,7 +65,7 @@ stdenv.mkDerivation rec {
   postInstall = ''
     mv $out/bin/juci $out/bin/.juci
     makeWrapper "$out/bin/.juci" "$out/bin/juci" \
-      --set PATH "${stdenv.lib.makeBinPath [ ctags coreutils llvmPackages.clang.cc cmake gnumake binutils llvmPackages.clang ]}" \
+      --set PATH "${stdenv.lib.makeBinPath [ ctags coreutils llvmPackages.clang.cc cmake gnumake llvmPackages.clang.bintools llvmPackages.clang ]}" \
       --set NO_AT_BRIDGE 1 \
       --set ASPELL_CONF "dict-dir ${aspellDicts.en}/lib/aspell"
   '';
diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix
index a12c835dd9bf..8d8b8a42fe9f 100644
--- a/pkgs/build-support/cc-wrapper/default.nix
+++ b/pkgs/build-support/cc-wrapper/default.nix
@@ -97,6 +97,11 @@ stdenv.mkDerivation {
   outputs = [ "out" "man" ];
 
   passthru = {
+    # "cc" is the generic name for a C compiler, but there is no one for package
+    # providing the linker and related tools. The two we use now are GNU
+    # Binutils, and Apple's "cctools"; "binutils" as an attempt to find an
+    # unused middle-ground name that evokes both.
+    bintools = binutils_bin;
     inherit libc nativeTools nativeLibc nativePrefix isGNU isClang default_cxx_stdlib_compile
             prefix;
 
diff --git a/pkgs/development/compilers/gcc/4.5/default.nix b/pkgs/development/compilers/gcc/4.5/default.nix
index 41d31888bde1..e7b188ad71b8 100644
--- a/pkgs/development/compilers/gcc/4.5/default.nix
+++ b/pkgs/development/compilers/gcc/4.5/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, noSysDirs
+{ stdenv, targetPackages, fetchurl, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
 , langJava ? false
 , langAda ? false
@@ -77,8 +77,8 @@ let version = "4.5.4";
       withCpu +
       withAbi +
       # Ensure that -print-prog-name is able to find the correct programs.
-      " --with-as=${binutils}/bin/${targetPlatform.config}-as" +
-      " --with-ld=${binutils}/bin/${targetPlatform.config}-ld" +
+      " --with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" +
+      " --with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" +
       (if crossMingw && crossStageStatic then
         " --with-headers=${libcCross}/include" +
         " --with-gcc" +
@@ -229,7 +229,7 @@ stdenv.mkDerivation ({
     ++ (optional langJava boehmgc)
     ++ (optionals langJava [zip unzip])
     ++ (optionals javaAwtGtk ([gtk2 pkgconfig libart_lgpl] ++ xlibs))
-    ++ (optionals (targetPlatform != hostPlatform) [binutils])
+    ++ (optionals (targetPlatform != hostPlatform) [targetPackages.stdenv.cc.bintools])
     ++ (optionals langAda [gnatboot])
     ++ (optionals langVhdl [gnat])
     ;
diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix
index 3031df56150b..ab91528049c4 100644
--- a/pkgs/development/compilers/gcc/4.8/default.nix
+++ b/pkgs/development/compilers/gcc/4.8/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, noSysDirs
+{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
 , langObjC ? targetPlatform.isDarwin
 , langObjCpp ? targetPlatform.isDarwin
@@ -153,8 +153,8 @@ let version = "4.8.5";
         withFloat +
         withMode +
         # Ensure that -print-prog-name is able to find the correct programs.
-        " --with-as=${binutils}/bin/${targetPlatform.config}-as" +
-        " --with-ld=${binutils}/bin/${targetPlatform.config}-ld" +
+        " --with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" +
+        " --with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" +
         (if crossMingw && crossStageStatic then
           " --with-headers=${libcCross}/include" +
           " --with-gcc" +
@@ -303,7 +303,7 @@ stdenv.mkDerivation ({
     ++ (optional (zlib != null) zlib)
     ++ (optionals langJava [ boehmgc zip unzip ])
     ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
-    ++ (optionals (targetPlatform != hostPlatform) [binutils])
+    ++ (optionals (targetPlatform != hostPlatform) [targetPackages.stdenv.cc.bintools])
     ++ (optionals langAda [gnatboot])
     ++ (optionals langVhdl [gnat])
 
diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix
index 4675787912e8..794d809fa727 100644
--- a/pkgs/development/compilers/gcc/4.9/default.nix
+++ b/pkgs/development/compilers/gcc/4.9/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, noSysDirs
+{ stdenv, targetPackages, fetchurl, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
 , langObjC ? targetPlatform.isDarwin
 , langObjCpp ? targetPlatform.isDarwin
@@ -144,8 +144,8 @@ let version = "4.9.4";
         withFloat +
         withMode +
         # Ensure that -print-prog-name is able to find the correct programs.
-        " --with-as=${binutils}/bin/${targetPlatform.config}-as" +
-        " --with-ld=${binutils}/bin/${targetPlatform.config}-ld" +
+        " --with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" +
+        " --with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" +
         (if crossMingw && crossStageStatic then
           " --with-headers=${libcCross}/include" +
           " --with-gcc" +
@@ -296,7 +296,7 @@ stdenv.mkDerivation ({
     ++ (optional (zlib != null) zlib)
     ++ (optionals langJava [ boehmgc zip unzip ])
     ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
-    ++ (optionals (targetPlatform != hostPlatform) [binutils])
+    ++ (optionals (targetPlatform != hostPlatform) [targetPackages.stdenv.cc.bintools])
     ++ (optionals langAda [gnatboot])
     ++ (optionals langVhdl [gnat])
 
diff --git a/pkgs/development/compilers/gcc/5/default.nix b/pkgs/development/compilers/gcc/5/default.nix
index 346ea928b76f..345e2baf6718 100644
--- a/pkgs/development/compilers/gcc/5/default.nix
+++ b/pkgs/development/compilers/gcc/5/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, noSysDirs
+{ stdenv, targetPackages, fetchurl, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
 , langObjC ? targetPlatform.isDarwin
 , langObjCpp ? targetPlatform.isDarwin
@@ -31,7 +31,6 @@
 , libpthread ? null, libpthreadCross ? null  # required for GNU/Hurd
 , stripped ? true
 , gnused ? null
-, binutils ? null
 , cloog # unused; just for compat with gcc4, as we override the parameter on some places
 , darwin ? null
 , buildPlatform, hostPlatform, targetPlatform
@@ -51,7 +50,7 @@ assert libelf != null -> zlib != null;
 assert hostPlatform.isDarwin -> gnused != null;
 
 # Need c++filt on darwin
-assert hostPlatform.isDarwin -> binutils != null;
+assert hostPlatform.isDarwin -> targetPackages.stdenv.cc.bintools or null != null;
 
 # The go frontend is written in c++
 assert langGo -> langCC;
@@ -149,8 +148,8 @@ let version = "5.5.0";
         withFloat +
         withMode +
         # Ensure that -print-prog-name is able to find the correct programs.
-        " --with-as=${binutils}/bin/${targetPlatform.config}-as" +
-        " --with-ld=${binutils}/bin/${targetPlatform.config}-ld" +
+        " --with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" +
+        " --with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" +
         (if crossMingw && crossStageStatic then
           " --with-headers=${libcCross}/include" +
           " --with-gcc" +
@@ -312,7 +311,7 @@ stdenv.mkDerivation ({
     ++ (optional (zlib != null) zlib)
     ++ (optionals langJava [ boehmgc zip unzip ])
     ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
-    ++ (optionals (targetPlatform != hostPlatform) [binutils])
+    ++ (optionals (targetPlatform != hostPlatform) [targetPackages.stdenv.cc.bintools])
     ++ (optionals (buildPlatform != hostPlatform) [buildPackages.stdenv.cc])
     ++ (optionals langAda [gnatboot])
     ++ (optionals langVhdl [gnat])
@@ -320,7 +319,7 @@ stdenv.mkDerivation ({
     # The builder relies on GNU sed (for instance, Darwin's `sed' fails with
     # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it.
     ++ (optional hostPlatform.isDarwin gnused)
-    ++ (optional hostPlatform.isDarwin binutils)
+    ++ (optional hostPlatform.isDarwin targetPackages.stdenv.cc.bintools)
     ;
 
   NIX_LDFLAGS = stdenv.lib.optionalString  hostPlatform.isSunOS "-lm -ldl";
diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix
index 7d019c7fe848..3ae478c4ecf6 100644
--- a/pkgs/development/compilers/gcc/6/default.nix
+++ b/pkgs/development/compilers/gcc/6/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, noSysDirs
+{ stdenv, targetPackages, fetchurl, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
 , langObjC ? targetPlatform.isDarwin
 , langObjCpp ? targetPlatform.isDarwin
@@ -31,7 +31,6 @@
 , libpthread ? null, libpthreadCross ? null  # required for GNU/Hurd
 , stripped ? true
 , gnused ? null
-, binutils ? null
 , cloog # unused; just for compat with gcc4, as we override the parameter on some places
 , darwin ? null
 , buildPlatform, hostPlatform, targetPlatform
@@ -50,7 +49,7 @@ assert libelf != null -> zlib != null;
 assert hostPlatform.isDarwin -> gnused != null;
 
 # Need c++filt on darwin
-assert hostPlatform.isDarwin -> binutils != null;
+assert hostPlatform.isDarwin -> targetPackages.stdenv.cc.bintools or null != null;
 
 # The go frontend is written in c++
 assert langGo -> langCC;
@@ -145,8 +144,8 @@ let version = "6.4.0";
         withFloat +
         withMode +
         # Ensure that -print-prog-name is able to find the correct programs.
-        " --with-as=${binutils}/bin/${targetPlatform.config}-as" +
-        " --with-ld=${binutils}/bin/${targetPlatform.config}-ld" +
+        " --with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" +
+        " --with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" +
         (if crossMingw && crossStageStatic then
           " --with-headers=${libcCross}/include" +
           " --with-gcc" +
@@ -309,14 +308,14 @@ stdenv.mkDerivation ({
     ++ (optional (zlib != null) zlib)
     ++ (optionals langJava [ boehmgc zip unzip ])
     ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
-    ++ (optionals (targetPlatform != hostPlatform) [binutils])
+    ++ (optionals (targetPlatform != hostPlatform) [targetPackages.stdenv.cc.bintools])
     ++ (optionals langAda [gnatboot])
     ++ (optionals langVhdl [gnat])
 
     # The builder relies on GNU sed (for instance, Darwin's `sed' fails with
     # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it.
     ++ (optional hostPlatform.isDarwin gnused)
-    ++ (optional hostPlatform.isDarwin binutils)
+    ++ (optional hostPlatform.isDarwin targetPackages.stdenv.cc.bintools)
     ;
 
   NIX_LDFLAGS = stdenv.lib.optionalString  hostPlatform.isSunOS "-lm -ldl";
diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix
index 064f2ab00d47..3a7c0eb64437 100644
--- a/pkgs/development/compilers/gcc/7/default.nix
+++ b/pkgs/development/compilers/gcc/7/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, noSysDirs
+{ stdenv, targetPackages, fetchurl, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
 , langObjC ? targetPlatform.isDarwin
 , langObjCpp ? targetPlatform.isDarwin
@@ -31,7 +31,6 @@
 , libpthread ? null, libpthreadCross ? null  # required for GNU/Hurd
 , stripped ? true
 , gnused ? null
-, binutils ? null
 , cloog # unused; just for compat with gcc4, as we override the parameter on some places
 , darwin ? null
 , flex ? null
@@ -51,7 +50,7 @@ assert libelf != null -> zlib != null;
 assert hostPlatform.isDarwin -> gnused != null;
 
 # Need c++filt on darwin
-assert hostPlatform.isDarwin -> binutils != null;
+assert hostPlatform.isDarwin -> targetPackages.stdenv.cc.bintools or null != null;
 
 # The go frontend is written in c++
 assert langGo -> langCC;
@@ -144,8 +143,8 @@ let version = "7.2.0";
         withFloat +
         withMode +
         # Ensure that -print-prog-name is able to find the correct programs.
-        " --with-as=${binutils}/bin/${targetPlatform.config}-as" +
-        " --with-ld=${binutils}/bin/${targetPlatform.config}-ld" +
+        " --with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" +
+        " --with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" +
         (if crossMingw && crossStageStatic then
           " --with-headers=${libcCross}/include" +
           " --with-gcc" +
@@ -308,14 +307,14 @@ stdenv.mkDerivation ({
     ++ (optional (zlib != null) zlib)
     ++ (optionals langJava [ boehmgc zip unzip ])
     ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
-    ++ (optionals (targetPlatform != hostPlatform) [binutils])
+    ++ (optionals (targetPlatform != hostPlatform) [targetPackages.stdenv.cc.bintools])
     ++ (optionals langAda [gnatboot])
     ++ (optionals langVhdl [gnat])
 
     # The builder relies on GNU sed (for instance, Darwin's `sed' fails with
     # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it.
     ++ (optional hostPlatform.isDarwin gnused)
-    ++ (optional hostPlatform.isDarwin binutils)
+    ++ (optional hostPlatform.isDarwin targetPackages.stdenv.cc.bintools)
     ;
 
   NIX_LDFLAGS = stdenv.lib.optionalString  hostPlatform.isSunOS "-lm -ldl";
diff --git a/pkgs/development/compilers/gcc/snapshot/default.nix b/pkgs/development/compilers/gcc/snapshot/default.nix
index 696417a49566..e235be639c6e 100644
--- a/pkgs/development/compilers/gcc/snapshot/default.nix
+++ b/pkgs/development/compilers/gcc/snapshot/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, noSysDirs
+{ stdenv, targetPackages, fetchurl, noSysDirs
 , langC ? true, langCC ? true, langFortran ? false
 , langObjC ? targetPlatform.isDarwin
 , langObjCpp ? targetPlatform.isDarwin
@@ -31,7 +31,6 @@
 , libpthread ? null, libpthreadCross ? null  # required for GNU/Hurd
 , stripped ? true
 , gnused ? null
-, binutils ? null
 , cloog # unused; just for compat with gcc4, as we override the parameter on some places
 , darwin ? null
 , flex ? null
@@ -51,7 +50,7 @@ assert libelf != null -> zlib != null;
 assert hostPlatform.isDarwin -> gnused != null;
 
 # Need c++filt on darwin
-assert hostPlatform.isDarwin -> binutils != null;
+assert hostPlatform.isDarwin -> targetPackages.stdenv.cc.bintools or null != null;
 
 # The go frontend is written in c++
 assert langGo -> langCC;
@@ -144,8 +143,8 @@ let version = "7-20170409";
         withFloat +
         withMode +
         # Ensure that -print-prog-name is able to find the correct programs.
-        " --with-as=${binutils}/bin/${targetPlatform.config}-as" +
-        " --with-ld=${binutils}/bin/${targetPlatform.config}-ld" +
+        " --with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" +
+        " --with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" +
         (if crossMingw && crossStageStatic then
           " --with-headers=${libcCross}/include" +
           " --with-gcc" +
@@ -295,14 +294,14 @@ stdenv.mkDerivation ({
     ++ (optional (zlib != null) zlib)
     ++ (optionals langJava [ boehmgc zip unzip ])
     ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs))
-    ++ (optionals (targetPlatform != hostPlatform) [binutils])
+    ++ (optionals (targetPlatform != hostPlatform) [targetPackages.stdenv.cc.bintools])
     ++ (optionals langAda [gnatboot])
     ++ (optionals langVhdl [gnat])
 
     # The builder relies on GNU sed (for instance, Darwin's `sed' fails with
     # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it.
     ++ (optional hostPlatform.isDarwin gnused)
-    ++ (optional hostPlatform.isDarwin binutils)
+    ++ (optional hostPlatform.isDarwin targetPackages.stdenv.cc.bintools)
     ;
 
   NIX_LDFLAGS = stdenv.lib.optionalString  hostPlatform.isSunOS "-lm -ldl";
diff --git a/pkgs/development/compilers/ghc/7.10.2.nix b/pkgs/development/compilers/ghc/7.10.2.nix
index 863f904e4e96..51274dd60598 100644
--- a/pkgs/development/compilers/ghc/7.10.2.nix
+++ b/pkgs/development/compilers/ghc/7.10.2.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, bootPkgs, perl, ncurses, libiconv, binutils, coreutils
+{ stdenv, fetchurl, fetchpatch, bootPkgs, perl, ncurses, libiconv, targetPackages, coreutils
 , libxml2, libxslt, docbook_xsl, docbook_xml_dtd_45, docbook_xml_dtd_42, hscolour
 
   # If enabled GHC will be build with the GPL-free but slower integer-simple
@@ -70,7 +70,7 @@ stdenv.mkDerivation rec {
     for i in "$out/bin/"*; do
       test ! -h $i || continue
       egrep --quiet '^#!' <(head -n 1 $i) || continue
-      sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ binutils coreutils ]}"' $i
+      sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
     done
   '';
 
diff --git a/pkgs/development/compilers/ghc/7.10.3.nix b/pkgs/development/compilers/ghc/7.10.3.nix
index eb8f1dddd19b..d573a22e0ae8 100644
--- a/pkgs/development/compilers/ghc/7.10.3.nix
+++ b/pkgs/development/compilers/ghc/7.10.3.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, fetchpatch, bootPkgs, perl, ncurses, libiconv, binutils, coreutils
+{ stdenv, fetchurl, fetchpatch, bootPkgs, perl, ncurses, libiconv, targetPackages, coreutils
 , libxml2, libxslt, docbook_xsl, docbook_xml_dtd_45, docbook_xml_dtd_42, hscolour
 
   # If enabled GHC will be build with the GPL-free but slower integer-simple
@@ -68,7 +68,7 @@ stdenv.mkDerivation rec {
     for i in "$out/bin/"*; do
       test ! -h $i || continue
       egrep --quiet '^#!' <(head -n 1 $i) || continue
-      sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ binutils coreutils ]}"' $i
+      sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
     done
   '';
 
diff --git a/pkgs/development/compilers/ghc/7.6.3.nix b/pkgs/development/compilers/ghc/7.6.3.nix
index 5f951936046f..fde4ca2aa37d 100644
--- a/pkgs/development/compilers/ghc/7.6.3.nix
+++ b/pkgs/development/compilers/ghc/7.6.3.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, ghc, perl, ncurses, binutils, libiconv
+{ stdenv, fetchurl, ghc, perl, ncurses, libiconv
 
   # If enabled GHC will be build with the GPL-free but slower integer-simple
   # library instead of the faster but GPLed integer-gmp library.
diff --git a/pkgs/development/compilers/ghc/8.0.2.nix b/pkgs/development/compilers/ghc/8.0.2.nix
index e50a8df7352d..d475e3438b4b 100644
--- a/pkgs/development/compilers/ghc/8.0.2.nix
+++ b/pkgs/development/compilers/ghc/8.0.2.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchurl, fetchpatch, bootPkgs, perl, ncurses, libiconv, binutils, coreutils
+{ stdenv, lib, fetchurl, fetchpatch, bootPkgs, perl, ncurses, libiconv, targetPackages, coreutils
 , hscolour, patchutils, sphinx
 
   # If enabled GHC will be build with the GPL-free but slower integer-simple
@@ -65,7 +65,7 @@ stdenv.mkDerivation rec {
     for i in "$out/bin/"*; do
       test ! -h $i || continue
       egrep --quiet '^#!' <(head -n 1 $i) || continue
-      sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ binutils coreutils ]}"' $i
+      sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
     done
   '';
 
diff --git a/pkgs/development/compilers/ghc/8.2.1.nix b/pkgs/development/compilers/ghc/8.2.1.nix
index dde56df81313..bcc801c98ea5 100644
--- a/pkgs/development/compilers/ghc/8.2.1.nix
+++ b/pkgs/development/compilers/ghc/8.2.1.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchurl, bootPkgs, perl, ncurses, libiconv, binutils, coreutils
+{ stdenv, lib, fetchurl, bootPkgs, perl, ncurses, libiconv, targetPackages, coreutils
 , autoconf, automake, happy, alex, python3, sphinx, hscolour
 , buildPlatform, targetPlatform , selfPkgs, cross ? null
 
@@ -66,7 +66,7 @@ in stdenv.mkDerivation (rec {
     for i in "$out/bin/"*; do
       test ! -h $i || continue
       egrep --quiet '^#!' <(head -n 1 $i) || continue
-      sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ binutils coreutils ]}"' $i
+      sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
     done
   '';
 
@@ -97,23 +97,23 @@ in stdenv.mkDerivation (rec {
 
   configureFlags = [
     "CC=${stdenv.ccCross}/bin/${cross.config}-cc"
-    "LD=${stdenv.binutils}/bin/${cross.config}-ld"
-    "AR=${stdenv.binutils}/bin/${cross.config}-ar"
-    "NM=${stdenv.binutils}/bin/${cross.config}-nm"
-    "RANLIB=${stdenv.binutils}/bin/${cross.config}-ranlib"
+    "LD=${targetPackages.stdenv.cc.bintools}/bin/${cross.config}-ld"
+    "AR=${targetPackages.stdenv.cc.bintools}/bin/${cross.config}-ar"
+    "NM=${targetPackages.stdenv.cc.bintools}/bin/${cross.config}-nm"
+    "RANLIB=${targetPackages.stdenv.cc.bintools}/bin/${cross.config}-ranlib"
     "--target=${cross.config}"
     "--enable-bootstrap-with-devel-snapshot"
   ] ++
     # fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
     lib.optional (cross.config or null == "aarch64-apple-darwin14") "--disable-large-address-space";
 
-  buildInputs = commonBuildInputs ++ [ stdenv.ccCross stdenv.binutils ];
+  buildInputs = commonBuildInputs ++ [ stdenv.ccCross stdenv.targetPackages.stdenv.cc.bintools ];
 
   dontSetConfigureCross = true;
 
   passthru = {
     inherit bootPkgs cross;
     cc = "${stdenv.ccCross}/bin/${cross.config}-cc";
-    ld = "${stdenv.binutils}/bin/${cross.config}-ld";
+    ld = "${stdenv.targetPackages.stdenv.cc.bintools}/bin/${cross.config}-ld";
   };
 })
diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix
index 362b4895b7e3..92ba3f6a46ed 100644
--- a/pkgs/development/compilers/ghc/head.nix
+++ b/pkgs/development/compilers/ghc/head.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchgit, bootPkgs, perl, ncurses, libiconv, binutils, coreutils
+{ stdenv, lib, fetchgit, bootPkgs, perl, ncurses, libiconv, targetPackages, coreutils
 , autoconf, automake, happy, alex, python3, buildPlatform, targetPlatform
 , selfPkgs, cross ? null
 
@@ -71,7 +71,7 @@ in stdenv.mkDerivation (rec {
     for i in "$out/bin/"*; do
       test ! -h $i || continue
       egrep --quiet '^#!' <(head -n 1 $i) || continue
-      sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ binutils coreutils ]}"' $i
+      sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
     done
   '';
 
diff --git a/pkgs/development/compilers/halvm/2.4.0.nix b/pkgs/development/compilers/halvm/2.4.0.nix
index 24fffcf603cb..0c4cef653d86 100644
--- a/pkgs/development/compilers/halvm/2.4.0.nix
+++ b/pkgs/development/compilers/halvm/2.4.0.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchgit, bootPkgs, perl, gmp, ncurses, binutils, autoconf, alex, happy, makeStaticLibraries
+{ stdenv, fetchgit, bootPkgs, perl, gmp, ncurses, targetPackages, autoconf, alex, happy, makeStaticLibraries
 , hscolour, xen, automake, gcc, git, zlib, libtool, enableIntegerSimple ? false
 }:
 
@@ -17,14 +17,14 @@ stdenv.mkDerivation rec {
     sed -i '305 d' Makefile
     sed -i '309,439 d' Makefile # Removes RPM packaging
     sed -i '20 d' src/scripts/halvm-cabal.in
-    sed -ie 's|ld |${binutils}/bin/ld |g' src/scripts/ldkernel.in
+    sed -ie 's|ld |${targetPackages.stdenv.cc.bintools}/bin/ld |g' src/scripts/ldkernel.in
   '';
   configureFlags = stdenv.lib.optional (!enableIntegerSimple) [ "--enable-gmp" ];
   propagatedNativeBuildInputs = [ alex happy ];
   buildInputs =
    let haskellPkgs = [ alex happy bootPkgs.hscolour bootPkgs.cabal-install bootPkgs.haddock bootPkgs.hpc
     ]; in [ bootPkgs.ghc
-            automake perl git binutils
+            automake perl git targetPackages.stdenv.cc.bintools
             autoconf xen zlib ncurses.dev
             libtool gmp ] ++ haskellPkgs;
   preConfigure = ''
@@ -40,7 +40,7 @@ stdenv.mkDerivation rec {
     inherit bootPkgs;
     cross.config = "halvm";
     cc = "${gcc}/bin/gcc";
-    ld = "${binutils}/bin/ld";
+    ld = "${targetPackages.stdenv.cc.bintools}/bin/ld";
   };
 
   meta = {
diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix
index a113f5db4807..9f96d05c1163 100644
--- a/pkgs/development/compilers/rust/rustc.nix
+++ b/pkgs/development/compilers/rust/rustc.nix
@@ -1,5 +1,6 @@
-{ stdenv, fetchurl, fetchgit, fetchzip, file, python2, tzdata, procps
-, llvm, jemalloc, ncurses, darwin, binutils, rustPlatform, git, cmake, curl
+{ stdenv, targetPackages
+, fetchurl, fetchgit, fetchzip, file, python2, tzdata, procps
+, llvm, jemalloc, ncurses, darwin, rustPlatform, git, cmake, curl
 , which, libffi, gdb
 , version
 , forceBundledLLVM ? false
@@ -49,7 +50,7 @@ stdenv.mkDerivation {
                 ++ [ "--enable-local-rust" "--local-rust-root=${rustPlatform.rust.rustc}" "--enable-rpath" ]
                 ++ [ "--enable-vendor" "--disable-locked-deps" ]
                 # ++ [ "--jemalloc-root=${jemalloc}/lib"
-                ++ [ "--default-linker=${stdenv.cc}/bin/cc" "--default-ar=${binutils.out}/bin/ar" ]
+                ++ [ "--default-linker=${targetPackages.stdenv.cc}/bin/cc" "--default-ar=${targetPackages.stdenv.cc.bintools}/bin/ar" ]
                 ++ optional (!forceBundledLLVM) [ "--enable-llvm-link-shared" ]
                 ++ optional (stdenv.cc.cc ? isClang) "--enable-clang"
                 ++ optional (targets != []) "--target=${target}"
diff --git a/pkgs/development/compilers/swift/default.nix b/pkgs/development/compilers/swift/default.nix
index 7484d2568be9..937977b0a97d 100644
--- a/pkgs/development/compilers/swift/default.nix
+++ b/pkgs/development/compilers/swift/default.nix
@@ -1,4 +1,5 @@
 { stdenv
+, targetPackages
 , cmake
 , coreutils
 , glibc
@@ -26,7 +27,6 @@
 , rsync
 , git
 , libgit2
-, binutils
 , fetchFromGitHub
 , paxctl
 , findutils
@@ -250,7 +250,7 @@ stdenv.mkDerivation rec {
 
     # TODO: Use wrappers to get these on the PATH for swift tools, instead
     ln -s ${clang}/bin/* $out/bin/
-    ln -s ${binutils}/bin/ar $out/bin/ar
+    ln -s ${targetPackages.stdenv.cc.bintools}/bin/ar $out/bin/ar
   '';
 
   # Hack to avoid TMPDIR in RPATHs.
diff --git a/pkgs/development/tools/profiling/systemtap/default.nix b/pkgs/development/tools/profiling/systemtap/default.nix
index 89a1b5fe0aac..b397f02665bc 100644
--- a/pkgs/development/tools/profiling/systemtap/default.nix
+++ b/pkgs/development/tools/profiling/systemtap/default.nix
@@ -1,5 +1,7 @@
 { fetchgit, pkgconfig, gettext, runCommand, makeWrapper
-, elfutils, kernel, gnumake, python2, pythonPackages, binutils }:
+, elfutils, kernel, gnumake, python2, pythonPackages
+}:
+
 let
   ## fetchgit info
   url = git://sourceware.org/git/systemtap.git;
@@ -55,5 +57,5 @@ in runCommand "systemtap-${kernel.version}-${version}" {
   rm $out/bin/stap
   makeWrapper $stapBuild/bin/stap $out/bin/stap \
     --add-flags "-r $kernelBuildDir" \
-    --prefix PATH : ${lib.makeBinPath [ stdenv.cc.cc binutils elfutils gnumake ]}
+    --prefix PATH : ${lib.makeBinPath [ stdenv.cc.cc stdenv.cc.bintools elfutils gnumake ]}
 ''
diff --git a/pkgs/games/brogue/default.nix b/pkgs/games/brogue/default.nix
index 814f4f6c82e6..d48dc8e8006e 100644
--- a/pkgs/games/brogue/default.nix
+++ b/pkgs/games/brogue/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, SDL, ncurses, libtcod, binutils }:
+{ stdenv, fetchurl, SDL, ncurses, libtcod }:
 
 stdenv.mkDerivation rec {
   name = "brogue-${version}";
diff --git a/pkgs/games/steam/runtime.nix b/pkgs/games/steam/runtime.nix
index 82fce93a66ae..1fa17c32d6c7 100644
--- a/pkgs/games/steam/runtime.nix
+++ b/pkgs/games/steam/runtime.nix
@@ -1,4 +1,4 @@
-{ stdenv, steamArch, fetchurl, writeText, python2, dpkg, binutils }:
+{ stdenv, steamArch, fetchurl, writeText, python2, dpkg }:
 
 let input = builtins.getAttr steamArch (import ./runtime-generated.nix { inherit fetchurl; });
 
@@ -7,7 +7,7 @@ let input = builtins.getAttr steamArch (import ./runtime-generated.nix { inherit
 in stdenv.mkDerivation {
   name = "steam-runtime-2016-08-13";
 
-  nativeBuildInputs = [ python2 dpkg binutils ];
+  nativeBuildInputs = [ python2 dpkg stdenv.cc.bintools ];
 
   buildCommand = ''
     mkdir -p $out
diff --git a/pkgs/servers/asterisk/default.nix b/pkgs/servers/asterisk/default.nix
index 1bea8006e9f3..c6cd9f3df4c5 100644
--- a/pkgs/servers/asterisk/default.nix
+++ b/pkgs/servers/asterisk/default.nix
@@ -1,6 +1,6 @@
 { stdenv, pkgs, lib, fetchurl, fetchgit, fetchsvn, fetchpatch,
   jansson, libxml2, libxslt, ncurses, openssl, sqlite,
-  utillinux, dmidecode, libuuid, binutils, newt,
+  utillinux, dmidecode, libuuid, newt,
   lua, speex,
   srtp, wget, curl
 }:
@@ -10,7 +10,7 @@ let
     inherit version;
     name = "asterisk-${version}";
 
-    buildInputs = [ jansson libxml2 libxslt ncurses openssl sqlite utillinux dmidecode libuuid binutils newt lua speex srtp wget curl ];
+    buildInputs = [ jansson libxml2 libxslt ncurses openssl sqlite utillinux dmidecode libuuid newt lua speex srtp wget curl ];
 
     patches = [
       # We want the Makefile to install the default /var skeleton
diff --git a/pkgs/stdenv/booter.nix b/pkgs/stdenv/booter.nix
index a1055708f995..7364a586fc2a 100644
--- a/pkgs/stdenv/booter.nix
+++ b/pkgs/stdenv/booter.nix
@@ -47,13 +47,13 @@ stageFuns: let
      same as
 
        let
-         f_-1  = lnul;
+         f_-1  = lnul f_0;
          f_0   = op f_-1   x_0  f_1;
          f_1   = op f_0    x_1  f_2;
          f_2   = op f_1    x_2  f_3;
          ...
          f_n   = op f_n-1  x_n  f_n+1;
-         f_n+1 = rnul;
+         f_n+1 = rnul f_n;
        in
          f_0
   */
@@ -62,13 +62,15 @@ stageFuns: let
       len = builtins.length list;
       go = pred: n:
         if n == len
-        then rnul
+        then rnul pred
         else let
           # Note the cycle -- call-by-need ensures finite fold.
           cur  = op pred (builtins.elemAt list n) succ;
           succ = go cur (n + 1);
         in cur;
-    in go lnul 0;
+      lapp = lnul cur;
+      cur = go lapp 0;
+    in cur;
 
   # Take the list and disallow custom overrides in all but the final stage,
   # and allow it in the final flag. Only defaults this boolean field if it
@@ -98,7 +100,18 @@ stageFuns: let
     then args'
     else allPackages ((builtins.removeAttrs args' ["selfBuild"]) // {
       buildPackages = if args.selfBuild or true then null else prevStage;
-      __targetPackages = if args.selfBuild or true then null else nextStage;
+      targetPackages = if args.selfBuild or true then null else nextStage;
     });
 
-in dfold folder {} {} withAllowCustomOverrides
+  # This is a hack for resolving cross-compiled compilers' run-time
+  # deps. (That is, compilers that are themselves cross-compiled, as
+  # opposed to used to cross-compile packages.)
+  postStage = buildPackages: {
+    __raw = true;
+    stdenv.cc =
+      if buildPackages.stdenv.cc.isClang or false
+      then buildPackages.clang
+      else buildPackages.gcc;
+  };
+
+in dfold folder postStage (_: {}) withAllowCustomOverrides
diff --git a/pkgs/tools/networking/htpdate/default.nix b/pkgs/tools/networking/htpdate/default.nix
index d937f3c2f0b9..47163b94dc52 100644
--- a/pkgs/tools/networking/htpdate/default.nix
+++ b/pkgs/tools/networking/htpdate/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
 
   makeFlags = [
     "INSTALL=install"
-    "STRIP=strip"
+    "STRIP=${stdenv.cc.bintools.prefix}strip"
     "prefix=$(out)"
   ];
 
diff --git a/pkgs/tools/networking/p2p/gtk-gnutella/default.nix b/pkgs/tools/networking/p2p/gtk-gnutella/default.nix
index 901d84b46926..f63c1d474c05 100644
--- a/pkgs/tools/networking/p2p/gtk-gnutella/default.nix
+++ b/pkgs/tools/networking/p2p/gtk-gnutella/default.nix
@@ -13,8 +13,8 @@ stdenv.mkDerivation {
     sha256 = "1zvadgsskmpm82id9mbj24a2lyq38qv768ixv7nmfjl3d4wr2biv";
   };
 
-  nativeBuildInputs = [ bison binutils gettext pkgconfig ];
-  buildInputs = [ glib gnutls gtk2 libxml2 zlib ];
+  nativeBuildInputs = [ bison gettext pkgconfig ];
+  buildInputs = [ binutils glib gnutls gtk2 libxml2 zlib ];
 
   hardeningDisable = [ "bindnow" "fortify" "pic" "relro" ];
 
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 04300e3507ea..8b888c534dac 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -5537,7 +5537,7 @@ with pkgs;
   # built with, and use, that cross-compiled libc.
   gccCrossStageStatic = assert targetPlatform != buildPlatform; let
     libcCross1 =
-      if targetPlatform.libc == "msvcrt" then __targetPackages.windows.mingw_w64_headers
+      if targetPlatform.libc == "msvcrt" then targetPackages.windows.mingw_w64_headers
       else if targetPlatform.libc == "libSystem" then darwin.xcode
       else null;
     in wrapCCWith {
@@ -8338,9 +8338,9 @@ with pkgs;
   libcCrossChooser = name:
     # libc is hackily often used from the previous stage. This `or`
     # hack fixes the hack, *sigh*.
-    /**/ if name == "glibc" then __targetPackages.glibcCross or glibcCross
+    /**/ if name == "glibc" then targetPackages.glibcCross or glibcCross
     else if name == "uclibc" then uclibcCross
-    else if name == "msvcrt" then __targetPackages.windows.mingw_w64 or windows.mingw_w64
+    else if name == "msvcrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64
     else if name == "libSystem" then darwin.xcode
     else throw "Unknown libc";
 
diff --git a/pkgs/top-level/splice.nix b/pkgs/top-level/splice.nix
index 44a46b7b6929..b13fa86a9958 100644
--- a/pkgs/top-level/splice.nix
+++ b/pkgs/top-level/splice.nix
@@ -67,7 +67,7 @@ let
     if actuallySplice
     then splicer defaultBuildScope defaultRunScope // {
       # These should never be spliced under any circumstances
-      inherit (pkgs) pkgs buildPackages __targetPackages
+      inherit (pkgs) pkgs buildPackages targetPackages
         buildPlatform targetPlatform hostPlatform;
     }
     else pkgs // pkgs.xorg;
diff --git a/pkgs/top-level/stage.nix b/pkgs/top-level/stage.nix
index 617fa0c30ce8..7cddc664570b 100644
--- a/pkgs/top-level/stage.nix
+++ b/pkgs/top-level/stage.nix
@@ -26,13 +26,13 @@
   # us to avoid expensive splicing.
   buildPackages
 
-, # The package set used in the next stage. If null, `__targetPackages` will be
+, # The package set used in the next stage. If null, `targetPackages` will be
   # defined internally as the final produced package set itself, just like with
   # `buildPackages` and for the same reasons.
   #
   # THIS IS A HACK for compilers that don't think critically about cross-
   # compilation. Please do *not* use unless you really know what you are doing.
-  __targetPackages
+  targetPackages
 
 , # The standard environment to use for building packages.
   stdenv
@@ -72,7 +72,7 @@ let
   stdenvBootstappingAndPlatforms = self: super: {
     buildPackages = (if buildPackages == null then self else buildPackages)
       // { recurseForDerivations = false; };
-    __targetPackages = (if __targetPackages == null then self else __targetPackages)
+    targetPackages = (if targetPackages == null then self else targetPackages)
       // { recurseForDerivations = false; };
     inherit stdenv;
   };