Skip to content

Commit 7f6f518

Browse files
committed
unix: set MACOSX_DEPLOYMENT_TARGET when building Python
See the inline comment. Python's configure isn't smart enough to pick up the value from cflags and we regressed the platform tag when we switched to cflags for minimum version targeting.
1 parent 97f08f0 commit 7f6f518

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

cpython-unix/build-cpython.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,15 @@ if [ "${PYBUILD_PLATFORM}" = "macos" ]; then
535535
exit 1
536536
fi
537537
fi
538+
539+
# Python's configure looks exclusively at MACOSX_DEPLOYMENT_TARGET for
540+
# determining the platform tag. We specify the minimum target via cflags
541+
# like -mmacosx-version-min but configure doesn't pick up on those. In
542+
# addition, configure isn't smart enough to look at environment variables
543+
# for other SDK targets to determine the OS version. So our hack here is
544+
# to expose MACOSX_DEPLOYMENT_TARGET everywhere so the value percolates
545+
# into platform tag.
546+
export MACOSX_DEPLOYMENT_TARGET="${APPLE_MIN_DEPLOYMENT_TARGET}"
538547
fi
539548

540549
if [ "${BUILD_TRIPLE}" != "${TARGET_TRIPLE}" ]; then

cpython-unix/build.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,51 +123,59 @@ def add_target_env(env, build_platform, target_triple, build_env):
123123
min_version_flags = [
124124
"-mmacosx-version-min=%s" % MACOSX_DEPLOYMENT_TARGET_ARM
125125
]
126+
env["APPLE_MIN_DEPLOYMENT_TARGET"] = MACOSX_DEPLOYMENT_TARGET_ARM
126127
elif target_triple == "aarch64-apple-ios":
127128
env["TARGET_TRIPLE"] = "aarch64-apple-ios"
128129
# TODO arm64e not supported by open source Clang.
129130
# TODO add arm7 / arm7s?
130131
arches = ["arm64"]
131132
sdk_platform = "iphoneos"
132133
min_version_flags = ["-mios-version-min=%s" % IPHONEOS_DEPLOYMENT_TARGET]
134+
env["APPLE_MIN_DEPLOYMENT_TARGET"] = IPHONEOS_DEPLOYMENT_TARGET
133135
elif target_triple == "arm64-apple-tvos":
134136
env["TARGET_TRIPLE"] = "arm64-apple-tvos"
135137
arches = ["arm64"]
136138
sdk_platform = "appletvos"
137139
min_version_flags = ["-mappletvos-version-min=%s" % TVOS_DEPLOYMENT_TARGET]
140+
env["APPLE_MIN_DEPLOYMENT_TARGET"] = TVOS_DEPLOYMENT_TARGET
138141
elif target_triple == "thumbv7k-apple-watchos":
139142
env["TARGET_TRIPLE"] = "thumbv7k-apple-watchos"
140143
arches = ["armv7k"]
141144
sdk_platform = "watchos"
142145
min_version_flags = ["-mwatchos-version-min=%s" % WATCHOS_DEPLOYMENT_TARGET]
146+
env["APPLE_MIN_DEPLOYMENT_TARGET"] = WATCHOS_DEPLOYMENT_TARGET
143147
elif target_triple == "x86_64-apple-darwin":
144148
env["TARGET_TRIPLE"] = "x86_64-apple-darwin"
145149
arches = ["x86_64"]
146150
sdk_platform = "macosx"
147151
min_version_flags = [
148152
"-mmacosx-version-min=%s" % MACOSX_DEPLOYMENT_TARGET_X86
149153
]
154+
env["APPLE_MIN_DEPLOYMENT_TARGET"] = MACOSX_DEPLOYMENT_TARGET_X86
150155
elif target_triple == "x86_64-apple-ios":
151156
env["TARGET_TRIPLE"] = "x86_64-apple-ios"
152157
arches = ["x86_64"]
153158
sdk_platform = "iphonesimulator"
154159
min_version_flags = [
155160
"-mios-simulator-version-min=%s" % IPHONEOS_DEPLOYMENT_TARGET,
156161
]
162+
env["APPLE_MIN_DEPLOYMENT_TARGET"] = IPHONEOS_DEPLOYMENT_TARGET
157163
elif target_triple == "x86_64-apple-tvos":
158164
env["TARGET_TRIPLE"] = "x86_64-apple-tvos"
159165
arches = ["x86_64"]
160166
sdk_platform = "appletvsimulator"
161167
min_version_flags = [
162168
"-mappletvsimulator-version-min=%s" % TVOS_DEPLOYMENT_TARGET
163169
]
170+
env["APPLE_MIN_DEPLOYMENT_TARGET"] = TVOS_DEPLOYMENT_TARGET
164171
elif target_triple == "x86_64-apple-watchos":
165172
env["TARGET_TRIPLE"] = "x86_64-apple-watchos"
166173
arches = ["x86_64"]
167174
sdk_platform = "watchsimulator"
168175
min_version_flags = [
169176
"-mwatchsimulator-version-min=%s" % WATCHOS_DEPLOYMENT_TARGET
170177
]
178+
env["APPLE_MIN_DEPLOYMENT_TARGET"] = WATCHOS_DEPLOYMENT_TARGET
171179
else:
172180
raise ValueError("unhandled target triple: %s" % target_triple)
173181

0 commit comments

Comments
 (0)