Skip to content

Commit eae413d

Browse files
authored
Removed SDKROOT from the environment variables that are purged before building Swift and then prefer SDKROOT when determining -isysroot when building Ninja. (swiftlang#13829)
1 parent 71af76a commit eae413d

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

utils/build-script

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,13 @@ class BuildScriptInvocation(object):
412412
# Set an appropriate default umask.
413413
os.umask(0o022)
414414

415+
if 'SDKROOT' in os.environ:
416+
print('NOTE: Environment variable SDKROOT is set to "{}"'
417+
.format(os.environ['SDKROOT']))
418+
415419
# Unset environment variables that might affect how tools behave.
416420
for v in [
417421
'MAKEFLAGS',
418-
'SDKROOT',
419422
'MACOSX_DEPLOYMENT_TARGET',
420423
'IPHONEOS_DEPLOYMENT_TARGET',
421424
'TVOS_DEPLOYMENT_TARGET',

utils/swift_build_support/swift_build_support/products/ninja.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from . import product
2222
from .. import cache_util
2323
from .. import shell
24+
from .. import xcrun
2425

2526

2627
class Ninja(product.Product):
@@ -33,23 +34,22 @@ def do_build(self):
3334
return
3435

3536
env = None
36-
if platform.system() == "Darwin":
37-
from .. import xcrun
38-
sysroot = xcrun.sdk_path("macosx")
39-
osx_version_min = self.args.darwin_deployment_version_osx
37+
if platform.system() == 'Darwin':
38+
sysroot = os.environ.get('SDKROOT', xcrun.sdk_path('macosx'))
4039
assert sysroot is not None
40+
41+
osx_version_min = self.args.darwin_deployment_version_osx
4142
env = {
42-
"CXX": self.toolchain.cxx,
43-
"CFLAGS": (
44-
"-isysroot {sysroot} -mmacosx-version-min={osx_version}"
45-
).format(sysroot=sysroot, osx_version=osx_version_min),
46-
"LDFLAGS": (
47-
"-mmacosx-version-min={osx_version}"
48-
).format(osx_version=osx_version_min),
43+
'CXX': self.toolchain.cxx,
44+
'CFLAGS': ' '.join([
45+
'-isysroot', sysroot,
46+
'-mmacosx-version-min={}'.format(osx_version_min),
47+
]),
48+
'LDFLAGS': '-mmacosx-version-min={}'.format(osx_version_min),
4949
}
5050
elif self.toolchain.cxx:
5151
env = {
52-
"CXX": self.toolchain.cxx,
52+
'CXX': self.toolchain.cxx,
5353
}
5454

5555
# Ninja can only be built in-tree. Copy the source tree to the build

0 commit comments

Comments
 (0)