Skip to content

Commit 7579290

Browse files
[clang][modules] Built-in modules are not correctly enabled for Mac Catalyst (llvm#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 4447f46 commit 7579290

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
@@ -3016,7 +3016,15 @@ static bool sdkSupportsBuiltinModules(
30163016
case Darwin::MacOS:
30173017
return SDKVersion >= VersionTuple(15U);
30183018
case Darwin::IPhoneOS:
3019-
return SDKVersion >= VersionTuple(18U);
3019+
switch (TargetEnvironment) {
3020+
case Darwin::MacCatalyst:
3021+
// Mac Catalyst uses `-target arm64-apple-ios18.0-macabi` so the platform
3022+
// is iOS, but it builds with the macOS SDK, so it's the macOS SDK version
3023+
// that's relevant.
3024+
return SDKVersion >= VersionTuple(15U);
3025+
default:
3026+
return SDKVersion >= VersionTuple(18U);
3027+
}
30203028
case Darwin::TvOS:
30213029
return SDKVersion >= VersionTuple(18U);
30223030
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)