binutils-wrapper: Import separately from cc-wrapper

This commit is contained in:
John Ericson 2017-08-26 11:43:30 -04:00
parent 3f30cffa55
commit dbf6d20d64
13 changed files with 95 additions and 55 deletions

View File

@ -84,7 +84,7 @@ stdenv.mkDerivation {
outputs = [ "out" "man" ]; outputs = [ "out" "man" ];
passthru = { passthru = {
inherit libc nativeTools nativeLibc nativePrefix prefix; inherit binutils libc nativeTools nativeLibc nativePrefix prefix;
emacsBufferSetup = pkgs: '' emacsBufferSetup = pkgs: ''
; We should handle propagation here too ; We should handle propagation here too

View File

@ -6,18 +6,17 @@
# compiler and the linker just "work". # compiler and the linker just "work".
{ name ? "", stdenv, nativeTools, noLibc ? false, nativeLibc, nativePrefix ? "" { name ? "", stdenv, nativeTools, noLibc ? false, nativeLibc, nativePrefix ? ""
, cc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? stdenv.shell , cc ? null, libc ? null, binutils, coreutils ? null, shell ? stdenv.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 }:
} @ args:
with stdenv.lib; with stdenv.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);
@ -27,17 +26,6 @@ assert cc.langVhdl or false -> zlib != null;
let let
inherit (stdenv) hostPlatform targetPlatform; inherit (stdenv) hostPlatform targetPlatform;
binutils = import ../binutils-wrapper {
inherit (args) binutils;
inherit # name
stdenv 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

@ -50,7 +50,7 @@ in stdenv.mkDerivation rec {
"-DLLVM_BUILD_TESTS=ON" "-DLLVM_BUILD_TESTS=ON"
"-DLLVM_ENABLE_FFI=ON" "-DLLVM_ENABLE_FFI=ON"
"-DLLVM_REQUIRES_RTTI=1" "-DLLVM_REQUIRES_RTTI=1"
"-DLLVM_BINUTILS_INCDIR=${binutils.dev or binutils}/include" "-DLLVM_BINUTILS_INCDIR=${binutils.binutils.dev or binutils.binutils}/include"
"-DCMAKE_CXX_FLAGS=-std=c++11" "-DCMAKE_CXX_FLAGS=-std=c++11"
] ++ stdenv.lib.optional (!stdenv.isDarwin) "-DBUILD_SHARED_LIBS=ON"; ] ++ stdenv.lib.optional (!stdenv.isDarwin) "-DBUILD_SHARED_LIBS=ON";

View File

@ -47,7 +47,7 @@ in stdenv.mkDerivation rec {
] ++ stdenv.lib.optional enableSharedLibraries ] ++ stdenv.lib.optional enableSharedLibraries
"-DBUILD_SHARED_LIBS=ON" "-DBUILD_SHARED_LIBS=ON"
++ stdenv.lib.optional (!isDarwin) ++ stdenv.lib.optional (!isDarwin)
"-DLLVM_BINUTILS_INCDIR=${binutils.dev}/include" "-DLLVM_BINUTILS_INCDIR=${binutils.binutils.dev}/include"
++ stdenv.lib.optionals ( isDarwin) [ ++ stdenv.lib.optionals ( isDarwin) [
"-DCMAKE_CXX_FLAGS=-stdlib=libc++" "-DCMAKE_CXX_FLAGS=-stdlib=libc++"
"-DCAN_TARGET_i386=false" "-DCAN_TARGET_i386=false"

View File

@ -67,7 +67,7 @@ in stdenv.mkDerivation rec {
] ++ stdenv.lib.optional enableSharedLibraries ] ++ stdenv.lib.optional enableSharedLibraries
"-DBUILD_SHARED_LIBS=ON" "-DBUILD_SHARED_LIBS=ON"
++ stdenv.lib.optional (!isDarwin) ++ stdenv.lib.optional (!isDarwin)
"-DLLVM_BINUTILS_INCDIR=${binutils.dev}/include" "-DLLVM_BINUTILS_INCDIR=${binutils.binutils.dev}/include"
++ stdenv.lib.optionals ( isDarwin) [ ++ stdenv.lib.optionals ( isDarwin) [
"-DLLVM_ENABLE_LIBCXX=ON" "-DLLVM_ENABLE_LIBCXX=ON"
"-DCAN_TARGET_i386=false" "-DCAN_TARGET_i386=false"

View File

@ -62,7 +62,7 @@ in stdenv.mkDerivation rec {
] ++ stdenv.lib.optional enableSharedLibraries [ ] ++ stdenv.lib.optional enableSharedLibraries [
"-DLLVM_LINK_LLVM_DYLIB=ON" "-DLLVM_LINK_LLVM_DYLIB=ON"
] ++ stdenv.lib.optional (!isDarwin) ] ++ stdenv.lib.optional (!isDarwin)
"-DLLVM_BINUTILS_INCDIR=${binutils.dev}/include" "-DLLVM_BINUTILS_INCDIR=${binutils.binutils.dev}/include"
++ stdenv.lib.optionals ( isDarwin) [ ++ stdenv.lib.optionals ( isDarwin) [
"-DLLVM_ENABLE_LIBCXX=ON" "-DLLVM_ENABLE_LIBCXX=ON"
"-DCAN_TARGET_i386=false" "-DCAN_TARGET_i386=false"

View File

@ -106,7 +106,7 @@ in stdenv.mkDerivation rec {
] ++ stdenv.lib.optional enableSharedLibraries [ ] ++ stdenv.lib.optional enableSharedLibraries [
"-DLLVM_LINK_LLVM_DYLIB=ON" "-DLLVM_LINK_LLVM_DYLIB=ON"
] ++ stdenv.lib.optional (!isDarwin) ] ++ stdenv.lib.optional (!isDarwin)
"-DLLVM_BINUTILS_INCDIR=${binutils.dev}/include" "-DLLVM_BINUTILS_INCDIR=${binutils.binutils.dev}/include"
++ stdenv.lib.optionals (isDarwin) [ ++ stdenv.lib.optionals (isDarwin) [
"-DLLVM_ENABLE_LIBCXX=ON" "-DLLVM_ENABLE_LIBCXX=ON"
"-DCAN_TARGET_i386=false" "-DCAN_TARGET_i386=false"

View File

@ -90,7 +90,7 @@ in stdenv.mkDerivation rec {
"-DSPHINX_WARNINGS_AS_ERRORS=OFF" "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
] ]
++ stdenv.lib.optional (!isDarwin) ++ stdenv.lib.optional (!isDarwin)
"-DLLVM_BINUTILS_INCDIR=${binutils.dev}/include" "-DLLVM_BINUTILS_INCDIR=${binutils.binutils.dev}/include"
++ stdenv.lib.optionals (isDarwin) [ ++ stdenv.lib.optionals (isDarwin) [
"-DLLVM_ENABLE_LIBCXX=ON" "-DLLVM_ENABLE_LIBCXX=ON"
"-DCAN_TARGET_i386=false" "-DCAN_TARGET_i386=false"

View File

@ -42,7 +42,7 @@ stdenv.mkDerivation rec {
cmakeFlags = with stdenv; [ cmakeFlags = with stdenv; [
"-DLLVM_ENABLE_FFI=ON" "-DLLVM_ENABLE_FFI=ON"
"-DLLVM_BINUTILS_INCDIR=${binutils.dev}/include" "-DLLVM_BINUTILS_INCDIR=${binutils.binutils.dev}/include"
"-DCMAKE_CXX_FLAGS=-std=c++11" "-DCMAKE_CXX_FLAGS=-std=c++11"
] ++ stdenv.lib.optional (!isDarwin) "-DBUILD_SHARED_LIBS=ON"; ] ++ stdenv.lib.optional (!isDarwin) "-DBUILD_SHARED_LIBS=ON";

View File

@ -63,10 +63,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; };
binutils = import ../../build-support/binutils-wrapper {
inherit shell;
inherit (last) stdenv;
nativeTools = false;
nativeLibc = false;
inherit buildPackages coreutils gnugrep;
libc = last.pkgs.darwin.Libsystem;
binutils = { name = "binutils-9.9.9"; outPath = bootstrapTools; };
};
cc = if isNull last then "/dev/null" else import ../../build-support/cc-wrapper {
inherit shell;
inherit (last) stdenv;
nativeTools = false;
nativeLibc = false;
inherit buildPackages coreutils gnugrep binutils;
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.binutils
]; ];
name = "stdenv-darwin-boot-${toString step}"; name = "stdenv-darwin-boot-${toString step}";
@ -75,24 +105,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) stdenv;
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
@ -350,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-raw.dev binutils gettext binutils-raw.binutils.out binutils-raw.binutils.dev binutils binutils.binutils
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

@ -143,7 +143,16 @@ in
''; '';
}; };
gcc-unwrapped = bootstrapTools; gcc-unwrapped = bootstrapTools;
binutils = bootstrapTools; binutils = import ../../build-support/binutils-wrapper {
nativeTools = false;
nativeLibc = false;
buildPackages = { };
libc = self.glibc;
inherit (self) coreutils gnugrep;
binutils = bootstrapTools;
name = "bootstrap-binutils-wrapper";
stdenv = self.stdenv;
};
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;
@ -299,8 +322,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.binutils 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 +333,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 (system == "aarch64-linux") ++ lib.optionals (system == "aarch64-linux")
[ prevStage.updateAutotoolsGnuConfigScriptsHook prevStage.gnu-config ]; [ prevStage.updateAutotoolsGnuConfigScriptsHook prevStage.gnu-config ];

View File

@ -5223,7 +5223,9 @@ with pkgs;
clang-sierraHack = clang.override { clang-sierraHack = clang.override {
name = "clang-wrapper-with-reexport-hack"; name = "clang-wrapper-with-reexport-hack";
useMacosReexportHack = true; binutils = clang.binutils.override {
useMacosReexportHack = true;
};
}; };
clang_4 = llvmPackages_4.clang; clang_4 = llvmPackages_4.clang;
@ -6115,6 +6117,7 @@ with pkgs;
}; };
ccWrapperFun = callPackage ../build-support/cc-wrapper; ccWrapperFun = callPackage ../build-support/cc-wrapper;
binutilsWrapperFun = callPackage ../build-support/binutils-wrapper;
wrapCC = wrapCCWith stdenv.cc.libc ""; wrapCC = wrapCCWith stdenv.cc.libc "";
# legacy version, used for gnat bootstrapping # legacy version, used for gnat bootstrapping
@ -6140,6 +6143,15 @@ with pkgs;
inherit cc binutils libc shell name; inherit cc binutils libc shell name;
}; };
wrapBinutils = baseBinutils: binutilsWrapperFun {
nativeTools = stdenv.cc.nativeTools or false;
nativeLibc = stdenv.cc.nativeLibc or false;
nativePrefix = stdenv.cc.nativePrefix or "";
libc = stdenv.cc.libc;
binutils = baseBinutils;
extraBuildCommands = "";
};
# prolog # prolog
yap = callPackage ../development/compilers/yap { }; yap = callPackage ../development/compilers/yap { };
@ -6690,13 +6702,15 @@ with pkgs;
then darwin.binutils then darwin.binutils
else binutils-raw; else binutils-raw;
binutils-raw = callPackage ../development/tools/misc/binutils { binutils-raw = wrapBinutils (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_nogold = lowPrio (binutils-raw.override { binutils_nogold = lowPrio (binutils-raw.override {
gold = false; binutils = binutils-raw.binutils.override {
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,9 @@ 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.wrapBinutils (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;