Skip to content

Commit 6444c13

Browse files
committed
[Build] Provide correct rpath for macOS test bundles
This will allow test bundles to find any linked dylibs in the build directory. <rdar://problem/56793593>
1 parent 81691b9 commit 6444c13

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Sources/Build/BuildPlan.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,8 @@ public final class ProductBuildDescription {
11231123
if buildParameters.triple.isLinux() {
11241124
args += ["-Xlinker", "-rpath=$ORIGIN"]
11251125
} else if buildParameters.triple.isDarwin() {
1126-
args += ["-Xlinker", "-rpath", "-Xlinker", "@loader_path"]
1126+
let rpath = product.type == .test ? "@loader_path/../../../" : "@loader_path"
1127+
args += ["-Xlinker", "-rpath", "-Xlinker", rpath]
11271128
}
11281129
args += ["@\(linkFileListPath.pathString)"]
11291130

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ final class BuildPlanTests: XCTestCase {
609609
"/fake/path/to/swiftc", "-L", "/path/to/build/debug", "-o",
610610
"/path/to/build/debug/PkgPackageTests.xctest/Contents/MacOS/PkgPackageTests", "-module-name",
611611
"PkgPackageTests", "-Xlinker", "-bundle",
612-
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
612+
"-Xlinker", "-rpath", "-Xlinker", "@loader_path/../../../",
613613
"@/path/to/build/debug/PkgPackageTests.product/Objects.LinkFileList",
614614
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
615615
"-target", "x86_64-apple-macosx10.10",

0 commit comments

Comments
 (0)