https://github.com/carlocab created https://github.com/llvm/llvm-project/pull/186683
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. >From 3c25c74d606759d379daf7a849e49240ed15bbd4 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <[email protected]> Date: Mon, 16 Mar 2026 00:43:36 +0800 Subject: [PATCH] [clang][Driver][Darwin] Use `xcselect` for `*-apple-darwin*` targets too 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. --- clang/lib/Driver/ToolChains/Darwin.cpp | 88 ++++++++++++++----- clang/test/Driver/arc.c | 10 +-- .../attr-availability-erroneous-diags.c | 2 +- clang/test/Driver/clang-g-opts.c | 4 +- clang/test/Driver/clang-translation.c | 14 +-- clang/test/Driver/darwin-builtin-modules.c | 2 +- clang/test/Driver/darwin-debug-flags.c | 6 +- .../Driver/darwin-header-search-system.cpp | 10 ++- clang/test/Driver/darwin-ld.c | 72 +++++++-------- clang/test/Driver/darwin-objc-options.m | 16 ++-- clang/test/Driver/darwin-version.c | 26 +++--- clang/test/Driver/debug-options.c | 22 ++--- clang/test/Driver/fsanitize-ignorelist.c | 2 +- .../macos-apple-silicon-slice-link-libs.cpp | 2 +- clang/test/Driver/target-triple-deployment.c | 2 +- clang/test/Driver/xcselect.c | 35 +++++++- 16 files changed, 197 insertions(+), 116 deletions(-) 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: "-lazy_framework" "Framework" -// 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_library Library 2> %t.log // // RUN: FileCheck -check-prefix=LINK_LAZY_LIBRARY %s < %t.log // LINK_LAZY_LIBRARY: {{ld(.exe)?"}} // LINK_LAZY_LIBRARY: "-lazy_library" "Library" -// RUN: %clang -target x86_64-apple-darwin10 -fuse-ld= -mlinker-version=400 -### %t.o 2> %t.log +// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -fuse-ld= -mlinker-version=400 -### %t.o 2> %t.log // RUN: %clang -target x86_64-apple-macosx10.7 -fuse-ld= -mlinker-version=400 -### %t.o 2>> %t.log // RUN: FileCheck -check-prefix=LINK_VERSION_MIN %s < %t.log // LINK_VERSION_MIN: {{ld(.exe)?"}} @@ -151,7 +151,7 @@ // LINK_VERSION_MIN_MACABI-NOT: macosx_version_min // LINK_VERSION_MIN_MACABI-NOT: macos_version_min -// RUN: %clang -target x86_64-apple-darwin12 -### %t.o 2> %t.log +// RUN: %clang -target x86_64-apple-darwin12 -mmacosx-version-min=10.8 -### %t.o 2> %t.log // RUN: FileCheck -check-prefix=LINK_NO_CRT1 %s < %t.log // LINK_NO_CRT1-NOT: crt @@ -228,12 +228,12 @@ // LINK_WATCHOS_KEXT: libclang_rt.cc_kext_watchos.a // LINK_WATCHOS_KEXT: libclang_rt.watchos.a -// RUN: %clang -target i386-apple-darwin12 -pg -### %t.o 2> %t.log +// RUN: %clang -target i386-apple-darwin12 -mmacosx-version-min=10.8 -pg -### %t.o 2> %t.log // RUN: FileCheck -check-prefix=LINK_PG %s < %t.log // LINK_PG: -lgcrt1.o // LINK_PG: -no_new_main -// RUN: not %clang -target i386-apple-darwin13 -pg -### %t.o 2> %t.log +// RUN: not %clang -target i386-apple-darwin13 -mmacosx-version-min=10.9 -pg -### %t.o 2> %t.log // RUN: FileCheck -check-prefix=LINK_PG_NO_SUPPORT_OSX %s < %t.log // LINK_PG_NO_SUPPORT_OSX: error: the clang compiler does not support -pg option on versions of OS X @@ -259,28 +259,28 @@ // RUN: FileCheck -check-prefix=LINK_NO_OSX_ARM64_LIBGCC_S %s < %t.log // LINK_NO_OSX_ARM64_LIBGCC_S-NOT: lgcc_s.1 -// RUN: %clang -target x86_64-apple-darwin12 -rdynamic -### %t.o \ +// RUN: %clang -target x86_64-apple-darwin12 -mmacosx-version-min=10.8 -rdynamic -### %t.o \ // RUN: -fuse-ld= -mlinker-version=100 2> %t.log // RUN: FileCheck -check-prefix=LINK_NO_EXPORT_DYNAMIC %s < %t.log // LINK_NO_EXPORT_DYNAMIC: {{ld(.exe)?"}} // LINK_NO_EXPORT_DYNAMIC-NOT: "-export_dynamic" -// RUN: %clang -target x86_64-apple-darwin12 -rdynamic -### %t.o \ +// RUN: %clang -target x86_64-apple-darwin12 -mmacosx-version-min=10.8 -rdynamic -### %t.o \ // RUN: -fuse-ld= -mlinker-version=137 2> %t.log // RUN: FileCheck -check-prefix=LINK_EXPORT_DYNAMIC %s < %t.log -// RUN: %clang -target x86_64-apple-darwin12 -rdynamic -### %t.o \ +// RUN: %clang -target x86_64-apple-darwin12 -mmacosx-version-min=10.8 -rdynamic -### %t.o \ // RUN: -fuse-ld=lld -B%S/Inputs/lld -mlinker-version=100 2> %t.log // RUN: FileCheck -check-prefix=LINK_EXPORT_DYNAMIC %s < %t.log // LINK_EXPORT_DYNAMIC: {{ld(.exe)?"}} // LINK_EXPORT_DYNAMIC: "-export_dynamic" -// RUN: %clang -target x86_64h-apple-darwin -### %t.o 2> %t.log +// RUN: %clang -target x86_64h-apple-darwin -mmacosx-version-min=10.5 -### %t.o 2> %t.log // RUN: FileCheck -check-prefix=LINK_X86_64H_ARCH %s < %t.log // // LINK_X86_64H_ARCH: {{ld(.exe)?"}} // LINK_X86_64H_ARCH: "x86_64h" -// RUN: %clang -target x86_64-apple-darwin -arch x86_64 -arch x86_64h -### %t.o 2> %t.log +// RUN: %clang -target x86_64-apple-darwin -mmacosx-version-min=10.5 -arch x86_64 -arch x86_64h -### %t.o 2> %t.log // RUN: FileCheck -check-prefix=LINK_X86_64H_MULTIARCH %s < %t.log // // LINK_X86_64H_MULTIARCH: {{ld(.exe)?"}} @@ -322,25 +322,25 @@ // LINK_WATCHOS_SIMULATOR_VERSION_MIN: -watchos_simulator_version_min // Check -iframework gets forward to ld as -F -// RUN: %clang -target x86_64-apple-darwin %s -iframework Bar -framework Foo -### 2>&1 | \ +// RUN: %clang -target x86_64-apple-darwin -mmacosx-version-min=10.5 %s -iframework Bar -framework Foo -### 2>&1 | \ // RUN: FileCheck --check-prefix=LINK-IFRAMEWORK %s // LINK-IFRAMEWORK: {{ld(.exe)?"}} // LINK-IFRAMEWORK: "-FBar" // Check ld64 accepts up to 5 digits with no extra characters -// RUN: %clang -target x86_64-apple-darwin12 %s -### -o %t \ +// RUN: %clang -target x86_64-apple-darwin12 -mmacosx-version-min=10.8 %s -### -o %t \ // RUN: -fuse-ld= -mlinker-version=133.3 2> %t.log -// RUN: %clang -target x86_64-apple-darwin12 %s -### -o %t \ +// RUN: %clang -target x86_64-apple-darwin12 -mmacosx-version-min=10.8 %s -### -o %t \ // RUN: -fuse-ld= -mlinker-version=133.3.0 2>> %t.log -// RUN: %clang -target x86_64-apple-darwin12 %s -### -o %t \ +// RUN: %clang -target x86_64-apple-darwin12 -mmacosx-version-min=10.8 %s -### -o %t \ // RUN: -fuse-ld= -mlinker-version=133.3.0.1 2>> %t.log -// RUN: not %clang -target x86_64-apple-darwin12 %s -### -o %t \ +// RUN: not %clang -target x86_64-apple-darwin12 -mmacosx-version-min=10.8 %s -### -o %t \ // RUN: -fuse-ld= -mlinker-version=133.3.0.1.2 2>> %t.log -// RUN: not %clang -target x86_64-apple-darwin12 %s -### -o %t \ +// RUN: not %clang -target x86_64-apple-darwin12 -mmacosx-version-min=10.8 %s -### -o %t \ // RUN: -fuse-ld= -mlinker-version=133.3.0.1.2.6 2>> %t.log -// RUN: not %clang -target x86_64-apple-darwin12 %s -### -o %t \ +// RUN: not %clang -target x86_64-apple-darwin12 -mmacosx-version-min=10.8 %s -### -o %t \ // RUN: -fuse-ld= -mlinker-version=133.3.0.1.a 2>> %t.log -// RUN: not %clang -target x86_64-apple-darwin12 %s -### -o %t \ +// RUN: not %clang -target x86_64-apple-darwin12 -mmacosx-version-min=10.8 %s -### -o %t \ // RUN: -fuse-ld= -mlinker-version=133.3.0.1a 2>> %t.log // RUN: FileCheck -check-prefix=LINK_VERSION_DIGITS %s < %t.log // LINK_VERSION_DIGITS-NOT: invalid version number in '-mlinker-version=133.3' @@ -351,25 +351,25 @@ // LINK_VERSION_DIGITS: invalid version number in '-mlinker-version=133.3.0.1.a' // LINK_VERSION_DIGITS: invalid version number in '-mlinker-version=133.3.0.1a' -// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -### %t.o 2> %t.log +// RUN: %clang -target x86_64-apple-darwin12 -mmacosx-version-min=10.8 -fprofile-instr-generate -### %t.o 2> %t.log // RUN: FileCheck -check-prefix=PROFILE_SECTALIGN %s < %t.log // RUN: %clang -target arm64-apple-ios12 -fprofile-instr-generate -### %t.o 2> %t.log // RUN: FileCheck -check-prefix=PROFILE_SECTALIGN %s < %t.log // PROFILE_SECTALIGN: "-sectalign" "__DATA" "__llvm_prf_cnts" "0x4000" "-sectalign" "__DATA" "__llvm_prf_bits" "0x4000" "-sectalign" "__DATA" "__llvm_prf_data" "0x4000" -// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate --coverage -### %t.o 2> %t.log +// RUN: %clang -target x86_64-apple-darwin12 -mmacosx-version-min=10.8 -fprofile-instr-generate --coverage -### %t.o 2> %t.log // RUN: FileCheck -check-prefix=NO_PROFILE_EXPORT %s < %t.log // NO_PROFILE_EXPORT-NOT: "-exported_symbol" // -// RUN: %clang -target x86_64-apple-darwin12 --coverage -exported_symbols_list /dev/null -### %t.o 2> %t.log +// RUN: %clang -target x86_64-apple-darwin12 -mmacosx-version-min=10.8 --coverage -exported_symbols_list /dev/null -### %t.o 2> %t.log // RUN: FileCheck -check-prefix=GCOV_EXPORT %s < %t.log -// RUN: %clang -target x86_64-apple-darwin12 -fprofile-arcs -Wl,-exported_symbols_list,/dev/null -### %t.o 2> %t.log +// RUN: %clang -target x86_64-apple-darwin12 -mmacosx-version-min=10.8 -fprofile-arcs -Wl,-exported_symbols_list,/dev/null -### %t.o 2> %t.log // RUN: FileCheck -check-prefix=GCOV_EXPORT %s < %t.log -// RUN: %clang -target x86_64-apple-darwin12 -fprofile-arcs -Wl,-exported_symbol,foo -### %t.o 2> %t.log +// RUN: %clang -target x86_64-apple-darwin12 -mmacosx-version-min=10.8 -fprofile-arcs -Wl,-exported_symbol,foo -### %t.o 2> %t.log // RUN: FileCheck -check-prefix=GCOV_EXPORT %s < %t.log -// RUN: %clang -target x86_64-apple-darwin12 -fprofile-arcs -Xlinker -exported_symbol -Xlinker foo -### %t.o 2> %t.log +// RUN: %clang -target x86_64-apple-darwin12 -mmacosx-version-min=10.8 -fprofile-arcs -Xlinker -exported_symbol -Xlinker foo -### %t.o 2> %t.log // RUN: FileCheck -check-prefix=GCOV_EXPORT %s < %t.log -// RUN: %clang -target x86_64-apple-darwin12 -fprofile-arcs -Xlinker -exported_symbols_list -Xlinker /dev/null -### %t.o 2> %t.log +// RUN: %clang -target x86_64-apple-darwin12 -mmacosx-version-min=10.8 -fprofile-arcs -Xlinker -exported_symbols_list -Xlinker /dev/null -### %t.o 2> %t.log // RUN: FileCheck -check-prefix=GCOV_EXPORT %s < %t.log // GCOV_EXPORT: "-exported_symbol" "___gcov_dump" // GCOV_EXPORT: "-exported_symbol" "___gcov_reset" diff --git a/clang/test/Driver/darwin-objc-options.m b/clang/test/Driver/darwin-objc-options.m index 8721fbc1ef1e2..d182323317a43 100644 --- a/clang/test/Driver/darwin-objc-options.m +++ b/clang/test/Driver/darwin-objc-options.m @@ -1,6 +1,6 @@ // Check miscellaneous Objective-C options. -// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \ +// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -S -### %s \ // RUN: -arch x86_64 -fobjc-abi-version=1 2> %t // RUN: FileCheck --check-prefix CHECK-CHECK-X86_64_ABI1 < %t %s @@ -9,7 +9,7 @@ // CHECK-CHECK-X86_64_ABI1-NOT: -fobjc-dispatch-method // CHECK-CHECK-X86_64_ABI1: darwin-objc-options -// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \ +// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -S -### %s \ // RUN: -arch i386 -fobjc-abi-version=2 2> %t // RUN: FileCheck --check-prefix CHECK-CHECK-I386_ABI2 < %t %s @@ -20,7 +20,7 @@ // CHECK-CHECK-I386_ABI2-NOT: -fobjc-dispatch-method // CHECK-CHECK-I386_ABI2: darwin-objc-options -// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \ +// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -S -### %s \ // RUN: -arch i386 -fobjc-runtime=ios-5.0 2> %t // RUN: FileCheck --check-prefix CHECK-CHECK-I386_IOS < %t %s @@ -33,8 +33,8 @@ /// Don't add -fobjc-runtime for non-ObjC input. // RUN: touch %t.c -// RUN: %clang -target x86_64-apple-darwin -x objective-c -S -### %t.c 2>&1 | FileCheck --check-prefix=F %s -// RUN: %clang -target x86_64-apple-darwin -S -### %t.c 2>&1 | FileCheck --check-prefix=NO_F %s +// RUN: %clang -target x86_64-apple-darwin -mmacosx-version-min=10.6 -x objective-c -S -### %t.c 2>&1 | FileCheck --check-prefix=F %s +// RUN: %clang -target x86_64-apple-darwin -mmacosx-version-min=10.6 -S -### %t.c 2>&1 | FileCheck --check-prefix=NO_F %s // F: -fobjc-runtime= // NO_F-NOT: -fobjc-runtime= @@ -42,14 +42,14 @@ // RUN: %clang -target i386-apple-ios7 -S -### %s // Add -fcompatibility-qualified-id-block-type-checking only on Darwin. -// RUN: %clang -target x86_64-apple-darwin10 -### %s 2>&1 | FileCheck --check-prefix=DARWIN_COMPATIBILITY %s +// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -### %s 2>&1 | FileCheck --check-prefix=DARWIN_COMPATIBILITY %s // RUN: %clang -target x86_64-linux-gnu -### %s 2>&1 | FileCheck --check-prefix=OTHER_COMPATIBILITY %s // DARWIN_COMPATIBILITY: -fcompatibility-qualified-id-block-type-checking // OTHER_COMPATIBILITY-NOT: -fcompatibility-qualified-id-block-type-checking // Add -fvisibility-inlines-hidden-static-local-var on Darwin. -// RUN: %clang -target x86_64-apple-darwin10 -### %s 2>&1 | FileCheck --check-prefix=DARWIN_INLINES_HIDDEN %s -// RUN: %clang -target x86_64-apple-darwin10 -fno-visibility-inlines-hidden-static-local-var -### %s 2>&1 | FileCheck --check-prefix=DARWIN_INLINES_HIDDEN_EXPLICIT_NO %s +// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -### %s 2>&1 | FileCheck --check-prefix=DARWIN_INLINES_HIDDEN %s +// RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -fno-visibility-inlines-hidden-static-local-var -### %s 2>&1 | FileCheck --check-prefix=DARWIN_INLINES_HIDDEN_EXPLICIT_NO %s // RUN: %clang -target x86_64-linux-gnu -### %s 2>&1 | FileCheck --check-prefix=NO_DARWIN_INLINES_HIDDEN %s // DARWIN_INLINES_HIDDEN: -fvisibility-inlines-hidden-static-local-var // DARWIN_INLINES_HIDDEN_EXPLICIT_NO-NOT: -fvisibility-inlines-hidden-static-local-var diff --git a/clang/test/Driver/darwin-version.c b/clang/test/Driver/darwin-version.c index 9b9c6034bb75d..3eac8c59513d9 100644 --- a/clang/test/Driver/darwin-version.c +++ b/clang/test/Driver/darwin-version.c @@ -60,23 +60,25 @@ // RUN: FileCheck --check-prefix=CHECK-VERSION-IOS12 %s // CHECK-VERSION-IOS12: thumbv7-apple-ios9.0.0 -// RUN: %clang -target i686-apple-darwin8 -c %s -### 2>&1 | \ -// RUN: FileCheck --check-prefix=CHECK-VERSION-OSX4 %s +// xcselect's SDK inference (priority #3) supersedes inferDeploymentTargetFromArch +// (priority #4), so these darwinN → macOS version tests don't apply with xcselect. +// RUN: %if !xcselect %{ %clang -target i686-apple-darwin8 -c %s -### 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-VERSION-OSX4 %s %} // RUN: %clang -target i686-apple-darwin9 -mmacos-version-min=10.4 -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-OSX4 %s // CHECK-VERSION-OSX4: "i686-apple-macosx10.4.0" -// RUN: %clang -target i686-apple-darwin9 -c %s -### 2>&1 | \ -// RUN: FileCheck --check-prefix=CHECK-VERSION-OSX5 %s +// RUN: %if !xcselect %{ %clang -target i686-apple-darwin9 -c %s -### 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-VERSION-OSX5 %s %} // RUN: %clang -target i686-apple-darwin9 -mmacos-version-min=10.5 -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-OSX5 %s // CHECK-VERSION-OSX5: "i686-apple-macosx10.5.0" -// RUN: %clang -target i686-apple-darwin10 -c %s -### 2>&1 | \ -// RUN: FileCheck --check-prefix=CHECK-VERSION-OSX6 %s +// RUN: %if !xcselect %{ %clang -target i686-apple-darwin10 -c %s -### 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-VERSION-OSX6 %s %} // RUN: %clang -target i686-apple-darwin9 -mmacos-version-min=10.6 -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-OSX6 %s // CHECK-VERSION-OSX6: "i686-apple-macosx10.6.0" -// RUN: %clang -target x86_64-apple-darwin14 -c %s -### 2>&1 | \ -// RUN: FileCheck --check-prefix=CHECK-VERSION-OSX10 %s +// RUN: %if !xcselect %{ %clang -target x86_64-apple-darwin14 -c %s -### 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-VERSION-OSX10 %s %} // RUN: %clang -target x86_64-apple-darwin -mmacos-version-min=10.10 -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-VERSION-OSX10 %s // RUN: %clang -target x86_64-apple-darwin -mmacos-version-min=10.10 -c %s -### 2>&1 | \ @@ -189,8 +191,8 @@ // "darwin" always back to the -m<os>version-min and environment: -// RUN: %clang -target x86_64-apple-darwin14 -c %s -### 2>&1 | \ -// RUN: FileCheck --check-prefix=CHECK-VERSION-TDARWIN-FALL1 %s +// RUN: %if !xcselect %{ %clang -target x86_64-apple-darwin14 -c %s -### 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-VERSION-TDARWIN-FALL1 %s %} // CHECK-VERSION-TDARWIN-FALL1: "x86_64-apple-macosx10.10.0" // RUN: %clang -target x86_64-apple-darwin14 -miphoneos-version-min=10.1 -c %s -### 2>&1 | \ @@ -326,8 +328,8 @@ // RUN: %clang -target x86_64-apple-macos11 -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-MACOS11 %s -// RUN: %clang -target x86_64-apple-darwin20 -c %s -### 2>&1 | \ -// RUN: FileCheck --check-prefix=CHECK-MACOS11 %s +// RUN: %if !xcselect %{ %clang -target x86_64-apple-darwin20 -c %s -### 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-MACOS11 %s %} // RUN: %clang -target x86_64-apple-darwin -mmacos-version-min=11 -c %s -### 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-MACOS11 %s // CHECK-MACOS11: "x86_64-apple-macosx11.0.0" diff --git a/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c index 92179ff9421ad..3e184e472a09d 100644 --- a/clang/test/Driver/debug-options.c +++ b/clang/test/Driver/debug-options.c @@ -26,27 +26,27 @@ // RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_DWARF4 %s // Darwin. -// RUN: %clang -### -c -g %s -target x86_64-apple-darwin14 2>&1 \ +// RUN: %clang -### -c -g %s -target x86_64-apple-darwin14 -mmacosx-version-min=10.10 2>&1 \ // RUN: | FileCheck -check-prefix=G_STANDALONE \ // RUN: -check-prefix=G_DWARF2 \ // RUN: -check-prefix=G_LLDB %s -// RUN: %clang -### -c -g %s -target x86_64-apple-darwin16 2>&1 \ +// RUN: %clang -### -c -g %s -target x86_64-apple-darwin16 -mmacosx-version-min=10.12 2>&1 \ // RUN: | FileCheck -check-prefix=G_STANDALONE \ // RUN: -check-prefix=G_DWARF4 \ // RUN: -check-prefix=G_LLDB %s -// RUN: %clang -### -c -g2 %s -target x86_64-apple-darwin16 2>&1 \ +// RUN: %clang -### -c -g2 %s -target x86_64-apple-darwin16 -mmacosx-version-min=10.12 2>&1 \ // RUN: | FileCheck -check-prefix=G_STANDALONE \ // RUN: -check-prefix=G_DWARF4 %s -// RUN: %clang -### -c -g3 %s -target x86_64-apple-darwin16 2>&1 \ +// RUN: %clang -### -c -g3 %s -target x86_64-apple-darwin16 -mmacosx-version-min=10.12 2>&1 \ // RUN: | FileCheck -check-prefix=G_STANDALONE \ // RUN: -check-prefix=G_DWARF4 %s -// RUN: %clang -### -c -ggdb %s -target x86_64-apple-darwin16 2>&1 \ +// RUN: %clang -### -c -ggdb %s -target x86_64-apple-darwin16 -mmacosx-version-min=10.12 2>&1 \ // RUN: | FileCheck -check-prefix=G_STANDALONE \ // RUN: -check-prefix=G_DWARF4 \ // RUN: -check-prefix=G_GDB %s -// RUN: %clang -### -c -ggdb1 %s -target x86_64-apple-darwin16 2>&1 \ +// RUN: %clang -### -c -ggdb1 %s -target x86_64-apple-darwin16 -mmacosx-version-min=10.12 2>&1 \ // RUN: | FileCheck -check-prefix=GLTO_ONLY %s -// RUN: %clang -### -c -ggdb3 %s -target x86_64-apple-darwin16 2>&1 \ +// RUN: %clang -### -c -ggdb3 %s -target x86_64-apple-darwin16 -mmacosx-version-min=10.12 2>&1 \ // RUN: | FileCheck -check-prefix=G_STANDALONE \ // RUN: -check-prefix=G_DWARF4 %s // RUN: %clang -### -c -g %s -target x86_64-apple-macosx10.11 2>&1 \ @@ -94,10 +94,10 @@ // RUN: -check-prefix=G_DWARF5 %s // // RUN: %clang -### -c -fsave-optimization-record %s \ -// RUN: -target x86_64-apple-darwin 2>&1 \ +// RUN: -target x86_64-apple-darwin -mmacosx-version-min=10.5 2>&1 \ // RUN: | FileCheck -check-prefix=GLTO_ONLY %s // RUN: %clang -### -c -g -fsave-optimization-record %s \ -// RUN: -target x86_64-apple-darwin 2>&1 \ +// RUN: -target x86_64-apple-darwin -mmacosx-version-min=10.5 2>&1 \ // RUN: | FileCheck -check-prefix=G_STANDALONE %s // FreeBSD. @@ -213,7 +213,7 @@ // RUN: | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s // RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-linux-gnu 2>&1 \ // RUN: | FileCheck -check-prefix=G_ONLY %s -// RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-apple-darwin16 2>&1 \ +// RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-apple-darwin16 -mmacosx-version-min=10.12 2>&1 \ // RUN: | FileCheck -check-prefix=G_STANDALONE -check-prefix=G_DWARF4 %s // RUN: %clang -### -c -gline-tables-only -g %s -target i686-pc-openbsd 2>&1 \ // RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s @@ -228,7 +228,7 @@ // RUN: | FileCheck -check-prefix=GLIO_ONLY_DWARF2 %s // RUN: %clang -### -c -gline-directives-only -g %s -target x86_64-linux-gnu 2>&1 \ // RUN: | FileCheck -check-prefix=G_ONLY %s -// RUN: %clang -### -c -gline-directives-only -g %s -target x86_64-apple-darwin16 2>&1 \ +// RUN: %clang -### -c -gline-directives-only -g %s -target x86_64-apple-darwin16 -mmacosx-version-min=10.12 2>&1 \ // RUN: | FileCheck -check-prefix=G_STANDALONE -check-prefix=G_DWARF4 %s // RUN: %clang -### -c -gline-directives-only -g %s -target i686-pc-openbsd 2>&1 \ // RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s diff --git a/clang/test/Driver/fsanitize-ignorelist.c b/clang/test/Driver/fsanitize-ignorelist.c index 7dd666a453198..9ee38468952c0 100644 --- a/clang/test/Driver/fsanitize-ignorelist.c +++ b/clang/test/Driver/fsanitize-ignorelist.c @@ -25,7 +25,7 @@ // RUN: %clang --target=x86_64-linux-gnu -fsanitize=nullability -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-UBSAN-IGNORELIST --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-ignorelist= // RUN: %clang --target=x86_64-linux-gnu -fsanitize=undefined -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-UBSAN-IGNORELIST --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-ignorelist= // RUN: %clang --target=x86_64-linux-gnu -fsanitize=alignment -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-UBSAN-IGNORELIST --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-ignorelist= -// RUN: %clang --target=%itanium_abi_triple -fsanitize=float-divide-by-zero -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-UBSAN-IGNORELIST --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-ignorelist= +// RUN: %clang --target=%itanium_abi_triple -fsanitize=float-divide-by-zero -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-UBSAN-IGNORELIST --implicit-check-not=fdepfile-entry={{.*}}ignorelist --implicit-check-not=-fsanitize-ignorelist= // CHECK-DEFAULT-UBSAN-IGNORELIST: -fsanitize-system-ignorelist={{.*}}ubsan_ignorelist.txt // Check that combining ubsan and another sanitizer results in both ignorelists being used. 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 4a2a029c736fc..44ce37740906e 100644 --- a/clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp +++ b/clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp @@ -17,7 +17,7 @@ // RUN: %clang -### -target arm64-apple-macos10.4 -dynamiclib %s 2>&1 | FileCheck -check-prefix=ARM64-10_4-DYNAMICLIB %s // RUN: %clang -### -target arm64-apple-darwin8 -dynamiclib %s 2>&1 | FileCheck -check-prefix=ARM64-10_4-DYNAMICLIB %s // RUN: %clang -### -target x86_64-apple-macos10.4 -dynamiclib %s 2>&1 | FileCheck -check-prefix=x86_64-10_4-DYNAMICLIB %s -// RUN: %clang -### -target x86_64-apple-darwin8 -dynamiclib %s 2>&1 | FileCheck -check-prefix=x86_64-10_4-DYNAMICLIB %s +// RUN: %clang -### -target x86_64-apple-darwin8 -mmacosx-version-min=10.4 -dynamiclib %s 2>&1 | FileCheck -check-prefix=x86_64-10_4-DYNAMICLIB %s // RUN: %clang -### -target arm64-apple-macos10.7 -static %s 2>&1 | FileCheck -check-prefix=STATIC %s // RUN: %clang -### -target x86_64-apple-macos10.7 -static %s 2>&1 | FileCheck -check-prefix=STATIC %s diff --git a/clang/test/Driver/target-triple-deployment.c b/clang/test/Driver/target-triple-deployment.c index 2e29992502ed4..9d045671a9db1 100644 --- a/clang/test/Driver/target-triple-deployment.c +++ b/clang/test/Driver/target-triple-deployment.c @@ -1,6 +1,6 @@ // 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 +// RUN: %clang -fuse-ld= -target x86_64-apple-darwin9 -mmacosx-version-min=10.5 -mlinker-version=400 -### %t.o 2>> %t.log // RUN: %clang -fuse-ld= -target x86_64-apple-macosx10.7 -mlinker-version=400 -### %t.o 2>> %t.log // // RUN: %clang -fuse-ld= -target armv7-apple-ios -mlinker-version=400 -### %t.o 2>> %t.log diff --git a/clang/test/Driver/xcselect.c b/clang/test/Driver/xcselect.c index 01cd4aca5ec23..02d9d3453e1bd 100644 --- a/clang/test/Driver/xcselect.c +++ b/clang/test/Driver/xcselect.c @@ -1,5 +1,34 @@ // REQUIRES: xcselect -// 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" +// xcselect injects -isysroot for -macosx triples. +// RUN: %clang -target arm64-apple-macosx -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=SDK %s +// The darwin version < 20 check only applies to -darwin triples, not -macosx. +// RUN: %clang -target arm64-apple-macosx15 -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=SDK %s + +// xcselect injects -isysroot for -darwin triples that are plausibly macOS. +// RUN: %clang -target x86_64-apple-darwin -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=SDK %s +// RUN: %clang -target arm64-apple-darwin20 -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=SDK %s + +// SDK: "-isysroot" "{{.*}}/SDKs/MacOSX{{([0-9]+(\.[0-9]+)?)?}}.sdk" + +// xcselect does NOT inject -isysroot for triples that aren't plausibly macOS: +// 32-bit ARM was never used for macOS. +// RUN: %clang -target armv7-apple-darwin10 -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=NO-SDK %s +// arm64 with darwin version < 20 predates ARM Macs. +// RUN: %clang -target arm64-apple-darwin19 -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=NO-SDK %s +// A non-macOS -m*-version-min flag signals cross-compilation. +// RUN: %clang -target arm64-apple-darwin -mios-simulator-version-min=15.0 \ +// RUN: -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=NO-SDK %s +// A non-macOS deployment target env var signals cross-compilation. +// RUN: env IPHONEOS_DEPLOYMENT_TARGET=14.0 \ +// RUN: %clang -target x86_64-apple-darwin -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=NO-SDK %s + +// NO-SDK-NOT: "-isysroot" _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
