Skip to content

Commit

Permalink
[clang][modules] Built-in modules are not correctly enabled for Mac C…
Browse files Browse the repository at this point in the history
…atalyst (#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)
  • Loading branch information
ian-twilightcoder authored and tru committed Aug 26, 2024
1 parent 9301cd5 commit 9dc4bdf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
10 changes: 9 additions & 1 deletion clang/lib/Driver/ToolChains/Darwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2953,7 +2953,15 @@ static bool sdkSupportsBuiltinModules(
case Darwin::MacOS:
return SDKVersion >= VersionTuple(15U);
case Darwin::IPhoneOS:
return SDKVersion >= VersionTuple(18U);
switch (TargetEnvironment) {
case Darwin::MacCatalyst:
// Mac Catalyst uses `-target arm64-apple-ios18.0-macabi` so the platform
// is iOS, but it builds with the macOS SDK, so it's the macOS SDK version
// that's relevant.
return SDKVersion >= VersionTuple(15U);
default:
return SDKVersion >= VersionTuple(18U);
}
case Darwin::TvOS:
return SDKVersion >= VersionTuple(18U);
case Darwin::WatchOS:
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Driver/Inputs/MacOSX15.0.sdk/SDKSettings.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Version":"990.0", "MaximumDeploymentTarget": "99.0.99"}
{"Version":"15.0", "MaximumDeploymentTarget": "15.0.99"}
1 change: 1 addition & 0 deletions clang/test/Driver/Inputs/MacOSX15.1.sdk/SDKSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Version":"15.1", "MaximumDeploymentTarget": "15.1.99"}
3 changes: 3 additions & 0 deletions clang/test/Driver/darwin-builtin-modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@

// RUN: %clang -isysroot %S/Inputs/MacOSX15.0.sdk -target x86_64-apple-macos14.0 -### %s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE %s
// RUN: %clang -isysroot %S/Inputs/MacOSX15.0.sdk -target x86_64-apple-macos15.0 -### %s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE %s
// RUN: %clang -isysroot %S/Inputs/MacOSX15.0.sdk -target x86_64-apple-ios18.0-macabi -### %s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE %s
// 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
// 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
// RUN: %clang -isysroot %S/Inputs/DriverKit23.0.sdk -target arm64-apple-driverkit23.0 -### %s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE %s
// CHECK_FUTURE-NOT: -fbuiltin-headers-in-system-modules

0 comments on commit 9dc4bdf

Please sign in to comment.