llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Carlo Cabrera (carlocab)

<details>
<summary>Changes</summary>

This is a follow-up to #<!-- -->119670. There, we introduced the CMake option
`CLANG_USE_XCSELECT`, which, when enabled, uses `libxcselect` to find
the right SDK to inject as an `-isysroot` flag when targetting
`*-apple-macos*`.

We intentionally left out `*-apple-darwin*` targets because it broke
many tests. This is unfortunate because `*-apple-darwin*` is the default
triple when building LLVM on macOS, so one isn't able to take advantage
of `xcselect` without an explicit `-target` flag or a change to the
toolchain's default target.

We do this in two ways.

First, when we fall into the `xcselect` branch, we use a few heuristics
to determine whether the target truly is macOS. Ideally these heuristics
would reuse the deployment target selection logic below it. However,
the deployment target selection code depends on the value of
`-isysroot`, so there is a circular dependency that is not easy to
break.

Second, we update tests where appropriate with a `-m*os-version-min`
flag. This is needed when running these tests on macOS, because xcselect
will inject an `-isysroot` flag pointing to the macOS SDK, and this
changes the these tests' intended deployment target and platform
version. We also have to skip some tests because they do not make sense
under xcselect.


---

Patch is 45.23 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/186683.diff


16 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Darwin.cpp (+68-20) 
- (modified) clang/test/Driver/arc.c (+5-5) 
- (modified) clang/test/Driver/attr-availability-erroneous-diags.c (+1-1) 
- (modified) clang/test/Driver/clang-g-opts.c (+2-2) 
- (modified) clang/test/Driver/clang-translation.c (+7-7) 
- (modified) clang/test/Driver/darwin-builtin-modules.c (+1-1) 
- (modified) clang/test/Driver/darwin-debug-flags.c (+3-3) 
- (modified) clang/test/Driver/darwin-header-search-system.cpp (+6-4) 
- (modified) clang/test/Driver/darwin-ld.c (+36-36) 
- (modified) clang/test/Driver/darwin-objc-options.m (+8-8) 
- (modified) clang/test/Driver/darwin-version.c (+14-12) 
- (modified) clang/test/Driver/debug-options.c (+11-11) 
- (modified) clang/test/Driver/fsanitize-ignorelist.c (+1-1) 
- (modified) clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp (+1-1) 
- (modified) clang/test/Driver/target-triple-deployment.c (+1-1) 
- (modified) clang/test/Driver/xcselect.c (+32-3) 


``````````diff
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 7251f4a92d92d..925502bd3a1d3 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1752,6 +1752,20 @@ static std::string getSystemOrSDKMacOSVersion(StringRef 
MacOSSDKVersion) {
   return std::string(MacOSSDKVersion);
 }
 
