[clang] [llvm] [clang][driver][darwin] Base the system prefix on the SDK, not the target (PR #171970)

Cyndy Ishida via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 19 12:05:00 PST 2025


================
@@ -78,6 +78,43 @@ TEST(DarwinSDKInfo, VersionMappingParseError) {
           .has_value());
 }
 
+TEST(DarwinSDKInfo, SystemPrefix) {
+  llvm::json::Object SDKSettings({{"CanonicalName", "macosx26.0"},
+                                  {"Version", "26.0"},
+                                  {"MaximumDeploymentTarget", "26.0.99"}});
+  llvm::json::Object SupportedTargets;
+  llvm::json::Object MacOS({{"Archs", {"x86_64", "arm64"}},
+                            {"LLVMTargetTripleVendor", "apple"},
+                            {"LLVMTargetTripleSys", "macos"},
+                            {"LLVMTargetTripleEnvironment", ""},
+                            {"SystemPrefix", "/System/macOSSupport"}});
+  llvm::json::Object MacCatalyst({{"Archs", {"x86_64", "arm64"}},
+                                  {"LLVMTargetTripleVendor", "apple"},
+                                  {"LLVMTargetTripleSys", "ios"},
+                                  {"LLVMTargetTripleEnvironment", "macabi"},
+                                  {"SystemPrefix", "/System/iOSSupport"}});
+  llvm::json::Object DriverKit({{"Archs", {"x86_64", "arm64"}},
+                                {"LLVMTargetTripleVendor", "apple"},
+                                {"LLVMTargetTripleSys", "driverkit"},
+                                {"LLVMTargetTripleEnvironment", ""},
+                                {"SystemPrefix", ""}});
+  SupportedTargets["macosx"] = std::move(MacOS);
+  SupportedTargets["iosmac"] = std::move(MacCatalyst);
+  SupportedTargets["driverkit"] = std::move(DriverKit);
+  SDKSettings["SupportedTargets"] = std::move(SupportedTargets);
+
+  auto SDKInfo = DarwinSDKInfo::parseDarwinSDKSettingsJSON(&SDKSettings);
+  ASSERT_TRUE(SDKInfo);
+  EXPECT_EQ(SDKInfo->getSystemPrefix(Triple("arm64-apple-macos26.0")),
+            "/System/macOSSupport");
+  EXPECT_EQ(SDKInfo->getSystemPrefix(Triple("ppc-apple-macos26.0")),
+            "/System/macOSSupport");
+  EXPECT_EQ(SDKInfo->getSystemPrefix(Triple("arm64-apple-ios26.0")),
+            "/System/macOSSupport");
----------------
cyndyishida wrote:

It seems to me the goal of this PR is that there should be no observable change for clients to well behaving configured projects. From a stability standpoint, I think it's better to preserve as much of the preexisting behavior for existing workflows as possible to land this change. If any client needs to make changes to get the right system prefixes, that should be handled separately from this pr. 

https://github.com/llvm/llvm-project/pull/171970


More information about the cfe-commits mailing list