Open gwynne opened 1 year ago
I argued about adding $ORIGIN
to this library with @compnerd a couple years ago. While he was open to it, he felt it shouldn't be done here, but in the Swift build script. Removing -no-toolchain-stdlib-rpath
will only help you with local builds and won't work with the official toolchain, as it adds an absolute path from the build host.
@compnerd, just pick one place to add it for ELF platforms like linux, either build-script-impl
or here, and let's finally get this rpath in. I'm not sure if this is precisely the fix for @gwynne's link issues, but we should've done it before anyway.
@gwynne, guessing he's busy, I suggest you submit a pull to add the flags -Xlinker -rpath -Xlinker \$ORIGIN
to the Swift flags passed to XCTest here, as he seemed to want at the time, and get it in before the 5.9 branch.
@buttaface I think that build-script
is the right place for this. We can do it in build-script-impl
or even better would be build-script
as that has been where things are migrating (albeit slowly).
@gwynne, if you submit a pull adding that, we can finally get it in.
When building on Linux, the
libXCTest.so
which is installed in/usr/lib/swift/linux/
ends up with noRUNPATH
s whatsoever, neither$ORIGIN
nor the toolchain's lib install directory. This has the effect of enforcing an entirely artificial link-ordering dependency when building Linuxxctest
executables due to its dependency onlibswift_RegexParser
. Control over link ordering is not generally available via SwiftPM, and is in fact actively discouraged by the default usage ofswift-autolink-extract
. Add to this that there is no attempt even by XCTest itself to guarantee its own build ordering, having relied for some time now on accident and luck to hide the problem, and its seem fairly obvious that the ordering dependency is both unintentional and undesirable.I'm not clear enough on how the Linux toolchain is set up to understand whether the fix is to add a
$ORIGIN
rpath, to remove the-no-toolchain-stdlib-rpath
flag from the XCTest CMake build (both of which successfully solved the linkage problem when I tried them), or some other approach.This issue was revealed by apple/swift#64312; specific details are given by https://github.com/apple/swift/pull/64312#issuecomment-1466935354 and https://github.com/apple/swift/pull/64312#issuecomment-1467017450.