[clang] b986438 - [clang][modules] Built-in modules are not correctly enabled for Mac Catalyst (#104872)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 20 03:29:15 PDT 2024
Author: Ian Anderson
Date: 2024-08-20T03:29:11-07:00
New Revision: b9864387d9d00e1d4888181460d05dbc92364d75
URL: https://github.com/llvm/llvm-project/commit/b9864387d9d00e1d4888181460d05dbc92364d75
DIFF: https://github.com/llvm/llvm-project/commit/b9864387d9d00e1d4888181460d05dbc92364d75.diff
LOG: [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.
Added:
clang/test/Driver/Inputs/MacOSX15.1.sdk/SDKSettings.json
Modified:
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-builtin-modules.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index ee6890d5b98f0e..2550541a438481 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -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:
diff --git a/clang/test/Driver/Inputs/MacOSX15.1.sdk/SDKSettings.json b/clang/test/Driver/Inputs/MacOSX15.1.sdk/SDKSettings.json
new file mode 100644
index 00000000000000..d46295b2ab5a17
--- /dev/null
+++ b/clang/test/Driver/Inputs/MacOSX15.1.sdk/SDKSettings.json
@@ -0,0 +1 @@
+{"Version":"15.1", "MaximumDeploymentTarget": "15.1.99"}
diff --git a/clang/test/Driver/darwin-builtin-modules.c b/clang/test/Driver/darwin-builtin-modules.c
index ec515133be8aba..4564d7317d7abe 100644
--- a/clang/test/Driver/darwin-builtin-modules.c
+++ b/clang/test/Driver/darwin-builtin-modules.c
@@ -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
More information about the cfe-commits
mailing list