https://github.com/carlocab updated 
https://github.com/llvm/llvm-project/pull/119670

>From 9db768ec1be84d6bf647b85f052776720822f64f Mon Sep 17 00:00:00 2001
From: Carlo Cabrera <git...@carlo.cab>
Date: Tue, 10 Dec 2024 01:45:22 +0800
Subject: [PATCH 1/7] [clang][Driver][Darwin] Optionally use xcselect to find
 macOS SDK

This is a scaled down version of https://reviews.llvm.org/D136315.

The intent is largely the same as before[^1], but I've scaled down the scope
to try to avoid the issues that the previous patch caused:
- the changes are now opt-in based on enabling `CLANG_USE_XCSELECT`
- this only works when targeting macOS on a macOS host (this is the only
  case supported by `libxcselect`[^2])

We also introduce an environment variable `CLANG_NO_XCSELECT` that
disables this behaviour if Clang is configured with
`CLANG_USE_XCSELECT=ON`. This is needed to avoid breaking tests.

Another reason to leave this as opt-in for now is that there are some
bugs in libxcselect that need fixing before it is safe to use by default
for all users. This has been reported to Apple as FB16081077.

[^1]: See also https://reviews.llvm.org/D109460 and #45225.
[^2]: https://developer.apple.com/documentation/xcselect?language=objc
---
 clang/CMakeLists.txt                      | 33 +++++++++++++++++++++++
 clang/include/clang/Config/config.h.cmake |  6 +++++
 clang/lib/Driver/CMakeLists.txt           |  4 +++
 clang/lib/Driver/ToolChains/Darwin.cpp    | 31 ++++++++++++++-------
 clang/test/lit.cfg.py                     |  4 +++
 5 files changed, 69 insertions(+), 9 deletions(-)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 27e8095534a65c..3c7096a27c509b 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -214,6 +214,39 @@ if(GCC_INSTALL_PREFIX AND NOT 
USE_DEPRECATED_GCC_INSTALL_PREFIX)
     "See https://github.com/llvm/llvm-project/pull/77537 for detail.")
 endif()
 
