Skip to content

Commit 9dc4bdf

Browse files
ian-twilightcodertru
authored andcommitted
[clang][modules] Built-in modules are not correctly enabled for Mac Catalyst (#104872)
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. (cherry picked from commit b986438)
1 parent 9301cd5 commit 9dc4bdf

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2953,7 +2953,15 @@ static bool sdkSupportsBuiltinModules(
29532953
case Darwin::MacOS:
29542954
return SDKVersion >= VersionTuple(15U);
29552955
case Darwin::IPhoneOS:
2956-
return SDKVersion >= VersionTuple(18U);
2956+
switch (TargetEnvironment) {
2957+
case Darwin::MacCatalyst:
2958+
// Mac Catalyst uses `-target arm64-apple-ios18.0-macabi` so the platform
2959+
// is iOS, but it builds with the macOS SDK, so it's the macOS SDK version
2960+
// that's relevant.
2961+
return SDKVersion >= VersionTuple(15U);
2962+
default:
2963+
return SDKVersion >= VersionTuple(18U);
2964+
}
29572965
case Darwin::TvOS:
29582966
return SDKVersion >= VersionTuple(18U);
29592967
case Darwin::WatchOS:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"Version":"990.0", "MaximumDeploymentTarget": "99.0.99"}
1+
{"Version":"15.0", "MaximumDeploymentTarget": "15.0.99"}
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)