|
8 | 8 | import os
|
9 | 9 | import pathlib
|
10 | 10 | import platform
|
| 11 | +import re |
11 | 12 | import subprocess
|
12 | 13 | import sys
|
13 | 14 | import tempfile
|
|
42 | 43 | SUPPORT = ROOT / "cpython-unix"
|
43 | 44 | TARGETS_CONFIG = SUPPORT / "targets.yml"
|
44 | 45 |
|
45 |
| -# Target older macOS on x86 for maximum run-time compatibility. |
46 |
| -MACOSX_DEPLOYMENT_TARGET_X86 = "10.9" |
47 |
| - |
48 |
| -# ARM macOS only supports 11.0+, so we can use a newer target. |
49 |
| -MACOSX_DEPLOYMENT_TARGET_ARM = "11.0" |
50 |
| - |
51 |
| -IPHONEOS_DEPLOYMENT_TARGET = "12.3" |
52 |
| - |
53 |
| -TVOS_DEPLOYMENT_TARGET = "12.3" |
54 |
| - |
55 |
| -WATCHOS_DEPLOYMENT_TARGET = "7.0" |
56 |
| - |
57 | 46 |
|
58 | 47 | def install_sccache(build_env):
|
59 | 48 | """Attempt to install sccache into the build environment.
|
@@ -119,50 +108,35 @@ def add_target_env(env, build_platform, target_triple, build_env):
|
119 | 108 | else:
|
120 | 109 | raise Exception("unhandled macOS machine value: %s" % machine)
|
121 | 110 |
|
| 111 | + # Sniff out the Apple SDK minimum deployment target from cflags and |
| 112 | + # export in its own variable. This is used by CPython's configure, as |
| 113 | + # it doesn't sniff the cflag. |
| 114 | + for flag in extra_target_cflags: |
| 115 | + m = re.search("-version-min=(.*)$", flag) |
| 116 | + if m: |
| 117 | + env["APPLE_MIN_DEPLOYMENT_TARGET"] = m.group(1) |
| 118 | + break |
| 119 | + else: |
| 120 | + raise Exception("could not find minimum Apple SDK version in cflags") |
| 121 | + |
122 | 122 | if target_triple == "aarch64-apple-darwin":
|
123 | 123 | sdk_platform = "macosx"
|
124 |
| - min_version_flags = [ |
125 |
| - "-mmacosx-version-min=%s" % MACOSX_DEPLOYMENT_TARGET_ARM |
126 |
| - ] |
127 |
| - env["APPLE_MIN_DEPLOYMENT_TARGET"] = MACOSX_DEPLOYMENT_TARGET_ARM |
128 | 124 | elif target_triple == "aarch64-apple-ios":
|
129 | 125 | # TODO arm64e not supported by open source Clang.
|
130 | 126 | # TODO add arm7 / arm7s?
|
131 | 127 | sdk_platform = "iphoneos"
|
132 |
| - min_version_flags = ["-mios-version-min=%s" % IPHONEOS_DEPLOYMENT_TARGET] |
133 |
| - env["APPLE_MIN_DEPLOYMENT_TARGET"] = IPHONEOS_DEPLOYMENT_TARGET |
134 | 128 | elif target_triple == "arm64-apple-tvos":
|
135 | 129 | sdk_platform = "appletvos"
|
136 |
| - min_version_flags = ["-mappletvos-version-min=%s" % TVOS_DEPLOYMENT_TARGET] |
137 |
| - env["APPLE_MIN_DEPLOYMENT_TARGET"] = TVOS_DEPLOYMENT_TARGET |
138 | 130 | elif target_triple == "thumbv7k-apple-watchos":
|
139 | 131 | sdk_platform = "watchos"
|
140 |
| - min_version_flags = ["-mwatchos-version-min=%s" % WATCHOS_DEPLOYMENT_TARGET] |
141 |
| - env["APPLE_MIN_DEPLOYMENT_TARGET"] = WATCHOS_DEPLOYMENT_TARGET |
142 | 132 | elif target_triple == "x86_64-apple-darwin":
|
143 | 133 | sdk_platform = "macosx"
|
144 |
| - min_version_flags = [ |
145 |
| - "-mmacosx-version-min=%s" % MACOSX_DEPLOYMENT_TARGET_X86 |
146 |
| - ] |
147 |
| - env["APPLE_MIN_DEPLOYMENT_TARGET"] = MACOSX_DEPLOYMENT_TARGET_X86 |
148 | 134 | elif target_triple == "x86_64-apple-ios":
|
149 | 135 | sdk_platform = "iphonesimulator"
|
150 |
| - min_version_flags = [ |
151 |
| - "-mios-simulator-version-min=%s" % IPHONEOS_DEPLOYMENT_TARGET, |
152 |
| - ] |
153 |
| - env["APPLE_MIN_DEPLOYMENT_TARGET"] = IPHONEOS_DEPLOYMENT_TARGET |
154 | 136 | elif target_triple == "x86_64-apple-tvos":
|
155 | 137 | sdk_platform = "appletvsimulator"
|
156 |
| - min_version_flags = [ |
157 |
| - "-mappletvsimulator-version-min=%s" % TVOS_DEPLOYMENT_TARGET |
158 |
| - ] |
159 |
| - env["APPLE_MIN_DEPLOYMENT_TARGET"] = TVOS_DEPLOYMENT_TARGET |
160 | 138 | elif target_triple == "x86_64-apple-watchos":
|
161 | 139 | sdk_platform = "watchsimulator"
|
162 |
| - min_version_flags = [ |
163 |
| - "-mwatchsimulator-version-min=%s" % WATCHOS_DEPLOYMENT_TARGET |
164 |
| - ] |
165 |
| - env["APPLE_MIN_DEPLOYMENT_TARGET"] = WATCHOS_DEPLOYMENT_TARGET |
166 | 140 | else:
|
167 | 141 | raise ValueError("unhandled target triple: %s" % target_triple)
|
168 | 142 |
|
@@ -207,8 +181,6 @@ def add_target_env(env, build_platform, target_triple, build_env):
|
207 | 181 |
|
208 | 182 | extra_target_cflags.extend(["-isysroot", sdk_path])
|
209 | 183 | extra_target_ldflags.extend(["-isysroot", sdk_path])
|
210 |
| - extra_target_cflags.extend(min_version_flags) |
211 |
| - extra_target_ldflags.extend(min_version_flags) |
212 | 184 |
|
213 | 185 | # The host SDK may be for a different platform from the target SDK.
|
214 | 186 | # Resolve that separately.
|
|
0 commit comments