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.
This commit is contained in:
Andrew Childs
2021-04-11 09:47:10 +09:00
parent 8b59d52ca3
commit 2a9b3b4943
4 changed files with 55 additions and 12 deletions
@@ -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