+if(APPLE)
+  check_include_file(xcselect.h CLANG_HAVE_XCSELECT_H)
+  if(CLANG_HAVE_XCSELECT_H)
+    include(CheckSymbolExists)
+    list(APPEND CMAKE_REQUIRED_LIBRARIES xcselect)
+    check_symbol_exists(xcselect_host_sdk_path xcselect.h 
CLANG_HAVE_XCSELECT_HOST_SDK_PATH)
+    list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES xcselect)
+  endif()
+endif()
+
+cmake_dependent_option(CLANG_USE_XCSELECT "Use libxcselect to find the macOS 
SDK." OFF
+  "APPLE;CLANG_HAVE_XCSELECT_HOST_SDK_PATH" OFF)
+
+if(DEFAULT_SYSROOT AND CLANG_USE_XCSELECT)
+  message(FATAL_ERROR "Setting DEFAULT_SYSROOT is incompatible with 
CLANG_USE_XCSELECT.")
+endif()
+
+if(CLANG_USE_XCSELECT)
+  set(XCSELECT_VALID_POLICIES LATEST MATCHING_ONLY MATCHING_PREFERRED)
+  set(CLANG_XCSELECT_HOST_SDK_POLICY "LATEST" CACHE STRING
+    "Policy to use for xcselect. One of: ${XCSELECT_VALID_POLICIES}")
+  set_property(CACHE CLANG_XCSELECT_HOST_SDK_POLICY PROPERTY STRINGS 
${XCSELECT_VALID_POLICIES})
+  string(TOUPPER ${CLANG_XCSELECT_HOST_SDK_POLICY} 
CLANG_XCSELECT_HOST_SDK_POLICY)
+  list(JOIN XCSELECT_VALID_POLICIES "|" XCSELECT_POLICY_REGEX)
+  if(NOT CLANG_XCSELECT_HOST_SDK_POLICY MATCHES 
"^XCSELECT_HOST_SDK_POLICY_(${XCSELECT_POLICY_REGEX})$")
+    if(NOT CLANG_XCSELECT_HOST_SDK_POLICY IN_LIST XCSELECT_VALID_POLICIES)
+      message(FATAL_ERROR
+        "CLANG_XCSELECT_HOST_SDK_POLICY (${CLANG_XCSELECT_HOST_SDK_POLICY}) 
must be one of: ${XCSELECT_VALID_POLICIES}")
+    endif()
+    set(CLANG_XCSELECT_HOST_SDK_POLICY 
"XCSELECT_HOST_SDK_POLICY_${CLANG_XCSELECT_HOST_SDK_POLICY}")
+  endif()
+endif()
+
 set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld")
 
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL
diff --git a/clang/include/clang/Config/config.h.cmake 
b/clang/include/clang/Config/config.h.cmake
index 27ed69e21562bf..9ae0c6a4b9e11d 100644
--- a/clang/include/clang/Config/config.h.cmake
+++ b/clang/include/clang/Config/config.h.cmake
@@ -86,4 +86,10 @@
 /* Whether CIR is built into Clang */
 #cmakedefine01 CLANG_ENABLE_CIR
 
+/* Whether to use xcselect to find the macOS SDK */
+#cmakedefine CLANG_USE_XCSELECT
+
+/* Policy to use for xcselect */
+#cmakedefine CLANG_XCSELECT_HOST_SDK_POLICY ${CLANG_XCSELECT_HOST_SDK_POLICY}
+
 #endif
diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index 4fd10bf671512f..299de2ef30470c 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -14,6 +14,10 @@ if(WIN32)
   set(system_libs version)
 endif()
 
+if(CLANG_USE_XCSELECT)
+  set(system_libs xcselect)
+endif()
+
 add_clang_library(clangDriver
   Action.cpp
   Compilation.cpp
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 87380869f6fdab..8d3e0130a5a432 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -29,6 +29,10 @@
 #include "llvm/TargetParser/Triple.h"
 #include <cstdlib> // ::getenv
 
+#ifdef CLANG_USE_XCSELECT
+#include <xcselect.h> // ::xcselect_host_sdk_path
+#endif
+
 using namespace clang::driver;
 using namespace clang::driver::tools;
 using namespace clang::driver::toolchains;
@@ -2257,17 +2261,26 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) 
const {
     // Warn if the path does not exist.
     if (!getVFS().exists(A->getValue()))
       getDriver().Diag(clang::diag::warn_missing_sysroot) << A->getValue();
-  } else {
-    if (char *env = ::getenv("SDKROOT")) {
-      // We only use this value as the default if it is an absolute path,
-      // exists, and it is not the root path.
-      if (llvm::sys::path::is_absolute(env) && getVFS().exists(env) &&
-          StringRef(env) != "/") {
-        Args.append(Args.MakeSeparateArg(
-            nullptr, Opts.getOption(options::OPT_isysroot), env));
-      }
+  } else if (const char *env = ::getenv("SDKROOT"); env && *env) {
+    // We only use this value as the default if it is an absolute path,
+    // exists, and it is not the root path.
+    if (llvm::sys::path::is_absolute(env) && getVFS().exists(env) &&
+        StringRef(env) != "/") {
+      Args.append(Args.MakeSeparateArg(
+          nullptr, Opts.getOption(options::OPT_isysroot), env));
     }
   }
+#ifdef CLANG_USE_XCSELECT
+  else if (const char *env = ::getenv("CLANG_NO_XCSELECT");
+           getTriple().isMacOSX() && (!env || !*env)) {
+    if (char *p;
+        !::xcselect_host_sdk_path(CLANG_XCSELECT_HOST_SDK_POLICY, &p)) {
+      Args.append(Args.MakeSeparateArg(
+          nullptr, Opts.getOption(options::OPT_isysroot), p));
+      ::free(p);
+    }
+  }
+#endif
 
   // Read the SDKSettings.json file for more information, like the SDK version
   // that we can pass down to the compiler.
diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 7e7934d5fe0f5f..d05ad1ec6c5fa6 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -366,3 +366,7 @@ def calculate_arch_features(arch_string):
 # possibly be present in system and user configuration files, so disable
 # default configs for the test runs.
 config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
+
+# Configuring clang with CLANG_USE_XCSELECT=ON breaks some tests, so disable
+# its behaviour while running tests.
+config.environment["CLANG_NO_XCSELECT"] = "1"

>From 8b5afe0871ece184fb1484dd0221721e4d42863c Mon Sep 17 00:00:00 2001
From: Carlo Cabrera <git...@carlo.cab>
Date: Fri, 13 Dec 2024 02:32:17 +0800
Subject: [PATCH 2/7] Gate all `xcselect` checks behind `CLANG_USE_XCSELECT`

---
 clang/CMakeLists.txt | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 3c7096a27c509b..5cdc573ac24660 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -214,30 +214,35 @@ if(GCC_INSTALL_PREFIX AND NOT 
USE_DEPRECATED_GCC_INSTALL_PREFIX)
     "See https://github.com/llvm/llvm-project/pull/77537 for detail.")
 endif()
 
-if(APPLE)
+cmake_dependent_option(CLANG_USE_XCSELECT "Use libxcselect to find the macOS 
SDK." OFF "APPLE" OFF)
+
+if(CLANG_USE_XCSELECT)
+  if(DEFAULT_SYSROOT)
+    message(FATAL_ERROR "Setting DEFAULT_SYSROOT is incompatible with 
CLANG_USE_XCSELECT.")
+  endif()
+
   check_include_file(xcselect.h CLANG_HAVE_XCSELECT_H)
-  if(CLANG_HAVE_XCSELECT_H)
-    include(CheckSymbolExists)
-    list(APPEND CMAKE_REQUIRED_LIBRARIES xcselect)
-    check_symbol_exists(xcselect_host_sdk_path xcselect.h 
CLANG_HAVE_XCSELECT_HOST_SDK_PATH)
-    list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES xcselect)
+  if(NOT CLANG_HAVE_XCSELECT_H)
+    message(FATAL_ERROR "CLANG_USE_XCSELECT is enabled but xcselect.h was not 
found.")
   endif()
-endif()
 
-cmake_dependent_option(CLANG_USE_XCSELECT "Use libxcselect to find the macOS 
SDK." OFF
-  "APPLE;CLANG_HAVE_XCSELECT_HOST_SDK_PATH" OFF)
+  include(CheckSymbolExists)
+  list(APPEND CMAKE_REQUIRED_LIBRARIES xcselect)
+  check_symbol_exists(xcselect_host_sdk_path xcselect.h 
CLANG_HAVE_XCSELECT_HOST_SDK_PATH)
+  list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES xcselect)
 
-if(DEFAULT_SYSROOT AND CLANG_USE_XCSELECT)
-  message(FATAL_ERROR "Setting DEFAULT_SYSROOT is incompatible with 
CLANG_USE_XCSELECT.")
-endif()
+  if(NOT CLANG_HAVE_XCSELECT_HOST_SDK_PATH)
+    message(FATAL_ERROR "CLANG_USE_XCSELECT is enabled but either libxcselect 
is not available "
+      "or it is missing xcselect_host_sdk_path.")
+  endif()
 
-if(CLANG_USE_XCSELECT)
   set(XCSELECT_VALID_POLICIES LATEST MATCHING_ONLY MATCHING_PREFERRED)
   set(CLANG_XCSELECT_HOST_SDK_POLICY "LATEST" CACHE STRING
     "Policy to use for xcselect. One of: ${XCSELECT_VALID_POLICIES}")
   set_property(CACHE CLANG_XCSELECT_HOST_SDK_POLICY PROPERTY STRINGS 
${XCSELECT_VALID_POLICIES})
   string(TOUPPER ${CLANG_XCSELECT_HOST_SDK_POLICY} 
CLANG_XCSELECT_HOST_SDK_POLICY)
   list(JOIN XCSELECT_VALID_POLICIES "|" XCSELECT_POLICY_REGEX)
+
   if(NOT CLANG_XCSELECT_HOST_SDK_POLICY MATCHES 
"^XCSELECT_HOST_SDK_POLICY_(${XCSELECT_POLICY_REGEX})$")
     if(NOT CLANG_XCSELECT_HOST_SDK_POLICY IN_LIST XCSELECT_VALID_POLICIES)
       message(FATAL_ERROR

>From 27a5e1920c33b16d866ac32b4e1ec1c4ca4a6935 Mon Sep 17 00:00:00 2001
From: Carlo Cabrera <git...@carlo.cab>
Date: Fri, 13 Dec 2024 02:37:10 +0800
Subject: [PATCH 3/7] Avoid `if` conditions with multiple statements

---
 clang/lib/Driver/ToolChains/Darwin.cpp | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 8d3e0130a5a432..b6b288b93f766b 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2261,7 +2261,7 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) 
const {
     // Warn if the path does not exist.
     if (!getVFS().exists(A->getValue()))
       getDriver().Diag(clang::diag::warn_missing_sysroot) << A->getValue();
-  } else if (const char *env = ::getenv("SDKROOT"); env && *env) {
+  } else if (const char *env = ::getenv("SDKROOT")) {
     // We only use this value as the default if it is an absolute path,
     // exists, and it is not the root path.
     if (llvm::sys::path::is_absolute(env) && getVFS().exists(env) &&
@@ -2271,13 +2271,16 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) 
const {
     }
   }
 #ifdef CLANG_USE_XCSELECT
-  else if (const char *env = ::getenv("CLANG_NO_XCSELECT");
-           getTriple().isMacOSX() && (!env || !*env)) {
-    if (char *p;
-        !::xcselect_host_sdk_path(CLANG_XCSELECT_HOST_SDK_POLICY, &p)) {
-      Args.append(Args.MakeSeparateArg(
-          nullptr, Opts.getOption(options::OPT_isysroot), p));
-      ::free(p);
+  else if (getTriple().isMacOSX()) {
+    const char *env = ::getenv("CLANG_NO_XCSELECT");
+
+    if (!env || !*env) {
+      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);
+      }
     }
   }
 #endif

>From 7e9bbf7f9fcbecae8858b2f9d40457915a403e07 Mon Sep 17 00:00:00 2001
From: Carlo Cabrera <git...@carlo.cab>
Date: Sat, 14 Dec 2024 00:40:09 +0800
Subject: [PATCH 4/7] Add xcselect test

---
 clang/test/CMakeLists.txt     | 1 +
 clang/test/Driver/xcselect.c  | 5 +++++
 clang/test/lit.cfg.py         | 2 ++
 clang/test/lit.site.cfg.py.in | 1 +
 4 files changed, 9 insertions(+)
 create mode 100644 clang/test/Driver/xcselect.c

diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 5369dc92f69e8a..78ef8bc6e690a6 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -10,6 +10,7 @@ llvm_canonicalize_cmake_booleans(
   CLANG_PLUGIN_SUPPORT
   CLANG_SPAWN_CC1
   CLANG_ENABLE_CIR
+  CLANG_USE_XCSELECT
   ENABLE_BACKTRACES
   LLVM_BUILD_EXAMPLES
   LLVM_BYE_LINK_INTO_TOOLS
diff --git a/clang/test/Driver/xcselect.c b/clang/test/Driver/xcselect.c
new file mode 100644
index 00000000000000..bdb89dbb966ba2
--- /dev/null
+++ b/clang/test/Driver/xcselect.c
@@ -0,0 +1,5 @@
+// REQUIRES: xcselect
+// RUN: %clang -target arm64-apple-darwin -c -### %s 2> %t.log
+// RUN: FileCheck %s <%t.log
+
+// CHECK: "-isysroot" "{{.*}}/SDKs/MacOSX{{([0-9]+(\.[0-9]+)?)?}}.sdk"
diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index d05ad1ec6c5fa6..b0aea62f03afb6 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -338,6 +338,8 @@ def calculate_arch_features(arch_string):
 if config.have_llvm_driver:
     config.available_features.add("llvm-driver")
 
+if config.use_xcselect:
+    config.available_features.add("xcselect")
 
 # Some tests perform deep recursion, which requires a larger pthread stack size
 # than the relatively low default of 192 KiB for 64-bit processes on AIX. The
diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index 1cbd876ac5bb93..95b3a866f64b30 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -44,6 +44,7 @@ config.standalone_build = @CLANG_BUILT_STANDALONE@
 config.ppc_linux_default_ieeelongdouble = @PPC_LINUX_DEFAULT_IEEELONGDOUBLE@
 config.have_llvm_driver = @LLVM_TOOL_LLVM_DRIVER_BUILD@
 config.substitutions.append(("%llvm-version-major", "@LLVM_VERSION_MAJOR@"))
+config.use_xcselect = @CLANG_USE_XCSELECT@
 
 import lit.llvm
 lit.llvm.initialize(lit_config, config)

>From dc195bd7668c09b7ec94abf771b618170cfd4b78 Mon Sep 17 00:00:00 2001
From: Carlo Cabrera <git...@carlo.cab>
Date: Sat, 14 Dec 2024 00:46:42 +0800
Subject: [PATCH 5/7] Mark failing tests with CLANG_USE_XCSELECT as XFAIL

---
 clang/lib/Driver/ToolChains/Darwin.cpp             | 14 +++++---------
 clang/test/Driver/arc.c                            |  3 +++
 clang/test/Driver/clang-g-opts.c                   |  3 +++
 clang/test/Driver/clang-translation.c              |  3 +++
 clang/test/Driver/darwin-builtin-modules.c         |  3 +++
 clang/test/Driver/darwin-debug-flags.c             |  3 +++
 clang/test/Driver/darwin-header-search-system.cpp  |  2 ++
 .../test/Driver/darwin-ld-platform-version-macos.c |  3 +++
 clang/test/Driver/darwin-ld.c                      |  3 +++
 clang/test/Driver/darwin-multiarch-arm.c           |  3 +++
 clang/test/Driver/darwin-objc-options.m            |  3 +++
 clang/test/Driver/darwin-version.c                 |  3 +++
 clang/test/Driver/debug-options.c                  |  3 +++
 clang/test/Driver/fsanitize.c                      |  3 +++
 .../Driver/macos-apple-silicon-slice-link-libs.cpp |  3 +++
 clang/test/Driver/target-triple-deployment.c       |  3 +++
 clang/test/lit.cfg.py                              |  4 ----
 17 files changed, 49 insertions(+), 13 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index b6b288b93f766b..0f4bffa903ec25 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2272,15 +2272,11 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) 
const {
   }
 #ifdef CLANG_USE_XCSELECT
   else if (getTriple().isMacOSX()) {
-    const char *env = ::getenv("CLANG_NO_XCSELECT");
-
-    if (!env || !*env) {
-      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);
-      }
+    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);
     }
   }
 #endif
diff --git a/clang/test/Driver/arc.c b/clang/test/Driver/arc.c
index e5d1af5225662a..7f6ac81aad17f9 100644
--- a/clang/test/Driver/arc.c
+++ b/clang/test/Driver/arc.c
@@ -1,3 +1,6 @@
+// XFAIL: xcselect
+// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
+
 // RUN: not %clang -ObjC -target i386-apple-darwin10 -stdlib=libstdc++ -m32 
-fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
 // RUN: not %clang -x objective-c -target i386-apple-darwin10 
-stdlib=libstdc++ -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
 // RUN: not %clang -x objective-c++ -target i386-apple-darwin10 
-stdlib=libstdc++ -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
diff --git a/clang/test/Driver/clang-g-opts.c b/clang/test/Driver/clang-g-opts.c
index fdbe0b96420c51..36cc3820bef162 100644
--- a/clang/test/Driver/clang-g-opts.c
+++ b/clang/test/Driver/clang-g-opts.c
@@ -1,3 +1,6 @@
+// XFAIL: xcselect
+// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
+
 // RUN: %clang -### -S %s        2>&1 | FileCheck 
--check-prefix=CHECK-WITHOUT-G %s
 // RUN: %clang -### -S %s -g -target x86_64-linux-gnu 2>&1 \
 // RUN:             | FileCheck --check-prefix=CHECK-WITH-G %s
diff --git a/clang/test/Driver/clang-translation.c 
b/clang/test/Driver/clang-translation.c
index a7343ea18b2135..3e56d571a0869b 100644
--- a/clang/test/Driver/clang-translation.c
+++ b/clang/test/Driver/clang-translation.c
@@ -1,3 +1,6 @@
+// XFAIL: xcselect
+// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
+
 // RUN: %clang -target i386-unknown-unknown -### -S -O0 -Os %s -o %t.s 
-fverbose-asm -fvisibility=hidden 2>&1 | FileCheck -check-prefix=I386 %s
 // I386: "-triple" "i386-unknown-unknown"
 // I386: "-S"
diff --git a/clang/test/Driver/darwin-builtin-modules.c 
b/clang/test/Driver/darwin-builtin-modules.c
index 4564d7317d7abe..e7f8bd8c9dab4e 100644
--- a/clang/test/Driver/darwin-builtin-modules.c
+++ b/clang/test/Driver/darwin-builtin-modules.c
@@ -1,3 +1,6 @@
+// XFAIL: xcselect
+// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
+
 // Check that darwin passes -fbuiltin-headers-in-system-modules
 // when expected.
 
diff --git a/clang/test/Driver/darwin-debug-flags.c 
b/clang/test/Driver/darwin-debug-flags.c
index 918ee345658a0e..dffc99733beb28 100644
--- a/clang/test/Driver/darwin-debug-flags.c
+++ b/clang/test/Driver/darwin-debug-flags.c
@@ -1,3 +1,6 @@
+// XFAIL: xcselect
+// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
+
 // RUN: env RC_DEBUG_OPTIONS=1 %clang -target i386-apple-darwin11 -I "path 
with \spaces" -g -Os %s  -emit-llvm -S -o - | FileCheck %s
 // RUN: touch %t.s
 // RUN: env RC_DEBUG_OPTIONS=1 %clang -### -target i386-apple-darwin11 -c -g 
%t.s 2>&1 | FileCheck -check-prefix=S %s
diff --git a/clang/test/Driver/darwin-header-search-system.cpp 
b/clang/test/Driver/darwin-header-search-system.cpp
index 5fb83b62ce7e63..1549b82f7cc678 100644
--- a/clang/test/Driver/darwin-header-search-system.cpp
+++ b/clang/test/Driver/darwin-header-search-system.cpp
@@ -1,4 +1,6 @@
 // UNSUPPORTED: system-windows
+// XFAIL: xcselect
+// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
 
 // General tests that the system header search paths detected by the driver
 // and passed to CC1 are correct on Darwin platforms.
diff --git a/clang/test/Driver/darwin-ld-platform-version-macos.c 
b/clang/test/Driver/darwin-ld-platform-version-macos.c
index 355df8dfc1bc20..a2c4cf8735be1e 100644
--- a/clang/test/Driver/darwin-ld-platform-version-macos.c
+++ b/clang/test/Driver/darwin-ld-platform-version-macos.c
@@ -1,3 +1,6 @@
+// XFAIL: xcselect
+// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
+
 // RUN: touch %t.o
 
 // RUN: %clang -target x86_64-apple-macos10.13 -fuse-ld=lld \
diff --git a/clang/test/Driver/darwin-ld.c b/clang/test/Driver/darwin-ld.c
index f0ca411430cc78..dd2995f2fb6db1 100644
--- a/clang/test/Driver/darwin-ld.c
+++ b/clang/test/Driver/darwin-ld.c
@@ -1,3 +1,6 @@
+// XFAIL: xcselect
+// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
+
 // Check that ld gets arch_multiple.
 
 // RUN: %clang -target i386-apple-darwin9 -arch i386 -arch x86_64 %s -### -o 
foo 2> %t.log
diff --git a/clang/test/Driver/darwin-multiarch-arm.c 
b/clang/test/Driver/darwin-multiarch-arm.c
index 0ea5c4bf9a69a4..1dd44013600bd3 100644
--- a/clang/test/Driver/darwin-multiarch-arm.c
+++ b/clang/test/Driver/darwin-multiarch-arm.c
@@ -1,3 +1,6 @@
+// XFAIL: xcselect
+// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
+
 // Check that we compile correctly with multiple ARM -arch options.
 //
 // RUN: %clang -target arm7-apple-darwin10 -### \
diff --git a/clang/test/Driver/darwin-objc-options.m 
b/clang/test/Driver/darwin-objc-options.m
index 8721fbc1ef1e28..9c75187c7ca3b5 100644
--- a/clang/test/Driver/darwin-objc-options.m
+++ b/clang/test/Driver/darwin-objc-options.m
@@ -1,3 +1,6 @@
+// XFAIL: xcselect
+// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
+
 // Check miscellaneous Objective-C options.
 
 // RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
diff --git a/clang/test/Driver/darwin-version.c 
b/clang/test/Driver/darwin-version.c
index ff05d4c10c4877..9a83c133524218 100644
--- a/clang/test/Driver/darwin-version.c
+++ b/clang/test/Driver/darwin-version.c
@@ -1,3 +1,6 @@
+// XFAIL: xcselect
+// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
+
 // RUN: %clang -target armv6-apple-darwin9 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX %s
 // CHECK-VERSION-OSX: "armv6k-apple-macosx10.5.0"
diff --git a/clang/test/Driver/debug-options.c 
b/clang/test/Driver/debug-options.c
index 73f2f402efa97a..cdca7b21837ab0 100644
--- a/clang/test/Driver/debug-options.c
+++ b/clang/test/Driver/debug-options.c
@@ -1,3 +1,6 @@
+// XFAIL: xcselect
+// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
+
 // Check to make sure clang is somewhat picky about -g options.
 
 // Linux.
diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index bb692b2aeea1d3..a2638bc808739a 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -1,3 +1,6 @@
+// XFAIL: xcselect
+// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
+
 // RUN: %clang --target=x86_64-linux-gnu -fsanitize=undefined 
-fsanitize-trap=undefined %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-UNDEFINED-TRAP
 // RUN: %clang --target=x86_64-linux-gnu -fsanitize=undefined 
-fsanitize-trap=undefined -fno-sanitize-trap=signed-integer-overflow %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP2
 // RUN: %clang --target=x86_64-linux-gnu -fsanitize=undefined 
-fsanitize-undefined-trap-on-error %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-UNDEFINED-TRAP
diff --git a/clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp 
b/clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp
index 4a2a029c736fc9..15739d1209938f 100644
--- a/clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp
+++ b/clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp
@@ -1,3 +1,6 @@
+// XFAIL: xcselect
+// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
+
 // RUN: %clang -### -target arm64-apple-macos10.7 %s 2>&1 | FileCheck 
-check-prefix=ARM64-10_7 %s
 // RUN: %clang -### -target x86_64-apple-macos10.7 %s 2>&1 | FileCheck 
-check-prefix=x86_64-10_7 %s
 // RUN: %clang -### -target arm64-apple-darwin6 %s 2>&1 | FileCheck 
-check-prefix=ARM64-10_7 %s
diff --git a/clang/test/Driver/target-triple-deployment.c 
b/clang/test/Driver/target-triple-deployment.c
index 2e29992502ed43..8eff2c61718173 100644
--- a/clang/test/Driver/target-triple-deployment.c
+++ b/clang/test/Driver/target-triple-deployment.c
@@ -1,3 +1,6 @@
+// XFAIL: xcselect
+// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
+
 // RUN: touch %t.o
 // RUN: %clang -fuse-ld= -target x86_64-apple-macosx10.4 -mlinker-version=400 
-### %t.o 2> %t.log
 // RUN: %clang -fuse-ld= -target x86_64-apple-darwin9 -mlinker-version=400 
-### %t.o 2>> %t.log
diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index b0aea62f03afb6..aadc9f85a168b8 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -368,7 +368,3 @@ def calculate_arch_features(arch_string):
 # possibly be present in system and user configuration files, so disable
 # default configs for the test runs.
 config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
-
-# Configuring clang with CLANG_USE_XCSELECT=ON breaks some tests, so disable
-# its behaviour while running tests.
-config.environment["CLANG_NO_XCSELECT"] = "1"

>From 8c0ea7f65724806c3a906dc76878de007ba4f95d Mon Sep 17 00:00:00 2001
From: Carlo Cabrera <git...@carlo.cab>
Date: Sat, 14 Dec 2024 02:03:11 +0800
Subject: [PATCH 6/7] Use xcselect only for `-macosx` triples

Using them for `-darwin*` triples makes many tests fail.
---
 clang/lib/Driver/ToolChains/Darwin.cpp                    | 4 +++-
 clang/test/Driver/arc.c                                   | 3 ---
 clang/test/Driver/clang-g-opts.c                          | 3 ---
 clang/test/Driver/clang-translation.c                     | 3 ---
 clang/test/Driver/darwin-builtin-modules.c                | 3 ---
 clang/test/Driver/darwin-debug-flags.c                    | 3 ---
 clang/test/Driver/darwin-header-search-system.cpp         | 2 --
 clang/test/Driver/darwin-ld-platform-version-macos.c      | 1 +
 clang/test/Driver/darwin-ld.c                             | 3 ---
 clang/test/Driver/darwin-multiarch-arm.c                  | 3 ---
 clang/test/Driver/darwin-objc-options.m                   | 3 ---
 clang/test/Driver/darwin-version.c                        | 3 ---
 clang/test/Driver/debug-options.c                         | 3 ---
 clang/test/Driver/fsanitize.c                             | 3 ---
 clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp | 3 ---
 clang/test/Driver/target-triple-deployment.c              | 3 ---
 clang/test/Driver/xcselect.c                              | 2 +-
 17 files changed, 5 insertions(+), 43 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 0f4bffa903ec25..ed292dfa62e108 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2271,7 +2271,9 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) 
