Skip to content

Commit 0917dc9

Browse files
author
git apple-llvm automerger
committed
Merge commit 'c0662ed83227' from apple/stable/20210107 into swift/release/5.5
2 parents 42cd7a6 + c0662ed commit 0917dc9

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2764,8 +2764,16 @@ void Darwin::addPlatformVersionArgs(const llvm::opt::ArgList &Args,
27642764
}
27652765
CmdArgs.push_back(Args.MakeArgString(SDKVersion.getAsString()));
27662766
} else {
2767-
// Use a blank SDK version if it's not present.
2768-
CmdArgs.push_back("0.0.0");
2767+
// Use an SDK version that's matching the deployment target if the SDK
2768+
// version is missing. This is preferred over an empty SDK version (0.0.0)
2769+
// as the system's runtime might expect the linked binary to contain a
2770+
// valid SDK version in order for the binary to work correctly. It's
2771+
// reasonable to use the deployment target version as a proxy for the
2772+
// SDK version because older SDKs don't guarantee support for deployment
2773+
// targets newer than the SDK versions, so that rules out using some
2774+
// predetermined older SDK version, which leaves the deployment target
2775+
// version as the only reasonable choice.
2776+
CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString()));
27692777
}
27702778
};
27712779
EmitPlatformVersionArg(getOSTargetVersion(), TargetPlatform,

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,7 @@
4848
// RUN: %clang -target x86_64-apple-macos10.13 -mlinker-version=520 \
4949
// RUN: -### %t.o 2>&1 \
5050
// RUN: | FileCheck --check-prefix=NOSDK %s
51-
// NOSDK: "-platform_version" "macos" "10.13.0" "0.0.0"
51+
// RUN: %clang -target x86_64-apple-darwin17 -mlinker-version=520 \
52+
// RUN: -### %t.o 2>&1 \
53+
// RUN: | FileCheck --check-prefix=NOSDK %s
54+
// NOSDK: "-platform_version" "macos" "10.13.0" "10.13.0"

0 commit comments

Comments
 (0)