Skip to content

Commit

Permalink
Workaround an issue regarding libXCTest.so (#5952)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
neonichu authored Dec 8, 2022
1 parent 4111569 commit 5700473
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Sources/Commands/Utilities/TestingSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ enum TestingSupport {
if let location = toolchain.xctestPath {
env.prependPath("Path", value: location.pathString)
}
#elseif os(Linux)
var libraryPaths = ["/usr/lib/swift/linux"]
if let path = env["PATH"], let firstPathEntry = path.components(separatedBy: ":").first {
libraryPaths.append("\(firstPathEntry)/../lib/swift/linux")
}
if let originalLibraryPaths = env["LD_LIBRARY_PATH"] {
libraryPaths.append(originalLibraryPaths)
}
// Pass this explicitly on Linux because XCTest started requiring it, rdar://103054033
env["LD_LIBRARY_PATH"] = libraryPaths.joined(separator: ":")
#endif
return env
#else
Expand Down

0 comments on commit 5700473

Please sign in to comment.