[clang] c2807b2 - [darwin][driver] fix isMacosxVersionLT minimum supported OS version check

Alex Lorenz via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 13 12:06:52 PDT 2020


Author: Alex Lorenz
Date: 2020-08-13T12:06:45-07:00
New Revision: c2807b2e56c05080354818c221ed4a35abd8a5c8

URL: https://github.com/llvm/llvm-project/commit/c2807b2e56c05080354818c221ed4a35abd8a5c8
DIFF: https://github.com/llvm/llvm-project/commit/c2807b2e56c05080354818c221ed4a35abd8a5c8.diff

LOG: [darwin][driver] fix isMacosxVersionLT minimum supported OS version check

The previous Driver's triple check only worked for -target, but not for -arch -mmacosx-version-min invocations

Added: 
    clang/test/Driver/macos-apple-silicon-slice-link-libs-darwin-only.cpp

Modified: 
    clang/lib/Driver/ToolChains/Darwin.h
    clang/test/Driver/macos-apple-silicon-slice-link-libs.cpp

Removed: 
    


################################################################################
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 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
   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


        


More information about the cfe-commits mailing list