Skip to content

Commit a566c12

Browse files
[cherry-pick swift/release/6.0][clang][modules] Built-in modules are not correctly enabled for Mac Catalyst
Mac Catalyst is the iOS platform, but it builds against the macOS SDK and so it needs to be checking the macOS SDK version instead of the iOS one. Add tests against a greater-than SDK version just to make sure this works beyond the initially supporting SDKs. rdar://116490661
1 parent 69b41f2 commit a566c12

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3111,7 +3111,15 @@ static bool sdkSupportsBuiltinModules(
31113111
case Darwin::MacOS:
31123112
return SDKVersion >= VersionTuple(15U);
31133113
case Darwin::IPhoneOS:
3114-
return SDKVersion >= VersionTuple(18U);
3114+
switch (TargetEnvironment) {
3115+
case Darwin::MacCatalyst:
3116+
// Mac Catalyst uses `-target arm64-apple-ios18.0-macabi` so the platform
3117+
// is iOS, but it builds with the macOS SDK, so it's the macOS SDK version
3118+
// that's relevant.
3119+
return SDKVersion >= VersionTuple(15U);
3120+
default:
3121+
return SDKVersion >= VersionTuple(18U);
3122+
}
31153123
case Darwin::TvOS:
31163124
return SDKVersion >= VersionTuple(18U);
31173125
case Darwin::WatchOS:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"Version":"15.1", "MaximumDeploymentTarget": "15.1.99"}

clang/test/Driver/darwin-builtin-modules.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@
88

99
// RUN: %clang -isysroot %S/Inputs/MacOSX15.0.sdk -target x86_64-apple-macos14.0 -### %s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE %s
1010
// RUN: %clang -isysroot %S/Inputs/MacOSX15.0.sdk -target x86_64-apple-macos15.0 -### %s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE %s
11+
// RUN: %clang -isysroot %S/Inputs/MacOSX15.0.sdk -target x86_64-apple-ios18.0-macabi -### %s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE %s
12+
// RUN: %clang -isysroot %S/Inputs/MacOSX15.1.sdk -target x86_64-apple-macos15.1 -darwin-target-variant x86_64-apple-ios18.1-macabi -### %s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE %s
13+
// RUN: %clang -isysroot %S/Inputs/MacOSX15.1.sdk -target x86_64-apple-ios18.1-macabi -darwin-target-variant x86_64-apple-macos15.1 -### %s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE %s
1114
// RUN: %clang -isysroot %S/Inputs/DriverKit23.0.sdk -target arm64-apple-driverkit23.0 -### %s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE %s
1215
// CHECK_FUTURE-NOT: -fbuiltin-headers-in-system-modules

0 commit comments

Comments
 (0)