bintools-wrapper: Import separately from cc-wrapper

This commit is contained in:
John Ericson 2017-08-26 11:43:30 -04:00
parent 8e557ed2c5
commit 2bba929062
16 changed files with 150 additions and 77 deletions

View File

@ -6,18 +6,17 @@
# compiler and the linker just "work". # compiler and the linker just "work".
{ name ? "", stdenvNoCC, nativeTools, noLibc ? false, nativeLibc, nativePrefix ? "" { name ? "", stdenvNoCC, nativeTools, noLibc ? false, nativeLibc, nativePrefix ? ""
, cc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? stdenvNoCC.shell , cc ? null, libc ? null, bintools, coreutils ? null, shell ? stdenvNoCC.shell
, zlib ? null, extraPackages ? [], extraBuildCommands ? "" , zlib ? null, extraPackages ? [], extraBuildCommands ? ""
, isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null , isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null
, buildPackages ? {} , buildPackages ? {}
, useMacosReexportHack ? false
}: }:
with stdenvNoCC.lib; with stdenvNoCC.lib;
assert nativeTools -> nativePrefix != ""; assert nativeTools -> nativePrefix != "";
assert !nativeTools -> assert !nativeTools ->
cc != null && binutils != null && coreutils != null && gnugrep != null; cc != null && coreutils != null && gnugrep != null;
assert !(nativeLibc && noLibc); assert !(nativeLibc && noLibc);
assert (noLibc || nativeLibc) == (libc == null); assert (noLibc || nativeLibc) == (libc == null);
@ -28,17 +27,6 @@ let
stdenv = stdenvNoCC; stdenv = stdenvNoCC;
inherit (stdenv) hostPlatform targetPlatform; inherit (stdenv) hostPlatform targetPlatform;
bintools = import ../bintools-wrapper {
bintools = binutils;
inherit # name
stdenvNoCC nativeTools noLibc nativeLibc nativePrefix
libc
coreutils shell gnugrep
extraPackages extraBuildCommands
buildPackages
useMacosReexportHack;
};
# Prefix for binaries. Customarily ends with a dash separator. # Prefix for binaries. Customarily ends with a dash separator.
# #
# TODO(@Ericson2314) Make unconditional, or optional but always true by # TODO(@Ericson2314) Make unconditional, or optional but always true by

View File

