darwin stdenv: Make stdenv.cc, not stdenv, bring in libcxx

stdenvNoCC should not inject any C++ standard library, just as it
doesn't inject any C standard library. stdenv still does, but only
indirectly through stdenv.cc. Wrapped clangs can be simplified now that
they don't need to worry about clobbering CoreFoundation when replacing
the C++ standard library implementation.

This generally-good cleanup should assist with debugging some C++
failures in #26805.
This commit is contained in:
John Ericson 2017-12-24 22:00:58 -05:00
parent dc906952be
commit 4651407654
6 changed files with 15 additions and 25 deletions

View File

@ -44,15 +44,11 @@ let
stdenv = stdenv.override (drv: { stdenv = stdenv.override (drv: {
allowedRequisites = null; allowedRequisites = null;
cc = self.clang; cc = self.clang;
# Don't include the libc++ and libc++abi from the original stdenv.
extraBuildInputs = stdenv.lib.optional stdenv.isDarwin darwin.CF;
}); });
libcxxStdenv = stdenv.override (drv: { libcxxStdenv = stdenv.override (drv: {
allowedRequisites = null; allowedRequisites = null;
cc = self.libcxxClang; cc = self.libcxxClang;
# Don't include the libc++ and libc++abi from the original stdenv.
extraBuildInputs = stdenv.lib.optional stdenv.isDarwin darwin.CF;
}); });
lldb = callPackage ./lldb.nix {}; lldb = callPackage ./lldb.nix {};

View File

@ -41,15 +41,11 @@ let
stdenv = stdenv.override (drv: { stdenv = stdenv.override (drv: {
allowedRequisites = null; allowedRequisites = null;
cc = self.clang; cc = self.clang;
# Don't include the libc++ and libc++abi from the original stdenv.
extraBuildInputs = stdenv.lib.optional stdenv.isDarwin darwin.CF;
}); });
libcxxStdenv = stdenv.override (drv: { libcxxStdenv = stdenv.override (drv: {
allowedRequisites = null; allowedRequisites = null;
cc = self.libcxxClang; cc = self.libcxxClang;
# Don't include the libc++ and libc++abi from the original stdenv.
extraBuildInputs = stdenv.lib.optional stdenv.isDarwin darwin.CF;
}); });
lldb = callPackage ./lldb.nix {}; lldb = callPackage ./lldb.nix {};

View File

@ -41,15 +41,11 @@ let
stdenv = stdenv.override (drv: { stdenv = stdenv.override (drv: {
allowedRequisites = null; allowedRequisites = null;
cc = self.clang; cc = self.clang;
# Don't include the libc++ and libc++abi from the original stdenv.
extraBuildInputs = stdenv.lib.optional stdenv.isDarwin darwin.CF;
}); });
libcxxStdenv = stdenv.override (drv: { libcxxStdenv = stdenv.override (drv: {
allowedRequisites = null; allowedRequisites = null;
cc = self.libcxxClang; cc = self.libcxxClang;
# Don't include the libc++ and libc++abi from the original stdenv.
extraBuildInputs = stdenv.lib.optional stdenv.isDarwin darwin.CF;
}); });
lldb = callPackage ./lldb.nix {}; lldb = callPackage ./lldb.nix {};

View File

@ -56,15 +56,11 @@ let
stdenv = stdenv.override (drv: { stdenv = stdenv.override (drv: {
allowedRequisites = null; allowedRequisites = null;
cc = self.clang; cc = self.clang;
# Don't include the libc++ and libc++abi from the original stdenv.
extraBuildInputs = stdenv.lib.optional stdenv.isDarwin darwin.CF;
}); });
libcxxStdenv = stdenv.override (drv: { libcxxStdenv = stdenv.override (drv: {
allowedRequisites = null; allowedRequisites = null;
cc = self.libcxxClang; cc = self.libcxxClang;
# Don't include the libc++ and libc++abi from the original stdenv.
extraBuildInputs = stdenv.lib.optional stdenv.isDarwin darwin.CF;
}); });
lld = callPackage ./lld.nix {}; lld = callPackage ./lld.nix {};

View File

@ -56,15 +56,11 @@ let
stdenv = stdenv.override (drv: { stdenv = stdenv.override (drv: {
allowedRequisites = null; allowedRequisites = null;
cc = self.clang; cc = self.clang;
# Don't include the libc++ and libc++abi from the original stdenv.
extraBuildInputs = stdenv.lib.optional stdenv.isDarwin darwin.CF;
}); });
libcxxStdenv = stdenv.override (drv: { libcxxStdenv = stdenv.override (drv: {
allowedRequisites = null; allowedRequisites = null;
cc = self.libcxxClang; cc = self.libcxxClang;
# Don't include the libc++ and libc++abi from the original stdenv.
extraBuildInputs = stdenv.lib.optional stdenv.isDarwin darwin.CF;
}); });
lld = callPackage ./lld.nix {}; lld = callPackage ./lld.nix {};

