Skip to content

Commit 1c1f422

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 17d8e65 commit 1c1f422

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Diff for: clang/lib/Driver/ToolChains/Darwin.cpp

+9-1
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:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"Version":"15.1", "MaximumDeploymentTarget": "15.1.99"}

Diff for: clang/test/Driver/darwin-builtin-modules.c

+3
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)