[clang] 6792a60 - [darwin][driver] pass the minimum supported OS version to the linker
Alex Lorenz via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 29 19:04:35 PDT 2020
Author: Alex Lorenz
Date: 2020-06-29T19:03:57-07:00
New Revision: 6792a6077889f1ce77a3aa55b3e4fd3f1eb4333b
URL: https://github.com/llvm/llvm-project/commit/6792a6077889f1ce77a3aa55b3e4fd3f1eb4333b
DIFF: https://github.com/llvm/llvm-project/commit/6792a6077889f1ce77a3aa55b3e4fd3f1eb4333b.diff
LOG: [darwin][driver] pass the minimum supported OS version to the linker
if it's newer than the target version
This change ensures that the arm64-apple-macOS slice is linked for
macOS 11 even if the deployment target is earlier than macOS 11.
Added:
Modified:
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-ld-platform-version-macos.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index 4b98fd09b4b0..ad3b3a955d42 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2546,6 +2546,9 @@ void Darwin::addMinVersionArgs(const ArgList &Args,
CmdArgs.push_back("-macosx_version_min");
}
+ VersionTuple MinTgtVers = getEffectiveTriple().getMinimumSupportedOSVersion();
+ if (!MinTgtVers.empty() && MinTgtVers > TargetVersion)
+ TargetVersion = MinTgtVers;
CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString()));
}
@@ -2578,6 +2581,9 @@ void Darwin::addPlatformVersionArgs(const llvm::opt::ArgList &Args,
PlatformName += "-simulator";
CmdArgs.push_back(Args.MakeArgString(PlatformName));
VersionTuple TargetVersion = getTargetVersion().withoutBuild();
+ VersionTuple MinTgtVers = getEffectiveTriple().getMinimumSupportedOSVersion();
+ if (!MinTgtVers.empty() && MinTgtVers > TargetVersion)
+ TargetVersion = MinTgtVers;
CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString()));
if (SDKInfo) {
VersionTuple SDKVersion = SDKInfo->getVersion().withoutBuild();
diff --git a/clang/test/Driver/darwin-ld-platform-version-macos.c b/clang/test/Driver/darwin-ld-platform-version-macos.c
index c1b940a3f35f..5c7af058e462 100644
--- a/clang/test/Driver/darwin-ld-platform-version-macos.c
+++ b/clang/test/Driver/darwin-ld-platform-version-macos.c
@@ -7,9 +7,28 @@
// RUN: env SDKROOT=%S/Inputs/MacOSX10.14.sdk %clang -target x86_64-apple-macos10.13.0.1 -mlinker-version=520 -### %t.o 2>&1 \
// RUN: | FileCheck --check-prefix=LINKER-NEW %s
+// RUN: %clang -target arm64-apple-macos10.13 -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=520 -### %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=ARM64_NEW %s
+// RUN: %clang -target arm64-apple-darwin19 -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=520 -### %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=ARM64_NEW %s
+// RUN: %clang -target arm64-apple-macos11.1 -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=520 -### %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=ARM64_NEW_1 %s
+// RUN: %clang -arch arm64 -mmacosx-version-min=10.15 -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=520 -### %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=ARM64_NEW %s
+// RUN: %clang -target arm64-apple-macos10.13 -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=400 -### %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=ARM64_OLD %s
+// RUN: %clang -arch arm64 -mmacosx-version-min=10.15 -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=400 -### %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=ARM64_OLD %s
+// RUN: %clang -target arm64e-apple-macos10.13 -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=520 -### %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=ARM64_NEW %s
+
// LINKER-OLD: "-macosx_version_min" "10.13.0"
// LINKER-NEW: "-platform_version" "macos" "10.13.0" "10.14"
+// ARM64_NEW: "-platform_version" "macos" "11.0.0" "10.14"
+// ARM64_NEW_1: "-platform_version" "macos" "11.1.0" "10.14"
+// ARM64_OLD: "-macosx_version_min" "11.0.0"
+
// RUN: %clang -target x86_64-apple-macos10.13 -mlinker-version=520 -### %t.o 2>&1 \
// RUN: | FileCheck --check-prefix=NOSDK %s
// NOSDK: "-platform_version" "macos" "10.13.0" "0.0.0"
More information about the cfe-commits
mailing list