Author: Alex Lorenz
Date: 2022-10-04T10:23:38-07:00
New Revision: 7d85f6b1af26c8f749f0c217d7aae694cc3931eb

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

LOG: [clang][driver][darwin] Ensure that the SDK version passed to 
-platform_version has a minor version number 0

The linker requires at least a "major.minor" for the SDK version, so it will 
fail when we don't have
a minor version in the case we don't actually have an SDK info.

Added: 
    clang/test/Driver/darwin-ld-platform-version-macos-requires-darwin.c

Modified: 
    clang/lib/Driver/ToolChains/Darwin.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 50572ff04ff85..758961d3bf79a 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -3103,6 +3103,8 @@ void Darwin::addPlatformVersionArgs(const 
llvm::opt::ArgList &Args,
 
         if (SDKInfo) {
           VersionTuple SDKVersion = SDKInfo->getVersion().withoutBuild();
+          if (!SDKVersion.getMinor())
+            SDKVersion = VersionTuple(SDKVersion.getMajor(), 0);
           CmdArgs.push_back(Args.MakeArgString(SDKVersion.getAsString()));
         } else {
           // Use an SDK version that's matching the deployment target if the 
SDK

diff  --git 
a/clang/test/Driver/darwin-ld-platform-version-macos-requires-darwin.c 
b/clang/test/Driver/darwin-ld-platform-version-macos-requires-darwin.c
new file mode 100644
index 0000000000000..24c0c0c20b70a
--- /dev/null
+++ b/clang/test/Driver/darwin-ld-platform-version-macos-requires-darwin.c
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: touch %t/f.o
+// RUN: mkdir -p %t/MacOSX12.0.sdk
+
+// RUN: %clang -fuse-ld= -arch arm64 -mlinker-version=520 -isysroot 
%t/MacOSX12.sdk/does-not-exist -### %t/f.o 2>&1 | FileCheck %s
+
+// CHECK: "-platform_version" "macos" "[[NUMBER:[0-9]+]].0.0" "[[NUMBER]].0"
+
+// REQUIRES: system-darwin


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

Reply via email to