[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.
This commit is contained in:
Alex Lorenz 2020-06-29 18:39:26 -07:00
parent 5a5f5350e1
commit 6792a60778
2 changed files with 25 additions and 0 deletions

View File

@ -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();

View File

@ -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"