bintools-wrapper, cc-wrapper: parameterize darwin min version variable
These variables are the ones that the standard toolchain uses, so we
should use those and not always use MACOSX_DEPLOYMENT_TARGET.
See 236a426c12/cctools/ld64/src/ld/PlatformSupport.cpp (L54-L55)
This commit is contained in:
parent
2a9b3b4943
commit
6c4ce7960e
|
@ -120,6 +120,10 @@ rec {
|
||||||
# platforms define the old name "sdkVer".
|
# platforms define the old name "sdkVer".
|
||||||
darwinSdkVersion = final.sdkVer or "10.12";
|
darwinSdkVersion = final.sdkVer or "10.12";
|
||||||
darwinMinVersion = final.darwinSdkVersion;
|
darwinMinVersion = final.darwinSdkVersion;
|
||||||
|
darwinMinVersionVariable =
|
||||||
|
if final.isMacOS then "MACOSX_DEPLOYMENT_TARGET"
|
||||||
|
else if final.isiOS then "IPHONEOS_DEPLOYMENT_TARGET"
|
||||||
|
else null;
|
||||||
|
|
||||||
emulator = pkgs: let
|
emulator = pkgs: let
|
||||||
qemu-user = pkgs.qemu.override {
|
qemu-user = pkgs.qemu.override {
|
||||||
|
|
|
@ -21,7 +21,7 @@ havePlatformVersionFlag=
|
||||||
haveDarwinSDKVersion=
|
haveDarwinSDKVersion=
|
||||||
haveDarwinPlatformVersion=
|
haveDarwinPlatformVersion=
|
||||||
|
|
||||||
mangleVarSingle MACOSX_DEPLOYMENT_TARGET ${role_suffixes[@]+"${role_suffixes[@]}"}
|
mangleVarSingle @darwinMinVersionVariable@ ${role_suffixes[@]+"${role_suffixes[@]}"}
|
||||||
|
|
||||||
n=0
|
n=0
|
||||||
nParams=${#params[@]}
|
nParams=${#params[@]}
|
||||||
|
@ -61,12 +61,12 @@ done
|
||||||
if [ ! "$havePlatformVersionFlag" ]; then
|
if [ ! "$havePlatformVersionFlag" ]; then
|
||||||
if [ ! "$haveDarwinSDKVersion" ] && [ ! "$haveDarwinPlatformVersion" ]; then
|
if [ ! "$haveDarwinSDKVersion" ] && [ ! "$haveDarwinPlatformVersion" ]; then
|
||||||
# Nothing provided. Use the modern "-platform_version" to set both.
|
# Nothing provided. Use the modern "-platform_version" to set both.
|
||||||
extraBefore+=(-platform_version @darwinPlatform@ "${MACOSX_DEPLOYMENT_TARGET_@suffixSalt@:-@darwinMinVersion@}" @darwinSdkVersion@)
|
extraBefore+=(-platform_version @darwinPlatform@ "${@darwinMinVersionVariable@_@suffixSalt@:-@darwinMinVersion@}" @darwinSdkVersion@)
|
||||||
elif [ ! "$haveDarwinSDKVersion" ]; then
|
elif [ ! "$haveDarwinSDKVersion" ]; then
|
||||||
# Add missing sdk version
|
# Add missing sdk version
|
||||||
extraBefore+=(-sdk_version @darwinSdkVersion@)
|
extraBefore+=(-sdk_version @darwinSdkVersion@)
|
||||||
elif [ ! "$haveDarwinPlatformVersion" ]; then
|
elif [ ! "$haveDarwinPlatformVersion" ]; then
|
||||||
# Add missing platform version
|
# Add missing platform version
|
||||||
extraBefore+=(-@darwinPlatform@_version_min "${MACOSX_DEPLOYMENT_TARGET_@suffixSalt@:-@darwinMinVersion@}")
|
extraBefore+=(-@darwinPlatform@_version_min "${@darwinMinVersionVariable@_@suffixSalt@:-@darwinMinVersion@}")
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -327,11 +327,14 @@ stdenv.mkDerivation {
|
||||||
###
|
###
|
||||||
+ optionalString stdenv.targetPlatform.isDarwin (
|
+ optionalString stdenv.targetPlatform.isDarwin (
|
||||||
let
|
let
|
||||||
inherit (stdenv.targetPlatform) darwinMinVersion darwinPlatform darwinSdkVersion;
|
inherit (stdenv.targetPlatform)
|
||||||
|
darwinPlatform darwinSdkVersion
|
||||||
|
darwinMinVersion darwinMinVersionVariable;
|
||||||
in ''
|
in ''
|
||||||
export darwinPlatform=${darwinPlatform}
|
export darwinPlatform=${darwinPlatform}
|
||||||
export darwinMinVersion=${darwinMinVersion}
|
export darwinMinVersion=${darwinMinVersion}
|
||||||
export darwinSdkVersion=${darwinSdkVersion}
|
export darwinSdkVersion=${darwinSdkVersion}
|
||||||
|
export darwinMinVersionVariable=${darwinMinVersionVariable}
|
||||||
substituteAll ${./add-darwin-ldflags-before.sh} $out/nix-support/add-local-ldflags-before.sh
|
substituteAll ${./add-darwin-ldflags-before.sh} $out/nix-support/add-local-ldflags-before.sh
|
||||||
''
|
''
|
||||||
)
|
)
|
||||||
|
|
|
@ -68,9 +68,9 @@ fi
|
||||||
# Only add darwin min version flag if a default darwin min version is set,
|
# Only add darwin min version flag if a default darwin min version is set,
|
||||||
# which is a signal that we're targetting darwin.
|
# which is a signal that we're targetting darwin.
|
||||||
if [ "@darwinMinVersion@" ]; then
|
if [ "@darwinMinVersion@" ]; then
|
||||||
mangleVarSingle MACOSX_DEPLOYMENT_TARGET ${role_suffixes[@]+"${role_suffixes[@]}"}
|
mangleVarSingle @darwinMinVersionVariable@ ${role_suffixes[@]+"${role_suffixes[@]}"}
|
||||||
|
|
||||||
NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@="-m@darwinPlatformForCC@-version-min=${MACOSX_DEPLOYMENT_TARGET_@suffixSalt@:-@darwinMinVersion@} $NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@"
|
NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@="-m@darwinPlatformForCC@-version-min=${@darwinMinVersionVariable@_@suffixSalt@:-@darwinMinVersion@} $NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# That way forked processes will not extend these environment variables again.
|
# That way forked processes will not extend these environment variables again.
|
||||||
|
|
|
@ -109,6 +109,9 @@ let
|
||||||
darwinMinVersion = optionalString stdenv.targetPlatform.isDarwin (
|
darwinMinVersion = optionalString stdenv.targetPlatform.isDarwin (
|
||||||
stdenv.targetPlatform.darwinMinVersion
|
stdenv.targetPlatform.darwinMinVersion
|
||||||
);
|
);
|
||||||
|
|
||||||
|
darwinMinVersionVariable = optionalString stdenv.targetPlatform.isDarwin
|
||||||
|
stdenv.targetPlatform.darwinMinVersionVariable;
|
||||||
in
|
in
|
||||||
|
|
||||||
# Ensure bintools matches
|
# Ensure bintools matches
|
||||||
|
@ -131,7 +134,7 @@ stdenv.mkDerivation {
|
||||||
gnugrep_bin = if nativeTools then "" else gnugrep;
|
gnugrep_bin = if nativeTools then "" else gnugrep;
|
||||||
|
|
||||||
inherit targetPrefix suffixSalt;
|
inherit targetPrefix suffixSalt;
|
||||||
inherit darwinPlatformForCC darwinMinVersion;
|
inherit darwinPlatformForCC darwinMinVersion darwinMinVersionVariable;
|
||||||
|
|
||||||
outputs = [ "out" ] ++ optionals propagateDoc [ "man" "info" ];
|
outputs = [ "out" ] ++ optionals propagateDoc [ "man" "info" ];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue