about summary refs log tree commit diff
path: root/pkgs/build-support/bintools-wrapper
diff options
context:
space:
mode:
authorAndrew Childs <lorne@cons.org.nz>2021-04-10 13:11:28 +0900
committerAndrew Childs <lorne@cons.org.nz>2021-04-11 09:47:10 +0900
commit2a9b3b4943bea5d778da184828492e92512db324 (patch)
treea5dc618dcb779abb80ac71b341dbe6545d10e575 /pkgs/build-support/bintools-wrapper
parent8b59d52ca3b6157f4cac333e6576c76f1fa546e8 (diff)
cc-wrapper, bintools-wrapper: support MACOSX_DEPLOYMENT_TARGET with roles
In a typical build environment the toolchain will use the value of the
MACOSX_DEPLOYMENT_TARGET environment variable to determine the version
of macOS to support. When cross compiling there are two distinct
toolchains, but they will look at this single environment variable. To
avoid contamination, we always set the equivalent command line flag
which effectively disables the toolchain's internal handling.

Prior to this change, the MACOSX_DEPLOYMENT_TARGET variable was
ignored, and the toolchains always used the Nix platform
definition (`darwinMinVersion`) unless overridden with command line
arguments.

This change restores support for MACOSX_DEPLOYMENT_TARGET, and adds
nix-specific MACOSX_DEPLOYMENT_TARGET_FOR_BUILD and
MACOSX_DEPLOYMENT_TARGET_FOR_TARGET for cross compilation.
Diffstat (limited to 'pkgs/build-support/bintools-wrapper')
-rw-r--r--pkgs/build-support/bintools-wrapper/add-darwin-ldflags-before.sh6
1 files changed, 4 insertions, 2 deletions
diff --git a/pkgs/build-support/bintools-wrapper/add-darwin-ldflags-before.sh b/pkgs/build-support/bintools-wrapper/add-darwin-ldflags-before.sh
index 37c6881810d9a..318311e1be9d0 100644
--- a/pkgs/build-support/bintools-wrapper/add-darwin-ldflags-before.sh
+++ b/pkgs/build-support/bintools-wrapper/add-darwin-ldflags-before.sh
@@ -21,6 +21,8 @@ havePlatformVersionFlag=
 haveDarwinSDKVersion=
 haveDarwinPlatformVersion=
 
+mangleVarSingle MACOSX_DEPLOYMENT_TARGET ${role_suffixes[@]+"${role_suffixes[@]}"}
+
 n=0
 nParams=${#params[@]}
 while (( n < nParams )); do
@@ -59,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@ @darwinMinVersion@ @darwinSdkVersion@)
+        extraBefore+=(-platform_version @darwinPlatform@ "${MACOSX_DEPLOYMENT_TARGET_@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 @darwinMinVersion@)
+        extraBefore+=(-@darwinPlatform@_version_min "${MACOSX_DEPLOYMENT_TARGET_@suffixSalt@:-@darwinMinVersion@}")
     fi
 fi