diff --git a/clang/lib/Driver/ToolChains/Darwin.h b/clang/lib/Driver/ToolChains/Darwin.h index 64c252efea7d..e67b2c5c87cd 100644 --- a/clang/lib/Driver/ToolChains/Darwin.h +++ b/clang/lib/Driver/ToolChains/Darwin.h @@ -436,7 +436,11 @@ public: bool isMacosxVersionLT(unsigned V0, unsigned V1 = 0, unsigned V2 = 0) const { assert(isTargetMacOS() && getTriple().isMacOSX() && "Unexpected call for non OS X target!"); - VersionTuple MinVers = getTriple().getMinimumSupportedOSVersion(); + // The effective triple might not be initialized yet, so construct a + // pseudo-effective triple to get the minimum supported OS version. + VersionTuple MinVers = + llvm::Triple(getTriple().getArchName(), "apple", "macos") + .getMinimumSupportedOSVersion(); return (!MinVers.empty() && MinVers > TargetVersion ? MinVers : TargetVersion) < VersionTuple(V0, V1, V2); diff --git a/clang/test/Driver/macos-apple-silicon-slice-link-libs-darwin-only.cpp b/clang/test/Driver/macos-apple-silicon-slice-link-libs-darwin-only.cpp new file mode 100644 index 000000000000..ec3b710c4da8 --- /dev/null +++ b/clang/test/Driver/macos-apple-silicon-slice-link-libs-darwin-only.cpp @@ -0,0 +1,6 @@ +// RUN: %clang -### -arch arm64 -mmacosx-version-min=10.7 %s 2>&1 | FileCheck -check-prefix=ARM64-10_7 %s +// RUN: %clang -### -arch x86_64 -mmacosx-version-min=10.7 %s 2>&1 | FileCheck -check-prefix=x86_64-10_7 %s +// REQUIRES: system-darwin + +// ARM64-10_7-NOT: -lcrt1.10.6.o +// x86_64-10_7: -lcrt1.10.6.o 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 522fda34987e..4a2a029c736f 100644 --- a/clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp +++ b/clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp @@ -1,5 +1,6 @@ // 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 // RUN: %clang -### -target arm64-apple-macos10.5 %s 2>&1 | FileCheck -check-prefix=ARM64-10_5 %s // RUN: %clang -### -target x86_64-apple-macos10.5 %s 2>&1 | FileCheck -check-prefix=x86_64-10_5 %s