[clang] [clang][Driver][Darwin] Use `xcselect` for `*-apple-darwin*` targets too (PR #186683)

Carlo Cabrera via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 17 04:30:23 PDT 2026


================
@@ -2651,6 +2639,21 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
   const std::string OSVersionStr = OSVersion.getAsString();
   // Set the tool chain target information.
   if (Platform == MacOS) {
+#ifdef CLANG_USE_XCSELECT
+    // If we don't have an SDK yet and are on macOS, try to inject one using
+    // xcselect, except when passed --no-xcselect.
+    if (!Args.hasArg(options::OPT_no_xcselect) &&
+        !Args.getLastArg(options::OPT_isysroot) && !::getenv("SDKROOT") &&
+        !SDKInfo) {
+      char *p;
+      if (!::xcselect_host_sdk_path(CLANG_XCSELECT_HOST_SDK_POLICY, &p)) {
+        Args.append(Args.MakeSeparateArg(
+            nullptr, Opts.getOption(options::OPT_isysroot), p));
+        ::free(p);
+        SDKInfo = parseSDKSettings(getVFS(), Args, getDriver());
+      }
+    }
----------------
carlocab wrote:

I wonder if we should also skip this if `--sysroot` is passed.

If we do that, we can also drop the `--no-xcselect` flag and use `--sysroot=""` instead. Though I suppose doing that in the tests would be less transparent.

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


More information about the cfe-commits mailing list