Skip to content

Commit fab8d3d

Browse files
authored
Merge pull request #24787 from apple/on-the-rpath-to-greatness
Upstream Driver changes for Swift-in-Apple-OSs
2 parents 0436589 + 3694686 commit fab8d3d

File tree

8 files changed

+309
-138
lines changed

8 files changed

+309
-138
lines changed

include/swift/Basic/Platform.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ 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
50+
/// ABI-stable swift libraries (eg. in /usr/lib/swift).
51+
bool tripleRequiresRPathForSwiftInOS(const llvm::Triple &triple);
52+
4953
/// Returns the platform name for a given target triple.
5054
///
5155
/// For example, the iOS simulator has the name "iphonesimulator", while real

include/swift/Option/Options.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,12 @@ def static_stdlib: Flag<["-"], "static-stdlib">,
502502
def no_static_stdlib: Flag<["-"], "no-static-stdlib">,
503503
Flags<[HelpHidden,DoesNotAffectIncrementalBuild]>,
504504
HelpText<"Don't statically link the Swift standard library">;
505+
def toolchain_stdlib_rpath: Flag<["-"], "toolchain-stdlib-rpath">,
506+
Flags<[HelpHidden,DoesNotAffectIncrementalBuild]>,
507+
HelpText<"Add an rpath entry for the toolchain's standard library, rather than the OS's">;
508+
def no_stdlib_rpath: Flag<["-"], "no-stdlib-rpath">,
509+
Flags<[HelpHidden,DoesNotAffectIncrementalBuild]>,
510+
HelpText<"Don't add any rpath entries.">;
505511

506512
def static_executable : Flag<["-"], "static-executable">,
507513
HelpText<"Statically link the executable">;

lib/Basic/Platform.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@ bool swift::tripleIsAnySimulator(const llvm::Triple &triple) {
5454
tripleIsAppleTVSimulator(triple);
5555
}
5656

57+
58+
bool swift::tripleRequiresRPathForSwiftInOS(const llvm::Triple &triple) {
59+
if (triple.isMacOSX()) {
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+
64+
} else if (triple.isiOS()) {
65+
return triple.isOSVersionLT(12, 2);
66+
67+
} else if (triple.isWatchOS()) {
68+
return triple.isOSVersionLT(5, 2);
69+
}
70+
71+
// Other platforms don't have Swift installed as part of the OS by default.
72+
return false;
73+
}
74+
5775
DarwinPlatformKind swift::getDarwinPlatformKind(const llvm::Triple &triple) {
5876
if (triple.isiOS()) {
5977
if (triple.isTvOS()) {

0 commit comments

Comments
 (0)