const {
     }
   }
 #ifdef CLANG_USE_XCSELECT
-  else if (getTriple().isMacOSX()) {
+  // FIXME: This should check for `getTriple().isMacOSX()`, but this breaks
+  // many tests. See https://github.com/llvm/llvm-project/pull/119670.
+  else if (getTriple().getOS() == llvm::Triple::MacOSX) {
     char *p;
     if (!::xcselect_host_sdk_path(CLANG_XCSELECT_HOST_SDK_POLICY, &p)) {
       Args.append(Args.MakeSeparateArg(
diff --git a/clang/test/Driver/arc.c b/clang/test/Driver/arc.c
index 7f6ac81aad17f9..e5d1af5225662a 100644
--- a/clang/test/Driver/arc.c
+++ b/clang/test/Driver/arc.c
@@ -1,6 +1,3 @@
-// XFAIL: xcselect
-// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
-
 // RUN: not %clang -ObjC -target i386-apple-darwin10 -stdlib=libstdc++ -m32 
-fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
 // RUN: not %clang -x objective-c -target i386-apple-darwin10 
-stdlib=libstdc++ -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
 // RUN: not %clang -x objective-c++ -target i386-apple-darwin10 
-stdlib=libstdc++ -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
diff --git a/clang/test/Driver/clang-g-opts.c b/clang/test/Driver/clang-g-opts.c
index 36cc3820bef162..fdbe0b96420c51 100644
--- a/clang/test/Driver/clang-g-opts.c
+++ b/clang/test/Driver/clang-g-opts.c
@@ -1,6 +1,3 @@
-// XFAIL: xcselect
-// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
-
 // RUN: %clang -### -S %s        2>&1 | FileCheck 
--check-prefix=CHECK-WITHOUT-G %s
 // RUN: %clang -### -S %s -g -target x86_64-linux-gnu 2>&1 \
 // RUN:             | FileCheck --check-prefix=CHECK-WITH-G %s
diff --git a/clang/test/Driver/clang-translation.c 
b/clang/test/Driver/clang-translation.c
index 3e56d571a0869b..a7343ea18b2135 100644
--- a/clang/test/Driver/clang-translation.c
+++ b/clang/test/Driver/clang-translation.c
@@ -1,6 +1,3 @@
-// XFAIL: xcselect
-// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
-
 // RUN: %clang -target i386-unknown-unknown -### -S -O0 -Os %s -o %t.s 
-fverbose-asm -fvisibility=hidden 2>&1 | FileCheck -check-prefix=I386 %s
 // I386: "-triple" "i386-unknown-unknown"
 // I386: "-S"
diff --git a/clang/test/Driver/darwin-builtin-modules.c 
b/clang/test/Driver/darwin-builtin-modules.c
index e7f8bd8c9dab4e..4564d7317d7abe 100644
--- a/clang/test/Driver/darwin-builtin-modules.c
+++ b/clang/test/Driver/darwin-builtin-modules.c
@@ -1,6 +1,3 @@
-// XFAIL: xcselect
-// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
-
 // Check that darwin passes -fbuiltin-headers-in-system-modules
 // when expected.
 
diff --git a/clang/test/Driver/darwin-debug-flags.c 
b/clang/test/Driver/darwin-debug-flags.c
index dffc99733beb28..918ee345658a0e 100644
--- a/clang/test/Driver/darwin-debug-flags.c
+++ b/clang/test/Driver/darwin-debug-flags.c
@@ -1,6 +1,3 @@
-// XFAIL: xcselect
-// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
-
 // RUN: env RC_DEBUG_OPTIONS=1 %clang -target i386-apple-darwin11 -I "path 
with \spaces" -g -Os %s  -emit-llvm -S -o - | FileCheck %s
 // RUN: touch %t.s
 // RUN: env RC_DEBUG_OPTIONS=1 %clang -### -target i386-apple-darwin11 -c -g 
%t.s 2>&1 | FileCheck -check-prefix=S %s
diff --git a/clang/test/Driver/darwin-header-search-system.cpp 
b/clang/test/Driver/darwin-header-search-system.cpp
index 1549b82f7cc678..5fb83b62ce7e63 100644
--- a/clang/test/Driver/darwin-header-search-system.cpp
+++ b/clang/test/Driver/darwin-header-search-system.cpp
@@ -1,6 +1,4 @@
 // UNSUPPORTED: system-windows
-// XFAIL: xcselect
-// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
 
 // General tests that the system header search paths detected by the driver
 // and passed to CC1 are correct on Darwin platforms.
diff --git a/clang/test/Driver/darwin-ld-platform-version-macos.c 
b/clang/test/Driver/darwin-ld-platform-version-macos.c
index a2c4cf8735be1e..e9698cfc47be3a 100644
--- a/clang/test/Driver/darwin-ld-platform-version-macos.c
+++ b/clang/test/Driver/darwin-ld-platform-version-macos.c
@@ -1,5 +1,6 @@
 // XFAIL: xcselect
 // FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
+// See https://github.com/llvm/llvm-project/pull/119670.
 
 // RUN: touch %t.o
 
diff --git a/clang/test/Driver/darwin-ld.c b/clang/test/Driver/darwin-ld.c
index dd2995f2fb6db1..f0ca411430cc78 100644
--- a/clang/test/Driver/darwin-ld.c
+++ b/clang/test/Driver/darwin-ld.c
@@ -1,6 +1,3 @@
-// XFAIL: xcselect
-// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
-
 // Check that ld gets arch_multiple.
 
 // RUN: %clang -target i386-apple-darwin9 -arch i386 -arch x86_64 %s -### -o 
foo 2> %t.log
diff --git a/clang/test/Driver/darwin-multiarch-arm.c 
b/clang/test/Driver/darwin-multiarch-arm.c
index 1dd44013600bd3..0ea5c4bf9a69a4 100644
--- a/clang/test/Driver/darwin-multiarch-arm.c
+++ b/clang/test/Driver/darwin-multiarch-arm.c
@@ -1,6 +1,3 @@
-// XFAIL: xcselect
-// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
-
 // Check that we compile correctly with multiple ARM -arch options.
 //
 // RUN: %clang -target arm7-apple-darwin10 -### \
diff --git a/clang/test/Driver/darwin-objc-options.m 
b/clang/test/Driver/darwin-objc-options.m
index 9c75187c7ca3b5..8721fbc1ef1e28 100644
--- a/clang/test/Driver/darwin-objc-options.m
+++ b/clang/test/Driver/darwin-objc-options.m
@@ -1,6 +1,3 @@
-// XFAIL: xcselect
-// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
-
 // Check miscellaneous Objective-C options.
 
 // RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
diff --git a/clang/test/Driver/darwin-version.c 
b/clang/test/Driver/darwin-version.c
index 9a83c133524218..ff05d4c10c4877 100644
--- a/clang/test/Driver/darwin-version.c
+++ b/clang/test/Driver/darwin-version.c
@@ -1,6 +1,3 @@
-// XFAIL: xcselect
-// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
-
 // RUN: %clang -target armv6-apple-darwin9 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX %s
 // CHECK-VERSION-OSX: "armv6k-apple-macosx10.5.0"
diff --git a/clang/test/Driver/debug-options.c 
b/clang/test/Driver/debug-options.c
index cdca7b21837ab0..73f2f402efa97a 100644
--- a/clang/test/Driver/debug-options.c
+++ b/clang/test/Driver/debug-options.c
@@ -1,6 +1,3 @@
-// XFAIL: xcselect
-// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
-
 // Check to make sure clang is somewhat picky about -g options.
 
 // Linux.
diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index a2638bc808739a..bb692b2aeea1d3 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -1,6 +1,3 @@
-// XFAIL: xcselect
-// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
-
 // RUN: %clang --target=x86_64-linux-gnu -fsanitize=undefined 
-fsanitize-trap=undefined %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-UNDEFINED-TRAP
 // RUN: %clang --target=x86_64-linux-gnu -fsanitize=undefined 
-fsanitize-trap=undefined -fno-sanitize-trap=signed-integer-overflow %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP2
 // RUN: %clang --target=x86_64-linux-gnu -fsanitize=undefined 
-fsanitize-undefined-trap-on-error %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-UNDEFINED-TRAP
diff --git a/clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp 
b/clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp
index 15739d1209938f..4a2a029c736fc9 100644
--- a/clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp
+++ b/clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp
@@ -1,6 +1,3 @@
-// XFAIL: xcselect
-// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
-
 // RUN: %clang -### -target arm64-apple-macos10.7 %s 2>&1 | FileCheck 
-check-prefix=ARM64-10_7 %s
 // RUN: %clang -### -target x86_64-apple-macos10.7 %s 2>&1 | FileCheck 
-check-prefix=x86_64-10_7 %s
 // RUN: %clang -### -target arm64-apple-darwin6 %s 2>&1 | FileCheck 
-check-prefix=ARM64-10_7 %s
diff --git a/clang/test/Driver/target-triple-deployment.c 
b/clang/test/Driver/target-triple-deployment.c
index 8eff2c61718173..2e29992502ed43 100644
--- a/clang/test/Driver/target-triple-deployment.c
+++ b/clang/test/Driver/target-triple-deployment.c
@@ -1,6 +1,3 @@
-// XFAIL: xcselect
-// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
-
 // RUN: touch %t.o
 // RUN: %clang -fuse-ld= -target x86_64-apple-macosx10.4 -mlinker-version=400 
-### %t.o 2> %t.log
 // RUN: %clang -fuse-ld= -target x86_64-apple-darwin9 -mlinker-version=400 
-### %t.o 2>> %t.log
diff --git a/clang/test/Driver/xcselect.c b/clang/test/Driver/xcselect.c
index bdb89dbb966ba2..01cd4aca5ec237 100644
--- a/clang/test/Driver/xcselect.c
+++ b/clang/test/Driver/xcselect.c
@@ -1,5 +1,5 @@
 // REQUIRES: xcselect
-// RUN: %clang -target arm64-apple-darwin -c -### %s 2> %t.log
+// RUN: %clang -target arm64-apple-macosx -c -### %s 2> %t.log
 // RUN: FileCheck %s <%t.log
 
 // CHECK: "-isysroot" "{{.*}}/SDKs/MacOSX{{([0-9]+(\.[0-9]+)?)?}}.sdk"

>From c505838fc20abf320245b82d52e2f69c8ae635d0 Mon Sep 17 00:00:00 2001
From: Carlo Cabrera <git...@carlo.cab>
Date: Sat, 14 Dec 2024 05:18:27 +0800
Subject: [PATCH 7/7] Fix test failures with `CLANG_USE_XCSELECT`

---
 .../Driver/darwin-ld-platform-version-macos-nosdk.c  | 12 ++++++++++++
 clang/test/Driver/darwin-ld-platform-version-macos.c | 10 +++-------
 2 files changed, 15 insertions(+), 7 deletions(-)
 create mode 100644 clang/test/Driver/darwin-ld-platform-version-macos-nosdk.c

diff --git a/clang/test/Driver/darwin-ld-platform-version-macos-nosdk.c 
b/clang/test/Driver/darwin-ld-platform-version-macos-nosdk.c
new file mode 100644
index 00000000000000..c5e0dd94c59259
--- /dev/null
+++ b/clang/test/Driver/darwin-ld-platform-version-macos-nosdk.c
@@ -0,0 +1,12 @@
+// UNSUPPORTED: xcselect
+// CLANG_USE_XCSELECT will always have an SDK inferred.
+
+// RUN: touch %t.o
+
+// RUN: %clang -target x86_64-apple-macos10.13 -mlinker-version=520 \
+// RUN:   -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=NOSDK %s
+// RUN: %clang -target x86_64-apple-darwin17 -mlinker-version=520 \
+// RUN:   -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=NOSDK %s
+// NOSDK: "-platform_version" "macos" "10.13.0" "10.13.0"
diff --git a/clang/test/Driver/darwin-ld-platform-version-macos.c 
b/clang/test/Driver/darwin-ld-platform-version-macos.c
index e9698cfc47be3a..0804c850242c2f 100644
--- a/clang/test/Driver/darwin-ld-platform-version-macos.c
+++ b/clang/test/Driver/darwin-ld-platform-version-macos.c
@@ -1,7 +1,3 @@
-// XFAIL: xcselect
-// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT.
-// See https://github.com/llvm/llvm-project/pull/119670.
-
 // RUN: touch %t.o
 
 // RUN: %clang -target x86_64-apple-macos10.13 -fuse-ld=lld \
@@ -47,8 +43,8 @@
 
 // RUN: %clang -target x86_64-apple-macos10.13 -mlinker-version=520 \
 // RUN:   -### %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=NOSDK %s
+// RUN:   | FileCheck --check-prefix=INFERRED-SDK %s
 // RUN: %clang -target x86_64-apple-darwin17 -mlinker-version=520 \
 // RUN:   -### %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=NOSDK %s
-// NOSDK: "-platform_version" "macos" "10.13.0" "10.13.0"
+// RUN:   | FileCheck --check-prefix=INFERRED-SDK %s
+// INFERRED-SDK: "-platform_version" "macos" "10.13.0" "{{[0-9]+(\.[0-9]+)*}}"

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to