@ -1,4 +1,4 @@
{ newScope, stdenv, wrapCC, wrapCCWith, symlinkJoin }: { newScope, stdenv, binutils-raw, wrapCCWith, symlinkJoin }:
let let
callPackage = newScope (self // {inherit stdenv;}); callPackage = newScope (self // {inherit stdenv;});
@ -6,6 +6,8 @@ let
emscriptenfastcomp-unwrapped = callPackage ./emscripten-fastcomp.nix {}; emscriptenfastcomp-unwrapped = callPackage ./emscripten-fastcomp.nix {};
emscriptenfastcomp-wrapped = wrapCCWith { emscriptenfastcomp-wrapped = wrapCCWith {
cc = self.emscriptenfastcomp-unwrapped; cc = self.emscriptenfastcomp-unwrapped;
# Never want Apple's cctools for WASM target
bintools = binutils-raw;
libc = stdenv.cc.libc; libc = stdenv.cc.libc;
extraBuildCommands = '' extraBuildCommands = ''
# hardening flags break WASM support # hardening flags break WASM support

View File

@ -30,14 +30,14 @@ let
libstdcxxClang = ccWrapperFun { libstdcxxClang = ccWrapperFun {
cc = self.clang-unwrapped; cc = self.clang-unwrapped;
/* FIXME is this right? */ /* FIXME is this right? */
inherit (stdenv.cc) libc nativeTools nativeLibc; inherit (stdenv.cc) bintools libc nativeTools nativeLibc;
extraPackages = [ libstdcxxHook ]; extraPackages = [ libstdcxxHook ];
}; };
libcxxClang = ccWrapperFun { libcxxClang = ccWrapperFun {
cc = self.clang-unwrapped; cc = self.clang-unwrapped;
/* FIXME is this right? */ /* FIXME is this right? */
inherit (stdenv.cc) libc nativeTools nativeLibc; inherit (stdenv.cc) bintools libc nativeTools nativeLibc;
extraPackages = [ self.libcxx self.libcxxabi ]; extraPackages = [ self.libcxx self.libcxxabi ];
}; };

View File

@ -27,14 +27,14 @@ let
libstdcxxClang = ccWrapperFun { libstdcxxClang = ccWrapperFun {
cc = self.clang-unwrapped; cc = self.clang-unwrapped;
/* FIXME is this right? */ /* FIXME is this right? */
inherit (stdenv.cc) libc nativeTools nativeLibc; inherit (stdenv.cc) bintools libc nativeTools nativeLibc;
extraPackages = [ libstdcxxHook ]; extraPackages = [ libstdcxxHook ];
}; };
libcxxClang = ccWrapperFun { libcxxClang = ccWrapperFun {
cc = self.clang-unwrapped; cc = self.clang-unwrapped;
/* FIXME is this right? */ /* FIXME is this right? */
inherit (stdenv.cc) libc nativeTools nativeLibc; inherit (stdenv.cc) bintools libc nativeTools nativeLibc;
extraPackages = [ self.libcxx self.libcxxabi ]; extraPackages = [ self.libcxx self.libcxxabi ];
}; };

View File

@ -27,14 +27,14 @@ let
libstdcxxClang = ccWrapperFun { libstdcxxClang = ccWrapperFun {
cc = self.clang-unwrapped; cc = self.clang-unwrapped;
/* FIXME is this right? */ /* FIXME is this right? */
inherit (stdenv.cc) libc nativeTools nativeLibc; inherit (stdenv.cc) bintools libc nativeTools nativeLibc;
extraPackages = [ libstdcxxHook ]; extraPackages = [ libstdcxxHook ];
}; };
libcxxClang = ccWrapperFun { libcxxClang = ccWrapperFun {
cc = self.clang-unwrapped; cc = self.clang-unwrapped;
/* FIXME is this right? */ /* FIXME is this right? */
inherit (stdenv.cc) libc nativeTools nativeLibc; inherit (stdenv.cc) bintools libc nativeTools nativeLibc;
extraPackages = [ self.libcxx self.libcxxabi ]; extraPackages = [ self.libcxx self.libcxxabi ];
}; };

View File

@ -42,14 +42,14 @@ let
libstdcxxClang = ccWrapperFun { libstdcxxClang = ccWrapperFun {
cc = self.clang-unwrapped; cc = self.clang-unwrapped;
/* FIXME is this right? */ /* FIXME is this right? */
inherit (stdenv.cc) libc nativeTools nativeLibc; inherit (stdenv.cc) bintools libc nativeTools nativeLibc;
extraPackages = [ libstdcxxHook ]; extraPackages = [ libstdcxxHook ];
}; };
libcxxClang = ccWrapperFun { libcxxClang = ccWrapperFun {
cc = self.clang-unwrapped; cc = self.clang-unwrapped;
/* FIXME is this right? */ /* FIXME is this right? */
inherit (stdenv.cc) libc nativeTools nativeLibc; inherit (stdenv.cc) bintools libc nativeTools nativeLibc;
extraPackages = [ self.libcxx self.libcxxabi ]; extraPackages = [ self.libcxx self.libcxxabi ];
}; };

View File

@ -42,14 +42,14 @@ let
libstdcxxClang = ccWrapperFun { libstdcxxClang = ccWrapperFun {
cc = self.clang-unwrapped; cc = self.clang-unwrapped;
/* FIXME is this right? */ /* FIXME is this right? */
inherit (stdenv.cc) libc nativeTools nativeLibc; inherit (stdenv.cc) bintools libc nativeTools nativeLibc;
extraPackages = [ libstdcxxHook ]; extraPackages = [ libstdcxxHook ];
}; };
libcxxClang = ccWrapperFun { libcxxClang = ccWrapperFun {
cc = self.clang-unwrapped; cc = self.clang-unwrapped;
/* FIXME is this right? */ /* FIXME is this right? */
inherit (stdenv.cc) libc nativeTools nativeLibc; inherit (stdenv.cc) bintools libc nativeTools nativeLibc;
extraPackages = [ self.libcxx self.libcxxabi ]; extraPackages = [ self.libcxx self.libcxxabi ];
}; };

View File

@ -5,11 +5,11 @@
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "libbfd-${version}"; name = "libbfd-${version}";
inherit (binutils-raw) version src; inherit (binutils-raw.bintools) version src;
outputs = [ "out" "dev" ]; outputs = [ "out" "dev" ];
patches = binutils-raw.patches ++ [ patches = binutils-raw.bintools.patches ++ [
../../tools/misc/binutils/build-components-separately.patch ../../tools/misc/binutils/build-components-separately.patch
]; ];

View File

@ -5,11 +5,11 @@
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "libopcodes-${version}"; name = "libopcodes-${version}";
inherit (binutils-raw) version src; inherit (binutils-raw.bintools) version src;
outputs = [ "out" "dev" ]; outputs = [ "out" "dev" ];
patches = binutils-raw.patches ++ [ patches = binutils-raw.bintools.patches ++ [
../../tools/misc/binutils/build-components-separately.patch ../../tools/misc/binutils/build-components-separately.patch
]; ];

View File

@ -20,7 +20,7 @@ stdenv.mkDerivation {
buildCommand = '' buildCommand = ''
mkdir -p $out/bin $out/include mkdir -p $out/bin $out/include
ln -s ${binutils-raw.out}/bin/${targetPrefix}c++filt $out/bin/${targetPrefix}c++filt ln -s ${binutils-raw.bintools.out}/bin/${targetPrefix}c++filt $out/bin/${targetPrefix}c++filt
# We specifically need: # We specifically need:
# - ld: binutils doesn't provide it on darwin # - ld: binutils doesn't provide it on darwin
@ -38,7 +38,7 @@ stdenv.mkDerivation {
done done
# FIXME: this will give us incorrect man pages for bits of cctools # FIXME: this will give us incorrect man pages for bits of cctools
ln -s ${binutils-raw.out}/share $out/share ln -s ${binutils-raw.bintools.out}/share $out/share
ln -s ${cctools}/libexec $out/libexec ln -s ${cctools}/libexec $out/libexec
''; '';

View File

@ -60,10 +60,40 @@ in rec {
extraBuildInputs, extraBuildInputs,
allowedRequisites ? null}: allowedRequisites ? null}:
let let
buildPackages = lib.optionalAttrs (last ? stdenv) {
inherit (last) stdenv;
};
coreutils = { name = "coreutils-9.9.9"; outPath = bootstrapTools; };
gnugrep = { name = "gnugrep-9.9.9"; outPath = bootstrapTools; };
bintools = import ../../build-support/bintools-wrapper {
inherit shell;
inherit (last) stdenvNoCC;
nativeTools = false;
nativeLibc = false;
inherit buildPackages coreutils gnugrep;
libc = last.pkgs.darwin.Libsystem;
bintools = { name = "binutils-9.9.9"; outPath = bootstrapTools; };
};
cc = if isNull last then "/dev/null" else import ../../build-support/cc-wrapper {
inherit shell;
inherit (last) stdenvNoCC;
nativeTools = false;
nativeLibc = false;
inherit buildPackages coreutils gnugrep bintools;
libc = last.pkgs.darwin.Libsystem;
isClang = true;
cc = { name = "clang-9.9.9"; outPath = bootstrapTools; };
};
thisStdenv = import ../generic { thisStdenv = import ../generic {
inherit config shell extraNativeBuildInputs extraBuildInputs; inherit config shell extraNativeBuildInputs extraBuildInputs;
allowedRequisites = if allowedRequisites == null then null else allowedRequisites ++ [ allowedRequisites = if allowedRequisites == null then null else allowedRequisites ++ [
thisStdenv.cc.expand-response-params cc.expand-response-params cc.bintools
]; ];
name = "stdenv-darwin-boot-${toString step}"; name = "stdenv-darwin-boot-${toString step}";
@ -72,24 +102,9 @@ in rec {
hostPlatform = localSystem; hostPlatform = localSystem;
targetPlatform = localSystem; targetPlatform = localSystem;
cc = if isNull last then "/dev/null" else import ../../build-support/cc-wrapper { inherit cc;
inherit shell;
inherit (last) stdenvNoCC;
nativeTools = false; preHook = lib.optionalString (shell == "${bootstrapTools}/bin/bash") ''
nativeLibc = false;
buildPackages = lib.optionalAttrs (last ? stdenv) {
inherit (last) stdenv;
};
libc = last.pkgs.darwin.Libsystem;
isClang = true;
cc = { name = "clang-9.9.9"; outPath = bootstrapTools; };
binutils = { name = "binutils-9.9.9"; outPath = bootstrapTools; };
coreutils = { name = "coreutils-9.9.9"; outPath = bootstrapTools; };
gnugrep = { name = "gnugrep-9.9.9"; outPath = bootstrapTools; };
};
preHook = stage0.stdenv.lib.optionalString (shell == "${bootstrapTools}/bin/bash") ''
# Don't patch #!/interpreter because it leads to retained # Don't patch #!/interpreter because it leads to retained
# dependencies on the bootstrapTools in the final stdenv. # dependencies on the bootstrapTools in the final stdenv.
dontPatchShebangs=1 dontPatchShebangs=1
@ -328,8 +343,9 @@ in rec {
buildPackages = { buildPackages = {
inherit (prevStage) stdenv; inherit (prevStage) stdenv;
}; };
inherit (pkgs) coreutils binutils gnugrep; inherit (pkgs) coreutils gnugrep;
cc = pkgs.llvmPackages.clang-unwrapped; cc = pkgs.llvmPackages.clang-unwrapped;
bintools = pkgs.darwin.binutils;
libc = pkgs.darwin.Libsystem; libc = pkgs.darwin.Libsystem;
}; };
@ -349,8 +365,8 @@ in rec {
xz.out xz.bin libcxx libcxxabi gmp.out gnumake findutils bzip2.out xz.out xz.bin libcxx libcxxabi gmp.out gnumake findutils bzip2.out
bzip2.bin llvmPackages.llvm llvmPackages.llvm.lib zlib.out zlib.dev libffi.out coreutils ed diffutils gnutar bzip2.bin llvmPackages.llvm llvmPackages.llvm.lib zlib.out zlib.dev libffi.out coreutils ed diffutils gnutar
gzip ncurses.out ncurses.dev ncurses.man gnused bash gawk gzip ncurses.out ncurses.dev ncurses.man gnused bash gawk
gnugrep llvmPackages.clang-unwrapped patch pcre.out binutils-raw.out gnugrep llvmPackages.clang-unwrapped patch pcre.out gettext
binutils gettext binutils-raw.bintools binutils binutils.bintools
cc.expand-response-params cc.expand-response-params
]) ++ (with pkgs.darwin; [ ]) ++ (with pkgs.darwin; [
dyld Libsystem CF cctools ICU libiconv locale dyld Libsystem CF cctools ICU libiconv locale

View File

@ -80,9 +80,10 @@ let
inherit (prevStage) stdenv; inherit (prevStage) stdenv;
}; };
cc = prevStage.gcc-unwrapped; cc = prevStage.gcc-unwrapped;
bintools = prevStage.binutils;
isGNU = true; isGNU = true;
libc = prevStage.glibc; libc = prevStage.glibc;
inherit (prevStage) binutils coreutils gnugrep; inherit (prevStage) coreutils gnugrep;
name = name; name = name;
stdenvNoCC = prevStage.ccWrapperStdenv; stdenvNoCC = prevStage.ccWrapperStdenv;
}; };
@ -143,7 +144,15 @@ in
''; '';
}; };
gcc-unwrapped = bootstrapTools; gcc-unwrapped = bootstrapTools;
binutils = bootstrapTools; binutils = import ../../build-support/bintools-wrapper {
nativeTools = false;
nativeLibc = false;
buildPackages = { };
libc = self.glibc;
inherit (self) stdenvNoCC coreutils gnugrep;
bintools = bootstrapTools;
name = "bootstrap-binutils-wrapper";
};
coreutils = bootstrapTools; coreutils = bootstrapTools;
gnugrep = bootstrapTools; gnugrep = bootstrapTools;
}; };
@ -165,7 +174,7 @@ in
# Rebuild binutils to use from stage2 onwards. # Rebuild binutils to use from stage2 onwards.
overrides = self: super: { overrides = self: super: {
binutils = super.binutils.override { gold = false; }; binutils = super.binutils_nogold;
inherit (prevStage) inherit (prevStage)
ccWrapperStdenv ccWrapperStdenv
glibc gcc-unwrapped coreutils gnugrep; glibc gcc-unwrapped coreutils gnugrep;
@ -188,9 +197,14 @@ in
overrides = self: super: { overrides = self: super: {
inherit (prevStage) inherit (prevStage)
ccWrapperStdenv ccWrapperStdenv
binutils gcc-unwrapped coreutils gnugrep gcc-unwrapped coreutils gnugrep
perl paxctl gnum4 bison; perl paxctl gnum4 bison;
# This also contains the full, dynamically linked, final Glibc. # This also contains the full, dynamically linked, final Glibc.
binutils = prevStage.binutils.override {
# Rewrap the binutils with the new glibc, so both the next
# stage's wrappers use it.
libc = self.glibc;
};
}; };
}) })
@ -235,6 +249,15 @@ in
# other purposes (binutils and top-level pkgs) too. # other purposes (binutils and top-level pkgs) too.
inherit (prevStage) gettext gnum4 bison gmp perl glibc zlib linuxHeaders; inherit (prevStage) gettext gnum4 bison gmp perl glibc zlib linuxHeaders;
binutils = super.binutils.override {
# Don't use stdenv's shell but our own
shell = self.bash + "/bin/bash";
# Build expand-response-params with last stage like below
buildPackages = {
inherit (prevStage) stdenv;
};
};
gcc = lib.makeOverridable (import ../../build-support/cc-wrapper) { gcc = lib.makeOverridable (import ../../build-support/cc-wrapper) {
nativeTools = false; nativeTools = false;
nativeLibc = false; nativeLibc = false;
@ -243,8 +266,9 @@ in
inherit (prevStage) stdenv; inherit (prevStage) stdenv;
}; };
cc = prevStage.gcc-unwrapped; cc = prevStage.gcc-unwrapped;
bintools = self.binutils;
libc = self.glibc; libc = self.glibc;
inherit (self) stdenvNoCC binutils coreutils gnugrep; inherit (self) stdenvNoCC coreutils gnugrep;
name = ""; name = "";
shell = self.bash + "/bin/bash"; shell = self.bash + "/bin/bash";
}; };
@ -299,8 +323,8 @@ in
allowedRequisites = with prevStage; with lib; allowedRequisites = with prevStage; with lib;
# Simple executable tools # Simple executable tools
concatMap (p: [ (getBin p) (getLib p) ]) concatMap (p: [ (getBin p) (getLib p) ])
[ gzip bzip2 xz bash binutils coreutils diffutils findutils gawk [ gzip bzip2 xz bash binutils.bintools coreutils diffutils findutils
gnumake gnused gnutar gnugrep gnupatch patchelf ed paxctl gawk gnumake gnused gnutar gnugrep gnupatch patchelf ed paxctl
] ]
# Library dependencies # Library dependencies
++ map getLib ( ++ map getLib (
@ -310,7 +334,7 @@ in
# More complicated cases # More complicated cases
++ [ ++ [
glibc.out glibc.dev glibc.bin/*propagated from .dev*/ linuxHeaders glibc.out glibc.dev glibc.bin/*propagated from .dev*/ linuxHeaders
gcc gcc.cc gcc.cc.lib gcc.expand-response-params binutils gcc gcc.cc gcc.cc.lib gcc.expand-response-params
] ]
++ lib.optionals localSystem.isAarch64 ++ lib.optionals localSystem.isAarch64
[ prevStage.updateAutotoolsGnuConfigScriptsHook prevStage.gnu-config ]; [ prevStage.updateAutotoolsGnuConfigScriptsHook prevStage.gnu-config ];
@ -322,7 +346,7 @@ in
attr acl paxctl zlib pcre; attr acl paxctl zlib pcre;
} // lib.optionalAttrs (super.targetPlatform == localSystem) { } // lib.optionalAttrs (super.targetPlatform == localSystem) {
# Need to get rid of these when cross-compiling. # Need to get rid of these when cross-compiling.
inherit (prevStage) binutils; inherit (prevStage) binutils binutils-raw;
gcc = cc; gcc = cc;
}; };
}; };

