Skip to content

Commit 87b7ee1

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 0c17a70 commit 87b7ee1

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
@@ -46,9 +46,9 @@ namespace swift {
4646
/// Return true if the given triple represents any simulator.
4747
bool tripleIsAnySimulator(const llvm::Triple &triple);
4848

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

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

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
@@ -401,7 +401,7 @@ toolchains::Darwin::addArgsToLinkStdlib(ArgStringList &Arguments,
401401
Arguments.push_back("-rpath");
402402
Arguments.push_back(context.Args.MakeArgString(path));
403403
}
404-
} else if (tripleHasSwiftInTheOS(getTriple()) ||
404+
} else if (!tripleRequiresRPathForSwiftInOS(getTriple()) ||
405405
context.Args.hasArg(options::OPT_no_stdlib_rpath)) {
406406
// If targeting an OS with Swift in /usr/lib/swift, the LC_ID_DYLIB
407407
// install_name the stdlib will be an absolute path like

0 commit comments

Comments
 (0)