Merge pull request #304033 from sternenseemann/wrapper-cleanups
wrapCC, wrapBintools, stdenv: make Nix code a bit more consistent
This commit is contained in:
commit
0820a71359
@ -83,8 +83,7 @@ let
|
||||
replaceStrings
|
||||
;
|
||||
|
||||
stdenv = stdenvNoCC;
|
||||
inherit (stdenv) hostPlatform targetPlatform;
|
||||
inherit (stdenvNoCC) hostPlatform targetPlatform;
|
||||
|
||||
# Prefix for binaries. Customarily ends with a dash separator.
|
||||
#
|
||||
@ -138,7 +137,7 @@ let
|
||||
|
||||
in
|
||||
|
||||
stdenv.mkDerivation {
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = targetPrefix
|
||||
+ (if name != "" then name else "${bintoolsName}-wrapper");
|
||||
version = optionalString (bintools != null) bintoolsVersion;
|
||||
@ -346,7 +345,7 @@ stdenv.mkDerivation {
|
||||
done
|
||||
''
|
||||
|
||||
+ optionalString stdenv.targetPlatform.isDarwin ''
|
||||
+ optionalString targetPlatform.isDarwin ''
|
||||
echo "-arch ${targetPlatform.darwinArch}" >> $out/nix-support/libc-ldflags
|
||||
''
|
||||
|
||||
@ -363,7 +362,7 @@ stdenv.mkDerivation {
|
||||
###
|
||||
### Remove certain timestamps from final binaries
|
||||
###
|
||||
+ optionalString (stdenv.targetPlatform.isDarwin && !(bintools.isGNU or false)) ''
|
||||
+ optionalString (targetPlatform.isDarwin && !(bintools.isGNU or false)) ''
|
||||
echo "export ZERO_AR_DATE=1" >> $out/nix-support/setup-hook
|
||||
''
|
||||
|
||||
@ -380,9 +379,9 @@ stdenv.mkDerivation {
|
||||
###
|
||||
### Ensure consistent LC_VERSION_MIN_MACOSX
|
||||
###
|
||||
+ optionalString stdenv.targetPlatform.isDarwin (
|
||||
+ optionalString targetPlatform.isDarwin (
|
||||
let
|
||||
inherit (stdenv.targetPlatform)
|
||||
inherit (targetPlatform)
|
||||
darwinPlatform darwinSdkVersion
|
||||
darwinMinVersion darwinMinVersionVariable;
|
||||
in ''
|
||||
|
@ -82,9 +82,7 @@ let
|
||||
versionAtLeast
|
||||
;
|
||||
|
||||
inherit (stdenv) hostPlatform targetPlatform;
|
||||
|
||||
stdenv = stdenvNoCC;
|
||||
inherit (stdenvNoCC) hostPlatform targetPlatform;
|
||||
|
||||
includeFortifyHeaders' = if includeFortifyHeaders != null
|
||||
then includeFortifyHeaders
|
||||
@ -119,10 +117,10 @@ let
|
||||
|
||||
useGccForLibs = useCcForLibs
|
||||
&& libcxx == null
|
||||
&& !stdenv.targetPlatform.isDarwin
|
||||
&& !(stdenv.targetPlatform.useLLVM or false)
|
||||
&& !(stdenv.targetPlatform.useAndroidPrebuilt or false)
|
||||
&& !(stdenv.targetPlatform.isiOS or false)
|
||||
&& !targetPlatform.isDarwin
|
||||
&& !(targetPlatform.useLLVM or false)
|
||||
&& !(targetPlatform.useAndroidPrebuilt or false)
|
||||
&& !(targetPlatform.isiOS or false)
|
||||
&& gccForLibs != null;
|
||||
gccForLibs_solib = getLib gccForLibs
|
||||
+ optionalString (targetPlatform != hostPlatform) "/${targetPlatform.config}";
|
||||
@ -249,17 +247,17 @@ let
|
||||
then cc.hardeningUnsupportedFlagsByTargetPlatform targetPlatform
|
||||
else (cc.hardeningUnsupportedFlags or []);
|
||||
|
||||
darwinPlatformForCC = optionalString stdenv.targetPlatform.isDarwin (
|
||||
darwinPlatformForCC = optionalString targetPlatform.isDarwin (
|
||||
if (targetPlatform.darwinPlatform == "macos" && isGNU) then "macosx"
|
||||
else targetPlatform.darwinPlatform
|
||||
);
|
||||
|
||||
darwinMinVersion = optionalString stdenv.targetPlatform.isDarwin (
|
||||
stdenv.targetPlatform.darwinMinVersion
|
||||
darwinMinVersion = optionalString targetPlatform.isDarwin (
|
||||
targetPlatform.darwinMinVersion
|
||||
);
|
||||
|
||||
darwinMinVersionVariable = optionalString stdenv.targetPlatform.isDarwin
|
||||
stdenv.targetPlatform.darwinMinVersionVariable;
|
||||
darwinMinVersionVariable = optionalString targetPlatform.isDarwin
|
||||
targetPlatform.darwinMinVersionVariable;
|
||||
in
|
||||
|
||||
assert includeFortifyHeaders' -> fortify-headers != null;
|
||||
@ -272,7 +270,7 @@ assert nativeTools == bintools.nativeTools;
|
||||
assert nativeLibc == bintools.nativeLibc;
|
||||
assert nativePrefix == bintools.nativePrefix;
|
||||
|
||||
stdenv.mkDerivation {
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = targetPrefix
|
||||
+ (if name != "" then name else "${ccName}-wrapper");
|
||||
version = optionalString (cc != null) ccVersion;
|
||||
@ -426,7 +424,7 @@ stdenv.mkDerivation {
|
||||
../setup-hooks/role.bash
|
||||
] ++ optional (cc.langC or true) ./setup-hook.sh
|
||||
++ optional (cc.langFortran or false) ./fortran-hook.sh
|
||||
++ optional (targetPlatform.isWindows) (stdenv.mkDerivation {
|
||||
++ optional (targetPlatform.isWindows) (stdenvNoCC.mkDerivation {
|
||||
name = "win-dll-hook.sh";
|
||||
dontUnpack = true;
|
||||
installPhase = ''
|
||||
@ -479,8 +477,8 @@ stdenv.mkDerivation {
|
||||
# break `useLLVM` into.)
|
||||
+ optionalString (isClang
|
||||
&& targetPlatform.isLinux
|
||||
&& !(stdenv.targetPlatform.useAndroidPrebuilt or false)
|
||||
&& !(stdenv.targetPlatform.useLLVM or false)
|
||||
&& !(targetPlatform.useAndroidPrebuilt or false)
|
||||
&& !(targetPlatform.useLLVM or false)
|
||||
&& gccForLibs != null) (''
|
||||
echo "--gcc-toolchain=${gccForLibs}" >> $out/nix-support/cc-cflags
|
||||
|
||||
@ -689,7 +687,7 @@ stdenv.mkDerivation {
|
||||
done
|
||||
''
|
||||
|
||||
+ optionalString stdenv.targetPlatform.isDarwin ''
|
||||
+ optionalString targetPlatform.isDarwin ''
|
||||
echo "-arch ${targetPlatform.darwinArch}" >> $out/nix-support/cc-cflags
|
||||
''
|
||||
|
||||
|
@ -328,12 +328,12 @@ in
|
||||
assert isBuiltByBootstrapFilesCompiler prevStage.patchelf;
|
||||
stageFun prevStage {
|
||||
name = "bootstrap-stage-xgcc";
|
||||
overrides = final: prev: {
|
||||
overrides = self: super: {
|
||||
inherit (prevStage) ccWrapperStdenv coreutils gnugrep gettext bison texinfo zlib gnum4 perl patchelf;
|
||||
${localSystem.libc} = getLibc prevStage;
|
||||
gmp = prev.gmp.override { cxx = false; };
|
||||
gmp = super.gmp.override { cxx = false; };
|
||||
gcc-unwrapped =
|
||||
(prev.gcc-unwrapped.override (commonGccOverrides // {
|
||||
(super.gcc-unwrapped.override (commonGccOverrides // {
|
||||
# The most logical name for this package would be something like
|
||||
# "gcc-stage1". Unfortunately "stage" is already reserved for the
|
||||
# layers of stdenv, so using "stage" in the name of this package
|
||||
@ -376,7 +376,7 @@ in
|
||||
#
|
||||
configureFlags = (a.configureFlags or []) ++ [
|
||||
"--with-native-system-header-dir=/include"
|
||||
"--with-build-sysroot=${lib.getDev final.stdenv.cc.libc}"
|
||||
"--with-build-sysroot=${lib.getDev self.stdenv.cc.libc}"
|
||||
];
|
||||
|
||||
# This is a separate phase because gcc assembles its phase scripts
|
||||
|
@ -152,7 +152,7 @@ in
|
||||
inherit config overlays;
|
||||
stdenv = makeStdenv {
|
||||
inherit (prevStage) cc fetchurl;
|
||||
overrides = prev: final: { inherit (prevStage) fetchurl; };
|
||||
overrides = self: super: { inherit (prevStage) fetchurl; };
|
||||
} // {
|
||||
inherit (prevStage) fetchurl;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user