Skip to content

Commit 8876f87

Browse files
authored
Remove rpaths to the toolchain libraries (#4208)
This was originally added to enable workflows like `swift run` on systems without Swift libraries in the OS. SwiftPM does not run on any systems old enough anymore at this point, so these rpaths can be removed at this point.
1 parent ae35ad7 commit 8876f87

File tree

2 files changed

+1
-16
lines changed

2 files changed

+1
-16
lines changed

Sources/Build/BuildPlan.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,14 +1351,9 @@ public final class ProductBuildDescription {
13511351
throw InternalError("unexpectedly asked to generate linker arguments for a plugin product")
13521352
}
13531353

1354-
if useStdlibRpath && buildParameters.triple.isDarwin() {
1355-
let stdlib = buildParameters.toolchain.macosSwiftStdlib
1356-
args += ["-Xlinker", "-rpath", "-Xlinker", stdlib.pathString]
1357-
}
1358-
13591354
// When deploying to macOS prior to macOS 12, add an rpath to the
13601355
// back-deployed concurrency libraries.
1361-
if buildParameters.triple.isDarwin(),
1356+
if useStdlibRpath, buildParameters.triple.isDarwin(),
13621357
let macOSSupportedPlatform = self.package.platforms.getDerived(for: .macOS),
13631358
macOSSupportedPlatform.version.major < 12 {
13641359
let backDeployedStdlib = buildParameters.toolchain.macosSwiftStdlib

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ final class BuildPlanTests: XCTestCase {
151151
"-emit-executable",
152152
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
153153
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
154-
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
155154
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift-5.5/macosx",
156155
"-target", defaultTargetTriple, "-Xlinker", "-add_ast_path",
157156
"-Xlinker", "/path/to/build/debug/exe.build/exe.swiftmodule", "-Xlinker", "-add_ast_path",
@@ -469,7 +468,6 @@ final class BuildPlanTests: XCTestCase {
469468
"-o", "/path/to/build/release/exe", "-module-name", "exe", "-emit-executable",
470469
"-Xlinker", "-dead_strip", "-Xlinker", "-rpath", "-Xlinker", "@loader_path",
471470
"@/path/to/build/release/exe.product/Objects.LinkFileList",
472-
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
473471
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift-5.5/macosx",
474472
"-target", defaultTargetTriple,
475473
])
@@ -523,7 +521,6 @@ final class BuildPlanTests: XCTestCase {
523521
"-o", "/path/to/build/release/exe", "-module-name", "exe", "-emit-executable",
524522
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
525523
"@/path/to/build/release/exe.product/Objects.LinkFileList",
526-
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
527524
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift-5.5/macosx",
528525
"-target", defaultTargetTriple,
529526
])
@@ -861,7 +858,6 @@ final class BuildPlanTests: XCTestCase {
861858
"-o", "/path/to/build/debug/exe", "-module-name", "exe", "-emit-executable",
862859
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
863860
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
864-
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
865861
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift-5.5/macosx",
866862
"-target", defaultTargetTriple,
867863
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/exe.build/exe.swiftmodule",
@@ -1027,7 +1023,6 @@ final class BuildPlanTests: XCTestCase {
10271023
"PkgPackageTests", "-Xlinker", "-bundle",
10281024
"-Xlinker", "-rpath", "-Xlinker", "@loader_path/../../../",
10291025
"@/path/to/build/debug/PkgPackageTests.product/Objects.LinkFileList",
1030-
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
10311026
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift-5.5/macosx",
10321027
"-target", "\(hostTriple.tripleString(forPlatformVersion: version))",
10331028
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/Foo.swiftmodule",
@@ -1086,7 +1081,6 @@ final class BuildPlanTests: XCTestCase {
10861081
"-o", "/path/to/build/release/exe", "-module-name", "exe", "-emit-executable",
10871082
"-Xlinker", "-dead_strip", "-Xlinker", "-rpath", "-Xlinker", "@loader_path",
10881083
"@/path/to/build/release/exe.product/Objects.LinkFileList",
1089-
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
10901084
"-target", hostTriple.tripleString(forPlatformVersion: "12.0"),
10911085
])
10921086
#endif
@@ -1191,7 +1185,6 @@ final class BuildPlanTests: XCTestCase {
11911185
"-o", "/path/to/build/debug/exe", "-module-name", "exe", "-emit-executable",
11921186
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
11931187
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
1194-
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
11951188
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift-5.5/macosx",
11961189
"-target", defaultTargetTriple,
11971190
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/exe.build/exe.swiftmodule",
@@ -1298,7 +1291,6 @@ final class BuildPlanTests: XCTestCase {
12981291
"-o", "/path/to/build/debug/Foo", "-module-name", "Foo", "-lBar-Baz", "-emit-executable",
12991292
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
13001293
"@/path/to/build/debug/Foo.product/Objects.LinkFileList",
1301-
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
13021294
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift-5.5/macosx",
13031295
"-target", defaultTargetTriple,
13041296
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/Foo.build/Foo.swiftmodule"
@@ -1311,7 +1303,6 @@ final class BuildPlanTests: XCTestCase {
13111303
"-Xlinker", "-install_name", "-Xlinker", "@rpath/libBar-Baz.dylib",
13121304
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
13131305
"@/path/to/build/debug/Bar-Baz.product/Objects.LinkFileList",
1314-
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
13151306
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift-5.5/macosx",
13161307
"-target", defaultTargetTriple,
13171308
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/Bar.swiftmodule"
@@ -1395,7 +1386,6 @@ final class BuildPlanTests: XCTestCase {
13951386
"-Xlinker", "-install_name", "-Xlinker", "@rpath/liblib.dylib",
13961387
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
13971388
"@/path/to/build/debug/lib.product/Objects.LinkFileList",
1398-
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
13991389
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift-5.5/macosx",
14001390
"-target", defaultTargetTriple,
14011391
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/lib.swiftmodule",

0 commit comments

Comments
 (0)