+/// Deployment target environment variable names, indexed by 
DarwinPlatformKind.
+/// Covers all platforms up to (but not including) Firmware.
+static constexpr const char *DeploymentTargetEnvVars[] = {
+    "MACOSX_DEPLOYMENT_TARGET",    // MacOS
+    "IPHONEOS_DEPLOYMENT_TARGET",  // IPhoneOS
+    "TVOS_DEPLOYMENT_TARGET",      // TvOS
+    "WATCHOS_DEPLOYMENT_TARGET",   // WatchOS
+    "DRIVERKIT_DEPLOYMENT_TARGET", // DriverKit
+    "XROS_DEPLOYMENT_TARGET",      // XROS
+};
+static_assert(
+    std::size(DeploymentTargetEnvVars) == Darwin::Firmware,
+    "Update DeploymentTargetEnvVars when modifying DarwinPlatformKind");
+
 namespace {
 
 /// The Darwin OS and version that was selected or inferred from arguments or
@@ -2229,16 +2243,9 @@ getDeploymentTargetFromOSVersionArg(DerivedArgList &Args,
 std::optional<DarwinPlatform>
 getDeploymentTargetFromEnvironmentVariables(const Driver &TheDriver,
                                             const llvm::Triple &Triple) {
-  const char *EnvVars[] = {
-      "MACOSX_DEPLOYMENT_TARGET",
-      "IPHONEOS_DEPLOYMENT_TARGET",
-      "TVOS_DEPLOYMENT_TARGET",
-      "WATCHOS_DEPLOYMENT_TARGET",
-      "DRIVERKIT_DEPLOYMENT_TARGET",
-      "XROS_DEPLOYMENT_TARGET"
-  };
-  std::string Targets[std::size(EnvVars)];
-  for (const auto &I : llvm::enumerate(llvm::ArrayRef(EnvVars))) {
+  std::string Targets[std::size(DeploymentTargetEnvVars)];
+  for (const auto &I :
+       llvm::enumerate(llvm::ArrayRef(DeploymentTargetEnvVars))) {
     if (char *Env = ::getenv(I.value()))
       Targets[I.index()] = Env;
   }
@@ -2273,8 +2280,8 @@ getDeploymentTargetFromEnvironmentVariables(const Driver 
&TheDriver,
   for (const auto &Target : llvm::enumerate(llvm::ArrayRef(Targets))) {
     if (!Target.value().empty())
       return DarwinPlatform::createDeploymentTargetEnv(
-          (Darwin::DarwinPlatformKind)Target.index(), EnvVars[Target.index()],
-          Target.value());
+          (Darwin::DarwinPlatformKind)Target.index(),
+          DeploymentTargetEnvVars[Target.index()], Target.value());
   }
   return std::nullopt;
 }
@@ -2502,14 +2509,55 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) 
const {
     }
   }
 #ifdef CLANG_USE_XCSELECT
-  // 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(
-          nullptr, Opts.getOption(options::OPT_isysroot), p));
-      ::free(p);
+  // FIXME: Ideally this block should reuse the deployment target selection
+  // logic below. However, the deployment target selection also depends on the
+  // value of `-isysroot`, so it's not straightforward how to break the 
circular
+  // dependency.
+  else if (getTriple().isMacOSX()) {
+    // Only inject the SDK for triples that could plausibly target macOS.
+    // 32-bit ARM was never used for macOS, and arm64 Macs only exist since
+    // darwin20 (macOS 11 Big Sur), so earlier darwin versions with AArch64
+    // are likely iOS/tvOS/watchOS cross-compilation targets.
+    const llvm::Triple &T = getTriple();
+    bool ProbablyMacOS = !T.isARM() && !T.isThumb();
+    if (ProbablyMacOS && T.isAArch64() && T.getOS() != llvm::Triple::MacOSX) {
+      unsigned Major = T.getOSMajorVersion();
+      if (Major > 0 && Major < 20)
+        ProbablyMacOS = false;
+    }
+    // A non-macOS -m*-version-min flag without -mmacosx-version-min means
+    // the user is cross-compiling. When both are present, the conflict is
+    // diagnosed by getDeploymentTargetFromOSVersionArg, which picks macOS.
+    if (ProbablyMacOS && !Args.getLastArg(options::OPT_mmacos_version_min_EQ) 
&&
+        Args.getLastArg(options::OPT_mios_version_min_EQ,
+                        options::OPT_mios_simulator_version_min_EQ,
+                        options::OPT_mtvos_version_min_EQ,
+                        options::OPT_mtvos_simulator_version_min_EQ,
+                        options::OPT_mwatchos_version_min_EQ,
+                        options::OPT_mwatchos_simulator_version_min_EQ))
+      ProbablyMacOS = false;
+    // If a non-macOS deployment target env var is set without
+    // MACOSX_DEPLOYMENT_TARGET, the user is clearly cross-compiling for
+    // another platform — don't inject a macOS SDK. When both are set,
+    // getDeploymentTargetFromEnvironmentVariables resolves the conflict
+    // based on the arch, and the user may still need xcselect for the SDK.
+    if (ProbablyMacOS && !::getenv("MACOSX_DEPLOYMENT_TARGET")) {
+      for (const char *EnvVar : DeploymentTargetEnvVars) {
+        if (!StringRef(EnvVar).starts_with("MACOSX_")) {
+          if (const char *Val = ::getenv(EnvVar); Val && *Val) {
+            ProbablyMacOS = false;
+            break;
+          }
+        }
+      }
+    }
+    if (ProbablyMacOS) {
+      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 e5d1af5225662..672bf6ba88976 100644
--- a/clang/test/Driver/arc.c
+++ b/clang/test/Driver/arc.c
@@ -1,8 +1,8 @@
-// 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
-// RUN: not %clang -x c -target i386-apple-darwin10 -stdlib=libstdc++ -m32 
-fobjc-arc %s -fsyntax-only 2>&1 | FileCheck -check-prefix NOTOBJC %s
-// RUN: not %clang -x c++ -target i386-apple-darwin10 -stdlib=libstdc++ -m32 
-fobjc-arc %s -fsyntax-only 2>&1 | FileCheck -check-prefix NOTOBJC %s
+// RUN: not %clang -ObjC -target i386-apple-darwin10 -mmacosx-version-min=10.6 
-stdlib=libstdc++ -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
+// RUN: not %clang -x objective-c -target i386-apple-darwin10 
-mmacosx-version-min=10.6 -stdlib=libstdc++ -m32 -fobjc-arc %s -fsyntax-only 
2>&1 | FileCheck %s
+// RUN: not %clang -x objective-c++ -target i386-apple-darwin10 
-mmacosx-version-min=10.6 -stdlib=libstdc++ -m32 -fobjc-arc %s -fsyntax-only 
2>&1 | FileCheck %s
+// RUN: not %clang -x c -target i386-apple-darwin10 -mmacosx-version-min=10.6 
-stdlib=libstdc++ -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck 
-check-prefix NOTOBJC %s
+// RUN: not %clang -x c++ -target i386-apple-darwin10 
-mmacosx-version-min=10.6 -stdlib=libstdc++ -m32 -fobjc-arc %s -fsyntax-only 
2>&1 | FileCheck -check-prefix NOTOBJC %s
 // RUN: not %clang -x objective-c -target x86_64-apple-darwin11 
-mmacos-version-min=10.5 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck 
-check-prefix NOTSUPPORTED %s
 
 // Just to test clang is working.
diff --git a/clang/test/Driver/attr-availability-erroneous-diags.c 
b/clang/test/Driver/attr-availability-erroneous-diags.c
index 5e67a461f3e19..9ca87546ad144 100644
--- a/clang/test/Driver/attr-availability-erroneous-diags.c
+++ b/clang/test/Driver/attr-availability-erroneous-diags.c
@@ -1,4 +1,4 @@
-// RUN: not %clang -target x86_64-apple-darwin9 -fsyntax-only %s 2>&1 | 
FileCheck %s
+// RUN: not %clang -target x86_64-apple-darwin9 -mmacosx-version-min=10.5 
-fsyntax-only %s 2>&1 | FileCheck %s
 
 // CHECK: error:
 // CHECK-SAME: 'f0' is unavailable: introduced in macOS 11
diff --git a/clang/test/Driver/clang-g-opts.c b/clang/test/Driver/clang-g-opts.c
index fdbe0b96420c5..6606a7ba09cb9 100644
--- a/clang/test/Driver/clang-g-opts.c
+++ b/clang/test/Driver/clang-g-opts.c
@@ -3,7 +3,7 @@
 // RUN:             | FileCheck --check-prefix=CHECK-WITH-G %s
 
 // Assert that the toolchains which should default to a lower Dwarf version do 
so.
-// RUN: %clang -### -S %s -g -target x86_64-apple-darwin8 2>&1 \
+// RUN: %clang -### -S %s -g -target x86_64-apple-darwin8 
-mmacosx-version-min=10.4 2>&1 \
 // RUN:             | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
 // RUN: %clang -### -S %s -g -target i686-pc-openbsd 2>&1 \
 // RUN:             | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
@@ -23,7 +23,7 @@
 //
 // RUN: %clang -### -S %s -g0 -g -target x86_64-linux-gnu 2>&1 \
 // RUN:             | FileCheck --check-prefix=CHECK-WITH-G %s
-// RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin8 2>&1 \
+// RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin8 
-mmacosx-version-min=10.4 2>&1 \
 // RUN:             | FileCheck --check-prefix=CHECK-WITH-G-STANDALONE %s
 // RUN: %clang -### -S %s -g0 -g -target i686-pc-openbsd 2>&1 \
 // RUN:             | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
diff --git a/clang/test/Driver/clang-translation.c 
b/clang/test/Driver/clang-translation.c
index 5ec052a7aaa11..766bf139634ef 100644
--- a/clang/test/Driver/clang-translation.c
+++ b/clang/test/Driver/clang-translation.c
@@ -17,28 +17,28 @@
 // RUN: %clang -target i386-unknown-unknown -### -S %s 
-fasynchronous-unwind-tables -fno-unwind-tables 2>&1 | FileCheck 
--check-prefix=UNWIND-TABLES %s --implicit-check-not=warning:
 // UNWIND-TABLES: "-funwind-tables=2"
 
-// RUN: %clang -target i386-apple-darwin9 -### -S %s -o %t.s 2>&1 | \
+// RUN: %clang -target i386-apple-darwin9 -mmacosx-version-min=10.5 -### -S %s 
-o %t.s 2>&1 | \
 // RUN: FileCheck -check-prefix=YONAH %s
 // RUN: %clang -target i386-apple-macosx10.11 -### -S %s -o %t.s 2>&1 | \
 // RUN: FileCheck -check-prefix=YONAH %s
 // YONAH: "-target-cpu"
 // YONAH: "yonah"
 
-// RUN: %clang -target x86_64-apple-darwin9 -### -S %s -o %t.s 2>&1 | \
+// RUN: %clang -target x86_64-apple-darwin9 -mmacosx-version-min=10.5 -### -S 
%s -o %t.s 2>&1 | \
 // RUN: FileCheck -check-prefix=CORE2 %s
 // RUN: %clang -target x86_64-apple-macosx10.11 -### -S %s -o %t.s 2>&1 | \
 // RUN: FileCheck -check-prefix=CORE2 %s
 // CORE2: "-target-cpu"
 // CORE2: "core2"
 
-// RUN: %clang -target x86_64h-apple-darwin -### -S %s -o %t.s 2>&1 | \
+// RUN: %clang -target x86_64h-apple-darwin -mmacosx-version-min=10.9 -### -S 
%s -o %t.s 2>&1 | \
 // RUN: FileCheck -check-prefix=AVX2 %s
 // RUN: %clang -target x86_64h-apple-macosx10.12 -### -S %s -o %t.s 2>&1 | \
 // RUN: FileCheck -check-prefix=AVX2 %s
 // AVX2: "-target-cpu"
 // AVX2: "core-avx2"
 
-// RUN: %clang -target x86_64h-apple-darwin -march=skx -### %s -o /dev/null 
2>&1 | \
+// RUN: %clang -target x86_64h-apple-darwin -mmacosx-version-min=10.9 
-march=skx -### %s -o /dev/null 2>&1 | \
 // RUN: FileCheck -check-prefix=X8664HSKX %s
 // X8664HSKX: "-target-cpu"
 // X8664HSKX: "skx"
@@ -51,7 +51,7 @@
 // PENRYN: "penryn"
 
 
-// RUN: %clang -target x86_64-apple-darwin10 -### -S %s -arch armv7 2>&1 | \
+// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -### -S 
%s -arch armv7 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMV7_DEFAULT %s
 // ARMV7_DEFAULT: clang
 // ARMV7_DEFAULT: "-cc1"
@@ -60,7 +60,7 @@
 // ARMV7_DEFAULT-NOT: "-msoft-float"
 // ARMV7_DEFAULT: "-x" "c"
 
-// RUN: %clang -target x86_64-apple-darwin10 -### -S %s -arch armv7 \
+// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -### -S 
%s -arch armv7 \
 // RUN: -msoft-float 2>&1 | FileCheck -check-prefix=ARMV7_SOFTFLOAT %s
 // ARMV7_SOFTFLOAT: clang
 // ARMV7_SOFTFLOAT: "-cc1"
@@ -70,7 +70,7 @@
 // ARMV7_SOFTFLOAT: "-mfloat-abi" "soft"
 // ARMV7_SOFTFLOAT: "-x" "c"
 
-// RUN: not %clang -target x86_64-apple-darwin10 -### -S %s -arch armv7 \
+// RUN: not %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 
-### -S %s -arch armv7 \
 // RUN: -mhard-float 2>&1 | FileCheck -check-prefix=ARMV7_HARDFLOAT %s
 // ARMV7_HARDFLOAT: clang
 // ARMV7_HARDFLOAT: "-cc1"
diff --git a/clang/test/Driver/darwin-builtin-modules.c 
b/clang/test/Driver/darwin-builtin-modules.c
index f4c9220b8d577..4cd5aed149851 100644
--- a/clang/test/Driver/darwin-builtin-modules.c
+++ b/clang/test/Driver/darwin-builtin-modules.c
@@ -1,7 +1,7 @@
 // Check that darwin passes -fbuiltin-headers-in-system-modules
 // when expected.
 
-// RUN: %clang -target x86_64-apple-darwin22.4 -### %s 2>&1 | FileCheck 
--check-prefix=CHECK_OLD %s
+// RUN: %clang -isysroot %S/Inputs/MacOSX10.15.sdk -target 
x86_64-apple-darwin22.4 -mmacosx-version-min=13.3 -### %s 2>&1 | FileCheck 
--check-prefix=CHECK_OLD %s
 // RUN: %clang -isysroot %S/Inputs/MacOSX10.15.sdk -target 
x86_64-apple-macos10.15 -### %s 2>&1 | FileCheck --check-prefix=CHECK_OLD %s
 // RUN: %clang -isysroot %S/Inputs/iPhoneOS13.0.sdk -target 
arm64-apple-ios13.0 -### %s 2>&1 | FileCheck --check-prefix=CHECK_OLD %s
 // CHECK_OLD: -fbuiltin-headers-in-system-modules
diff --git a/clang/test/Driver/darwin-debug-flags.c 
b/clang/test/Driver/darwin-debug-flags.c
index 90209bb179bfc..90afd4a0dcdfd 100644
--- a/clang/test/Driver/darwin-debug-flags.c
+++ b/clang/test/Driver/darwin-debug-flags.c
@@ -1,7 +1,7 @@
-// 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: env RC_DEBUG_OPTIONS=1 %clang -target i386-apple-darwin11 -I "path 
with \spaces" -g -Os -mmacosx-version-min=10.7 %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
-// RUN: %clang -### -target i386-apple-darwin11 -c -g %t.s 2>&1 | FileCheck 
-check-prefix=P %s
+// RUN: env RC_DEBUG_OPTIONS=1 %clang -### -target i386-apple-darwin11 
-mmacosx-version-min=10.7 -c -g %t.s 2>&1 | FileCheck -check-prefix=S %s
+// RUN: %clang -### -target i386-apple-darwin11 -mmacosx-version-min=10.7 -c 
-g %t.s 2>&1 | FileCheck -check-prefix=P %s
 
 // CHECK: distinct !DICompileUnit(
 // CHECK-SAME:                flags:
diff --git a/clang/test/Driver/darwin-header-search-system.cpp 
b/clang/test/Driver/darwin-header-search-system.cpp
index 5fb83b62ce7e6..b8befeea07377 100644
--- a/clang/test/Driver/darwin-header-search-system.cpp
+++ b/clang/test/Driver/darwin-header-search-system.cpp
@@ -15,14 +15,15 @@
 // RUN:               -DRESOURCE=%S/Inputs/resource_dir \
 // RUN:               --check-prefix=CHECK-SYSTEM %s
 //
-// RUN: %clang -### %s -fsyntax-only 2>&1 \
+// xcselect injects -isysroot for -darwin triples, overriding --sysroot.
+// RUN: %if !xcselect %{ %clang -### %s -fsyntax-only 2>&1 \
 // RUN:     --target=x86_64-apple-darwin \
 // RUN:     -ccc-install-dir 
%S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
 // RUN:     -resource-dir=%S/Inputs/resource_dir \
 // RUN:     --sysroot %S/Inputs/basic_darwin_sdk_usr_and_usr_local \
 // RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_and_usr_local \
 // RUN:               -DRESOURCE=%S/Inputs/resource_dir \
-// RUN:               --check-prefix=CHECK-SYSTEM %s
+// RUN:               --check-prefix=CHECK-SYSTEM %s %}
 //
 // RUN: %clang -### %s -fsyntax-only 2>&1 \
 // RUN:     --target=x86_64-apple-darwin \
@@ -90,14 +91,15 @@
 // CHECK-NOSTDINC-NOT: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 
 // Check search paths without -isysroot
+// xcselect injects -isysroot for -darwin triples regardless of --sysroot.
 //
-// RUN: %clang -### %s -fsyntax-only 2>&1 \
+// RUN: %if !xcselect %{ %clang -### %s -fsyntax-only 2>&1 \
 // RUN:     --target=x86_64-apple-darwin \
 // RUN:     -ccc-install-dir 
%S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
 // RUN:     -resource-dir=%S/Inputs/resource_dir \
 // RUN:     --sysroot="" \
 // RUN:   | FileCheck -DRESOURCE=%S/Inputs/resource_dir \
-// RUN:               --check-prefix=CHECK-NOSYSROOT %s
+// RUN:               --check-prefix=CHECK-NOSYSROOT %s %}
 // CHECK-NOSYSROOT: "-cc1"
 // CHECK-NOSYSROOT: "-internal-isystem" "/usr/local/include"
 // CHECK-NOSYSROOT: "-internal-isystem" "[[RESOURCE]]/include"
diff --git a/clang/test/Driver/darwin-ld.c b/clang/test/Driver/darwin-ld.c
index cf89bdd4dac00..94952831bd726 100644
--- a/clang/test/Driver/darwin-ld.c
+++ b/clang/test/Driver/darwin-ld.c
@@ -1,12 +1,12 @@
 // Check that ld gets arch_multiple.
 
-// RUN: %clang -target i386-apple-darwin9 -arch i386 -arch x86_64 %s -### -o 
foo 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -mmacosx-version-min=10.5 -arch i386 
-arch x86_64 %s -### -o foo 2> %t.log
 // RUN: grep '".*ld.*" .*"-arch_multiple" "-final_output" "foo"' %t.log
 
 // Make sure we run dsymutil on source input files.
-// RUN: %clang -target i386-apple-darwin9 -### -g %s -o BAR 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -mmacosx-version-min=10.5 -### -g %s 
-o BAR 2> %t.log
 // RUN: grep -E '".*dsymutil(\.exe)?" "-o" "BAR.dSYM" "BAR"' %t.log
-// RUN: %clang -target i386-apple-darwin9 -### -g -filelist FOO %s -o BAR 2> 
%t.log
+// RUN: %clang -target i386-apple-darwin9 -mmacosx-version-min=10.5 -### -g 
-filelist FOO %s -o BAR 2> %t.log
 // RUN: grep -E '".*dsymutil(\.exe)?" "-o" "BAR.dSYM" "BAR"' %t.log
 
 // Check linker changes that came with new linkedit format.
@@ -71,26 +71,26 @@
 
 // LINK_IOSSIM_ARM64: "-platform_version" "ios-simulator" "15.0.0" "15.0.0"
 
-// RUN: %clang -target i386-apple-darwin9 -### -fpie %t.o 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -mmacosx-version-min=10.5 -### -fpie 
%t.o 2> %t.log
 // RUN: FileCheck -check-prefix=LINK_EXPLICIT_PIE %s < %t.log
 //
 // LINK_EXPLICIT_PIE: {{ld(.exe)?"}}
 // LINK_EXPLICIT_PIE: "-pie"
 
-// RUN: %clang -target i386-apple-darwin9 -### -fno-pie %t.o 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -mmacosx-version-min=10.5 -### 
-fno-pie %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=LINK_EXPLICIT_NO_PIE %s < %t.log
 //
 // LINK_EXPLICIT_NO_PIE: {{ld(.exe)?"}}
 // LINK_EXPLICIT_NO_PIE: "-no_pie"
 
-// RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
+// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -### 
%t.o \
 // RUN:   -fuse-ld= -mlinker-version=100 2> %t.log
 // RUN: FileCheck -check-prefix=LINK_NEWER_DEMANGLE %s < %t.log
 //
 // LINK_NEWER_DEMANGLE: {{ld(.exe)?"}}
 // LINK_NEWER_DEMANGLE: "-demangle"
 
-// RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
+// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -### 
%t.o \
 // RUN:   -fuse-ld= -mlinker-version=100 -Wl,--no-demangle 2> %t.log
 // RUN: FileCheck -check-prefix=LINK_NEWER_NODEMANGLE %s < %t.log
 //
@@ -98,7 +98,7 @@
 // LINK_NEWER_NODEMANGLE-NOT: "-demangle"
 // LINK_NEWER_NODEMANGLE: "-lSystem"
 
-// RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
+// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -### 
%t.o \
 // RUN:   -fuse-ld= -mlinker-version=95 2> %t.log
 // RUN: FileCheck -check-prefix=LINK_OLDER_NODEMANGLE %s < %t.log
 //
@@ -106,7 +106,7 @@
 // LINK_OLDER_NODEMANGLE-NOT: "-demangle"
 // LINK_OLDER_NODEMANGLE: "-lSystem"
 
-// RUN: %clang -target x86_64-apple-darwin10 -### %s \
+// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -### %s 
\
 // RUN:   -fuse-ld= -mlinker-version=117 -flto 2> %t.log
 // RUN: cat %t.log
 // RUN: FileCheck -check-prefix=LINK_OBJECT_LTO_PATH %s < %t.log
@@ -114,7 +114,7 @@
 // LINK_OBJECT_LTO_PATH: {{ld(.exe)?"}}
 // LINK_OBJECT_LTO_PATH: "-object_path_lto"
 
-// RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
+// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -### 
%t.o \
 // RUN:   -force_load a -force_load b 2> %t.log
 // RUN: cat %t.log
 // RUN: FileCheck -check-prefix=FORCE_LOAD %s < %t.log
@@ -122,21 +122,21 @@
 // FORCE_LOAD: {{ld(.exe)?"}}
 // FORCE_LOAD: "-force_load" "a" "-force_load" "b"
 
-// RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
+// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -### 
%t.o \
 // RUN:   -lazy_framework Framework 2> %t.log
 //
 // RUN: FileCheck -check-prefix=LINK_LAZY_FRAMEWORK %s < %t.log
 // LINK_LAZY_FRAMEWORK: {{ld(.exe)?"}}
 // LINK_LAZY_FRAMEWORK: "-laz...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/186683
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to