summary refs log tree commit diff
path: root/pkgs/build-support/wrapper-common
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/wrapper-common
parent8b59d52ca3b6157f4cac333e6576c76f1fa546e8 (diff)
downloadnixpkgs-2a9b3b4943bea5d778da184828492e92512db324.tar
nixpkgs-2a9b3b4943bea5d778da184828492e92512db324.tar.gz
nixpkgs-2a9b3b4943bea5d778da184828492e92512db324.tar.bz2
nixpkgs-2a9b3b4943bea5d778da184828492e92512db324.tar.lz
nixpkgs-2a9b3b4943bea5d778da184828492e92512db324.tar.xz
nixpkgs-2a9b3b4943bea5d778da184828492e92512db324.tar.zst
nixpkgs-2a9b3b4943bea5d778da184828492e92512db324.zip
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/wrapper-common')
-rw-r--r--pkgs/build-support/wrapper-common/utils.bash29
1 files changed, 29 insertions, 0 deletions
diff --git a/pkgs/build-support/wrapper-common/utils.bash b/pkgs/build-support/wrapper-common/utils.bash
index d164982b434..66b7c3f3e83 100644
--- a/pkgs/build-support/wrapper-common/utils.bash
+++ b/pkgs/build-support/wrapper-common/utils.bash
@@ -49,6 +49,35 @@ mangleVarBool() {
     done
 }
 
+# Combine a singular value from all roles. If multiple roles are being served,
+# and the value differs in these roles then the request is impossible to
+# satisfy and we abort immediately.
+mangleVarSingle() {
+    local var="$1"
+    shift
+    local -a role_suffixes=("$@")
+
+    local outputVar="${var}_@suffixSalt@"
+    for suffix in "${role_suffixes[@]}"; do
+        local inputVar="${var}${suffix}"
+        if [ -v "$inputVar" ]; then
+            if [ -v "$outputVar" ]; then
+                if [ "${!outputVar}" != "${!inputVar}" ]; then
+                    {
+                        echo "Multiple conflicting values defined for $outputVar"
+                        echo "Existing value is ${!outputVar}"
+                        echo "Attempting to set to ${!inputVar} via $inputVar"
+                    } >&2
+
+                    exit 1
+                fi
+            else
+                declare -gx ${outputVar}="${!inputVar}"
+            fi
+        fi
+    done
+}
+
 skip () {
     if (( "${NIX_DEBUG:-0}" >= 1 )); then
         echo "skipping impure path $1" >&2