Skip to content

Commit 92a176b

Browse files
committed
Workaround an issue regarding libXCTest.so
We're seeing an issue where the XCTest library doesn't use absolute paths to link dependent Swift libs on Linux which means we need to explicitly set `LD_LIBRARY_PATH` to work around that.
1 parent bd6487b commit 92a176b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Sources/Commands/Utilities/TestingSupport.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ enum TestingSupport {
133133
if let location = toolchain.xctestPath {
134134
env.prependPath("Path", value: location.pathString)
135135
}
136+
#elseif os(Linux)
137+
var libraryPaths = ["/usr/lib/swift/linux"]
138+
if let path = env["PATH"], let firstPathEntry = path.components(separatedBy: ":").first {
139+
libraryPaths.append("\(firstPathEntry)/../lib/swift/linux")
140+
}
141+
if let originalLibraryPaths = env["LD_LIBRARY_PATH"] {
142+
libraryPaths.append(originalLibraryPaths)
143+
}
144+
// Pass this explicitly on Linux because XCTest started requiring it, rdar://103054033
145+
env["LD_LIBRARY_PATH"] = libraryPaths.joined(separator: ":")
136146
#endif
137147
return env
138148
#else

0 commit comments

Comments
 (0)