@@ -6061,18 +6061,6 @@ with pkgs;
60616061
60626062 clang-analyzer = callPackage ../development/tools/analysis/clang-analyzer { };
60636063
6064− clangSelf = clangWrapSelf llvmPackagesSelf.clang;
6065−
6066− clangWrapSelf = build: ccWrapperFun {
6067− cc = build;
6068− isClang = true;
6069− inherit stdenvNoCC;
6070− inherit (targetPackages.stdenv.cc) bintools libc;
6071− extraPackages = [ libcxx libcxxabi ];
6072− nativeTools = false;
6073− nativeLibc = false;
6074− };
6075−
60766064 #Use this instead of stdenv to build with clang
60776065 clangStdenv = if stdenv.cc.isClang then stdenv else lowPrio llvmPackages.stdenv;
60786066 clang-sierraHack-stdenv = overrideCC stdenv clang-sierraHack;
@@ -6709,10 +6697,6 @@ with pkgs;
67096697
67106698 llvmPackages = recurseIntoAttrs llvmPackages_5;
67116699
6712− llvmPackagesSelf = llvmPackages_34.override {
6713− stdenv = libcxxStdenv;
6714− };
6715−
67166700 llvmPackages_34 = callPackage ../development/compilers/llvm/3.4 ({
67176701 isl = isl_0_12;
67186702 } // stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) {
@@ -6727,30 +6711,40 @@ with pkgs;
67276711
67286712 llvmPackages_37 = callPackage ../development/compilers/llvm/3.7 ({
67296713 inherit (stdenvAdapters) overrideCC;
6714+ buildLlvmPackages = buildPackages.llvmPackages_37;
6715+ targetLlvmPackages = targetPackages.llvmPackages_37;
67306716 } // stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) {
67316717 stdenv = overrideCC stdenv gcc6;
67326718 });
67336719
67346720 llvmPackages_38 = callPackage ../development/compilers/llvm/3.8 ({
67356721 inherit (stdenvAdapters) overrideCC;
6722+ buildLlvmPackages = buildPackages.llvmPackages_38;
6723+ targetLlvmPackages = targetPackages.llvmPackages_38;
67366724 } // stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) {
67376725 stdenv = overrideCC stdenv gcc6;
67386726 });
67396727
67406728 llvmPackages_39 = callPackage ../development/compilers/llvm/3.9 ({
67416729 inherit (stdenvAdapters) overrideCC;
6730+ buildLlvmPackages = buildPackages.llvmPackages_39;
6731+ targetLlvmPackages = targetPackages.llvmPackages_39;
67426732 } // stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) {
67436733 stdenv = overrideCC stdenv gcc6;
67446734 });
67456735
67466736 llvmPackages_4 = callPackage ../development/compilers/llvm/4 ({
67476737 inherit (stdenvAdapters) overrideCC;
6738+ buildLlvmPackages = buildPackages.llvmPackages_4;
6739+ targetLlvmPackages = targetPackages.llvmPackages_4;
67486740 } // stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) {
67496741 stdenv = overrideCC stdenv gcc6;
67506742 });
67516743
67526744 llvmPackages_5 = callPackage ../development/compilers/llvm/5 ({
67536745 inherit (stdenvAdapters) overrideCC;
6746+ buildLlvmPackages = buildPackages.llvmPackages_5;
6747+ targetLlvmPackages = targetPackages.llvmPackages_5;
67546748 } // stdenv.lib.optionalAttrs stdenv.isDarwin {
67556749 cmake = cmake.override {
67566750 isBootstrap = true;
@@ -6764,6 +6758,8 @@ with pkgs;
67646758
67656759 llvmPackages_6 = callPackage ../development/compilers/llvm/6 ({
67666760 inherit (stdenvAdapters) overrideCC;
6761+ buildLlvmPackages = buildPackages.llvmPackages_6;
6762+ targetLlvmPackages = targetPackages.llvmPackages_6;
67676763 } // stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) {
67686764 stdenv = overrideCC stdenv gcc6; # with gcc-7: undefined reference to `__divmoddi4'
67696765 });
@@ -7017,42 +7013,46 @@ with pkgs;
70177013
70187014 wla-dx = callPackage ../development/compilers/wla-dx { };
70197015
7020− wrapCCWith = { name ? "", cc, bintools, libc, extraBuildCommands ? "" }:
7021− ccWrapperFun rec {
7016+ wrapCCWith =
7017+ { cc
7018+ , # This should be the only bintools runtime dep with this sort of logic. The
7019+ # Others should instead delegate to the next stage's choice with
7020+ # `targetPackages.stdenv.cc.bintools`. This one is different just to
7021+ # provide the default choice, avoiding infinite recursion.
7022+ bintools ? if targetPlatform.isDarwin then darwin.binutils else binutils
7023+ , libc ? bintools.libc
7024+ , ...
7025+ } @ extraArgs:
7026+ callPackage ../build-support/cc-wrapper (let self = {
70227027 nativeTools = targetPlatform == hostPlatform && stdenv.cc.nativeTools or false;
70237028 nativeLibc = targetPlatform == hostPlatform && stdenv.cc.nativeLibc or false;
70247029 nativePrefix = stdenv.cc.nativePrefix or "";
7025− noLibc = !nativeLibc && (libc == null);
7030+ noLibc = !self.nativeLibc && (self.libc == null);
70267031
70277032 isGNU = cc.isGNU or false;
70287033 isClang = cc.isClang or false;
70297034
7030− inherit name cc bintools libc extraBuildCommands;
7031− };
7032−
7033− ccWrapperFun = callPackage ../build-support/cc-wrapper;
7034− bintoolsWrapperFun = callPackage ../build-support/bintools-wrapper;
7035+ inherit cc bintools libc;
7036+ } // extraArgs; in self);
70357037
70367038 wrapCC = cc: wrapCCWith {
7037− name = lib.optionalString (targetPlatform != hostPlatform) "gcc-cross-wrapper";
70387039 inherit cc;
7039− # This should be the only bintools runtime dep with this sort of logic. The
7040− # Others should instead delegate to the next stage's choice with
7041− # `targetPackages.stdenv.cc.bintools`. This one is different just to
7042− # provide the default choice, avoiding infinite recursion.
7043− bintools = if targetPlatform.isDarwin then darwin.binutils else binutils;
7044− libc = if targetPlatform != hostPlatform then libcCross else stdenv.cc.libc;
70457040 };
70467041
7047− wrapBintoolsWith = { bintools, libc, extraBuildCommands ? "" }: bintoolsWrapperFun {
7042+ wrapBintoolsWith =
7043+ { bintools
7044+ , libc ? if targetPlatform != hostPlatform then libcCross else stdenv.cc.libc
7045+ , ...
7046+ } @ extraArgs:
7047+ callPackage ../build-support/bintools-wrapper (let self = {
70487048 nativeTools = targetPlatform == hostPlatform && stdenv.cc.nativeTools or false;
70497049 nativeLibc = targetPlatform == hostPlatform && stdenv.cc.nativeLibc or false;
70507050 nativePrefix = stdenv.cc.nativePrefix or "";
70517051
7052− noLibc = (libc == null);
7052+ noLibc = (self.libc == null);
70537053
7054− inherit bintools libc extraBuildCommands;
7055− };
7054+ inherit bintools libc;
7055+ } // extraArgs; in self);
70567056
70577057 # prolog
70587058 yap = callPackage ../development/compilers/yap { };
@@ -7658,11 +7658,9 @@ with pkgs;
76587658 noSysDirs = (targetPlatform != buildPlatform) || noSysDirs;
76597659 };
76607660 binutils = wrapBintoolsWith {
7661− libc = if targetPlatform != hostPlatform then libcCross else stdenv.cc.libc;
76627661 bintools = binutils-unwrapped;
76637662 };
76647663 binutils_nogold = lowPrio (wrapBintoolsWith {
7665− libc = if targetPlatform != hostPlatform then libcCross else stdenv.cc.libc;
76667664 bintools = binutils-unwrapped.override {
76677665 gold = false;
76687666 };