Skip to content

Commit 37d3ee5

Browse files
committed
Tweak Swift-in-OS check to account for linker limitations
The backwards-deployment install name trickery we're using doesn't handle "patch" components in version numbers, so we still need to provide an rpath even when deploying to macOS 10.14.4.
1 parent e98eee8 commit 37d3ee5

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

include/swift/Basic/Platform.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ namespace swift {
4545
/// Return true if the given triple represents any simulator.
4646
bool tripleIsAnySimulator(const llvm::Triple &triple);
4747

48-
/// Returns true if the given triple represents an OS that ships with ABI-stable
49-
/// swift libraries (eg. in /usr/lib/swift).
50-
bool tripleHasSwiftInTheOS(const llvm::Triple &triple);
48+
/// Returns true if the given triple represents an OS that ships with
49+
/// ABI-stable swift libraries (eg. in /usr/lib/swift).
50+
bool tripleRequiresRPathForSwiftInOS(const llvm::Triple &triple);
5151

5252
/// Returns the platform name for a given target triple.
5353
///

lib/Basic/Platform.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,20 @@ bool swift::tripleIsAnySimulator(const llvm::Triple &triple) {
5555
}
5656

5757

58-
bool swift::tripleHasSwiftInTheOS(const llvm::Triple &triple) {
59-
unsigned major, minor, revision;
58+
bool swift::tripleRequiresRPathForSwiftInOS(const llvm::Triple &triple) {
6059
if (triple.isMacOSX()) {
61-
triple.getMacOSXVersion(major, minor, revision);
62-
return llvm::VersionTuple(major, minor, revision) >=
63-
llvm::VersionTuple(10, 14, 4);
60+
// macOS 10.14.4 contains a copy of Swift, but the linker will still use an
61+
// rpath-based install name until 10.15.
62+
return triple.isMacOSXVersionLT(10, 15);
63+
6464
} else if (triple.isiOS()) {
65-
triple.getiOSVersion(major, minor, revision);
66-
return llvm::VersionTuple(major, minor, revision) >=
67-
llvm::VersionTuple(12, 2);
65+
return triple.isOSVersionLT(12, 2);
66+
6867
} else if (triple.isWatchOS()) {
69-
triple.getOSVersion(major, minor, revision);
70-
return llvm::VersionTuple(major, minor, revision) >=
71-
llvm::VersionTuple(5, 2);
68+
return triple.isOSVersionLT(5, 2);
7269
}
70+
71+
// Other platforms don't have Swift installed as part of the OS by default.
7372
return false;
7473
}
7574

lib/Driver/DarwinToolChains.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ toolchains::Darwin::addArgsToLinkStdlib(ArgStringList &Arguments,
350350
Arguments.push_back("-rpath");
351351
Arguments.push_back(context.Args.MakeArgString(RuntimeLibPath));
352352

353-
} else if (tripleHasSwiftInTheOS(getTriple()) ||
353+
} else if (!tripleRequiresRPathForSwiftInOS(getTriple()) ||
354354
context.Args.hasArg(options::OPT_no_stdlib_rpath)) {
355355
// If targeting an OS with Swift in /usr/lib/swift, the LC_ID_DYLIB
356356
// install_name the stdlib will be an absolute path like

0 commit comments

Comments
 (0)