View File

@ -177,7 +177,7 @@ rec {
# Copy binutils. # Copy binutils.
for i in as ld ar ranlib nm strip readelf objdump; do for i in as ld ar ranlib nm strip readelf objdump; do
cp ${binutils.out}/bin/$i $out/bin cp ${binutils.bintools.out}/bin/$i $out/bin
done done
chmod -R u+w $out chmod -R u+w $out

View File

@ -126,7 +126,7 @@ rec {
# Copy binutils. # Copy binutils.
for i in as ld ar ranlib nm strip readelf objdump; do for i in as ld ar ranlib nm strip readelf objdump; do
cp ${binutils.out}/bin/$i $out/bin cp ${binutils.bintools.out}/bin/$i $out/bin
done done
chmod -R u+w $out chmod -R u+w $out

View File

@ -5462,8 +5462,10 @@ with pkgs;
clang-sierraHack = clang.override { clang-sierraHack = clang.override {
name = "clang-wrapper-with-reexport-hack"; name = "clang-wrapper-with-reexport-hack";
bintools = clang.bintools.override {
useMacosReexportHack = true; useMacosReexportHack = true;
}; };
};
clang_5 = llvmPackages_5.clang; clang_5 = llvmPackages_5.clang;
clang_4 = llvmPackages_4.clang; clang_4 = llvmPackages_4.clang;
@ -5491,7 +5493,7 @@ with pkgs;
cc = build; cc = build;
isClang = true; isClang = true;
inherit stdenvNoCC; inherit stdenvNoCC;
libc = glibc; inherit (targetPackages.stdenv.cc) bintools libc;
extraPackages = [ libcxx libcxxabi ]; extraPackages = [ libcxx libcxxabi ];
nativeTools = false; nativeTools = false;
nativeLibc = false; nativeLibc = false;
@ -5561,18 +5563,23 @@ with pkgs;
}; };
wrapCCMulti = cc: wrapCCMulti = cc:
if system == "x86_64-linux" then lowPrio (wrapCCWith { if system == "x86_64-linux" then let
# Binutils with glibc multi
bintools = cc.bintools.override {
libc = glibc_multi;
};
in lowPrio (wrapCCWith {
cc = cc.cc.override { cc = cc.cc.override {
stdenv = overrideCC stdenv (wrapCCWith { stdenv = overrideCC stdenv (wrapCCWith {
cc = cc.cc; cc = cc.cc;
inherit bintools;
libc = glibc_multi; libc = glibc_multi;
}); });
profiledCompiler = false; profiledCompiler = false;
enableMultilib = true; enableMultilib = true;
}; };
libc = glibc_multi; libc = glibc_multi;
inherit bintools;
extraBuildCommands = '' extraBuildCommands = ''
echo "dontMoveLib64=1" >> $out/nix-support/setup-hook echo "dontMoveLib64=1" >> $out/nix-support/setup-hook
''; '';
@ -5605,6 +5612,10 @@ with pkgs;
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 if targetPlatform.libc == "libSystem" then darwin.xcode
else null; else null;
binutils1 = wrapBintoolsWith {
bintools = binutils-unwrapped;
libc = libcCross1;
};
in wrapCCWith { in wrapCCWith {
name = "gcc-cross-wrapper"; name = "gcc-cross-wrapper";
cc = gccFun { cc = gccFun {
@ -5618,9 +5629,10 @@ with pkgs;
crossStageStatic = true; crossStageStatic = true;
langCC = false; langCC = false;
libcCross = libcCross1; libcCross = libcCross1;
targetPackages.stdenv.cc.bintools = binutils; targetPackages.stdenv.cc.bintools = binutils1;
enableShared = false; enableShared = false;
}; };
bintools = binutils1;
libc = libcCross1; libc = libcCross1;
}; };
@ -5629,6 +5641,7 @@ with pkgs;
name = "gcc-cross-wrapper"; name = "gcc-cross-wrapper";
cc = gccCrossStageStatic.gcc; cc = gccCrossStageStatic.gcc;
libc = windows.mingw_headers2; libc = windows.mingw_headers2;
inherit binutils;
}; };
gcc45 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/4.5 { gcc45 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/4.5 {
@ -6394,7 +6407,8 @@ with pkgs;
wla-dx = callPackage ../development/compilers/wla-dx { }; wla-dx = callPackage ../development/compilers/wla-dx { };
wrapCCWith = { name ? "", cc, libc, extraBuildCommands ? "" }: ccWrapperFun rec { wrapCCWith = { name ? "", cc, bintools, libc, extraBuildCommands ? "" }:
ccWrapperFun rec {
nativeTools = targetPlatform == hostPlatform && stdenv.cc.nativeTools or false; nativeTools = targetPlatform == hostPlatform && stdenv.cc.nativeTools or false;
nativeLibc = targetPlatform == hostPlatform && stdenv.cc.nativeLibc or false; nativeLibc = targetPlatform == hostPlatform && stdenv.cc.nativeLibc or false;
nativePrefix = stdenv.cc.nativePrefix or ""; nativePrefix = stdenv.cc.nativePrefix or "";
@ -6403,14 +6417,20 @@ with pkgs;
isGNU = cc.isGNU or false; isGNU = cc.isGNU or false;
isClang = cc.isClang or false; isClang = cc.isClang or false;
inherit name cc libc extraBuildCommands; inherit name cc bintools libc extraBuildCommands;
}; };
ccWrapperFun = callPackage ../build-support/cc-wrapper; ccWrapperFun = callPackage ../build-support/cc-wrapper;
bintoolsWrapperFun = callPackage ../build-support/bintools-wrapper;
wrapCC = cc: wrapCCWith { wrapCC = cc: wrapCCWith {
name = lib.optionalString (targetPlatform != hostPlatform) "gcc-cross-wrapper"; name = lib.optionalString (targetPlatform != hostPlatform) "gcc-cross-wrapper";
inherit cc; inherit cc;
# This should be the only bintools runtime dep with this sort of logic. The
# Others should instead delegate to the next stage's choice with
# `targetPackages.stdenv.cc.bintools`. This one is different just to
# provide the default choice, avoiding infinite recursion.
bintools = if targetPlatform.isDarwin then darwin.binutils else binutils;
libc = if targetPlatform != hostPlatform then libcCross else stdenv.cc.libc; libc = if targetPlatform != hostPlatform then libcCross else stdenv.cc.libc;
}; };
# legacy version, used for gnat bootstrapping # legacy version, used for gnat bootstrapping
@ -6422,6 +6442,17 @@ with pkgs;
libc = glibc; libc = glibc;
}; };
wrapBintoolsWith = { bintools, libc }: bintoolsWrapperFun {
nativeTools = targetPlatform == hostPlatform && stdenv.cc.nativeTools or false;
nativeLibc = targetPlatform == hostPlatform && stdenv.cc.nativeLibc or false;
nativePrefix = stdenv.cc.nativePrefix or "";
noLibc = (libc == null);
inherit bintools libc;
extraBuildCommands = "";
};
# prolog # prolog
yap = callPackage ../development/compilers/yap { }; yap = callPackage ../development/compilers/yap { };
@ -7003,13 +7034,19 @@ with pkgs;
then darwin.binutils then darwin.binutils
else binutils-raw; else binutils-raw;
binutils-raw = callPackage ../development/tools/misc/binutils { binutils-unwrapped = callPackage ../development/tools/misc/binutils {
# FHS sys dirs presumably only have stuff for the build platform # FHS sys dirs presumably only have stuff for the build platform
noSysDirs = (targetPlatform != buildPlatform) || noSysDirs; noSysDirs = (targetPlatform != buildPlatform) || noSysDirs;
}; };
binutils-raw = wrapBintoolsWith {
libc = if targetPlatform != hostPlatform then libcCross else stdenv.cc.libc;
bintools = binutils-unwrapped;
};
binutils_nogold = lowPrio (binutils-raw.override { binutils_nogold = lowPrio (binutils-raw.override {
bintools = binutils-raw.bintools.override {
gold = false; gold = false;
};
}); });
bison2 = callPackage ../development/tools/parsing/bison/2.x.nix { }; bison2 = callPackage ../development/tools/parsing/bison/2.x.nix { };

View File

@ -10,9 +10,15 @@ in
apple_sdk = callPackage ../os-specific/darwin/apple-sdk { }; apple_sdk = callPackage ../os-specific/darwin/apple-sdk { };
binutils = callPackage ../os-specific/darwin/binutils { binutils = pkgs.wrapBintoolsWith {
libc =
if pkgs.targetPlatform != pkgs.hostPlatform
then pkgs.libcCross
else pkgs.stdenv.cc.libc;
bintools = callPackage ../os-specific/darwin/binutils {
inherit (darwin) cctools; inherit (darwin) cctools;
}; };
};
cctools = callPackage ../os-specific/darwin/cctools/port.nix { cctools = callPackage ../os-specific/darwin/cctools/port.nix {
inherit (darwin) libobjc maloader; inherit (darwin) libobjc maloader;