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 https://github.com/tpoechtrager/cctools-port/blob/236a426c1205a3bfcf0dbb2e2faf2296f0a100e5/cctools/ld64/src/ld/PlatformSupport.cpp#L54-L55
This commit is contained in:
Andrew Childs
2021-04-11 09:47:10 +09:00
parent 2a9b3b4943
commit 6c4ce7960e
5 changed files with 17 additions and 7 deletions
@@ -21,7 +21,7 @@ havePlatformVersionFlag=
haveDarwinSDKVersion=
haveDarwinPlatformVersion=
mangleVarSingle MACOSX_DEPLOYMENT_TARGET ${role_suffixes[@]+"${role_suffixes[@]}"}
mangleVarSingle @darwinMinVersionVariable@ ${role_suffixes[@]+"${role_suffixes[@]}"}
n=0
nParams=${#params[@]}
@@ -61,12 +61,12 @@ done
if [ ! "$havePlatformVersionFlag" ]; then
if [ ! "$haveDarwinSDKVersion" ] && [ ! "$haveDarwinPlatformVersion" ]; then
# 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
# Add missing sdk version
extraBefore+=(-sdk_version @darwinSdkVersion@)
elif [ ! "$haveDarwinPlatformVersion" ]; then
# Add missing platform version
extraBefore+=(-@darwinPlatform@_version_min "${MACOSX_DEPLOYMENT_TARGET_@suffixSalt@:-@darwinMinVersion@}")
extraBefore+=(-@darwinPlatform@_version_min "${@darwinMinVersionVariable@_@suffixSalt@:-@darwinMinVersion@}")
fi
fi
@@ -327,11 +327,14 @@ stdenv.mkDerivation {
###
+ optionalString stdenv.targetPlatform.isDarwin (
let
inherit (stdenv.targetPlatform) darwinMinVersion darwinPlatform darwinSdkVersion;
inherit (stdenv.targetPlatform)
darwinPlatform darwinSdkVersion
darwinMinVersion darwinMinVersionVariable;
in ''
export darwinPlatform=${darwinPlatform}
export darwinMinVersion=${darwinMinVersion}
export darwinSdkVersion=${darwinSdkVersion}
export darwinMinVersionVariable=${darwinMinVersionVariable}
substituteAll ${./add-darwin-ldflags-before.sh} $out/nix-support/add-local-ldflags-before.sh
''
)