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 (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.
  • Loading branch information
ian-twilightcoder authored Aug 20, 2024
1 parent 34a88bb commit b986438
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
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
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 b986438

Please sign in to comment.