View File

@ -58,6 +58,7 @@ in rec {
extraPreHook ? "", extraPreHook ? "",
extraNativeBuildInputs, extraNativeBuildInputs,
extraBuildInputs, extraBuildInputs,
libcxx,
allowedRequisites ? null}: allowedRequisites ? null}:
let let
buildPackages = lib.optionalAttrs (last ? stdenv) { buildPackages = lib.optionalAttrs (last ? stdenv) {
@ -82,6 +83,8 @@ in rec {
inherit shell; inherit shell;
inherit (last) stdenvNoCC; inherit (last) stdenvNoCC;
extraPackages = lib.optional (libcxx != null) libcxx;
nativeTools = false; nativeTools = false;
nativeLibc = false; nativeLibc = false;
inherit buildPackages coreutils gnugrep bintools; inherit buildPackages coreutils gnugrep bintools;
@ -176,6 +179,7 @@ in rec {
extraNativeBuildInputs = []; extraNativeBuildInputs = [];
extraBuildInputs = []; extraBuildInputs = [];
libcxx = null;
}; };
stage1 = prevStage: let stage1 = prevStage: let
@ -183,7 +187,8 @@ in rec {
in with prevStage; stageFun 1 prevStage { in with prevStage; stageFun 1 prevStage {
extraPreHook = "export NIX_CFLAGS_COMPILE+=\" -F${bootstrapTools}/Library/Frameworks\""; extraPreHook = "export NIX_CFLAGS_COMPILE+=\" -F${bootstrapTools}/Library/Frameworks\"";
extraNativeBuildInputs = []; extraNativeBuildInputs = [];
extraBuildInputs = [ pkgs.libcxx ]; extraBuildInputs = [ ];
libcxx = pkgs.libcxx;
allowedRequisites = allowedRequisites =
[ bootstrapTools ] ++ (with pkgs; [ libcxx libcxxabi ]) ++ [ pkgs.darwin.Libsystem ]; [ bootstrapTools ] ++ (with pkgs; [ libcxx libcxxabi ]) ++ [ pkgs.darwin.Libsystem ];
@ -210,7 +215,8 @@ in rec {
''; '';
extraNativeBuildInputs = [ pkgs.xz ]; extraNativeBuildInputs = [ pkgs.xz ];
extraBuildInputs = with pkgs; [ darwin.CF libcxx ]; extraBuildInputs = [ pkgs.darwin.CF ];
libcxx = pkgs.libcxx;
allowedRequisites = allowedRequisites =
[ bootstrapTools ] ++ [ bootstrapTools ] ++
@ -242,7 +248,8 @@ in rec {
# and instead goes by $PATH, which happens to contain bootstrapTools. So it goes and # and instead goes by $PATH, which happens to contain bootstrapTools. So it goes and
# patches our shebangs back to point at bootstrapTools. This makes sure bash comes first. # patches our shebangs back to point at bootstrapTools. This makes sure bash comes first.
extraNativeBuildInputs = with pkgs; [ xz pkgs.bash ]; extraNativeBuildInputs = with pkgs; [ xz pkgs.bash ];
extraBuildInputs = with pkgs; [ darwin.CF libcxx ]; extraBuildInputs = [ pkgs.darwin.CF ];
libcxx = pkgs.libcxx;
extraPreHook = '' extraPreHook = ''
export PATH=${pkgs.bash}/bin:$PATH export PATH=${pkgs.bash}/bin:$PATH
@ -277,7 +284,9 @@ in rec {
in with prevStage; stageFun 4 prevStage { in with prevStage; stageFun 4 prevStage {
shell = "${pkgs.bash}/bin/bash"; shell = "${pkgs.bash}/bin/bash";
extraNativeBuildInputs = with pkgs; [ xz pkgs.bash ]; extraNativeBuildInputs = with pkgs; [ xz pkgs.bash ];
extraBuildInputs = with pkgs; [ darwin.CF libcxx ]; extraBuildInputs = [ pkgs.darwin.CF ];
libcxx = pkgs.libcxx;
extraPreHook = '' extraPreHook = ''
export PATH_LOCALE=${pkgs.darwin.locale}/share/locale export PATH_LOCALE=${pkgs.darwin.locale}/share/locale
''; '';
@ -347,10 +356,11 @@ in rec {
cc = pkgs.llvmPackages.clang-unwrapped; cc = pkgs.llvmPackages.clang-unwrapped;
bintools = pkgs.darwin.binutils; bintools = pkgs.darwin.binutils;
libc = pkgs.darwin.Libsystem; libc = pkgs.darwin.Libsystem;
extraPackages = [ pkgs.libcxx ];
}; };
extraNativeBuildInputs = []; extraNativeBuildInputs = [];
extraBuildInputs = with pkgs; [ darwin.CF libcxx ]; extraBuildInputs = [ pkgs.darwin.CF ];
extraAttrs = { extraAttrs = {
inherit platform bootstrapTools; inherit platform bootstrapTools;