Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libXCTest.so on Linux has no RUNPATH #432

Open
gwynne opened this issue Mar 13, 2023 · 4 comments
Open

libXCTest.so on Linux has no RUNPATH #432

gwynne opened this issue Mar 13, 2023 · 4 comments

Comments

@gwynne
Copy link

gwynne commented Mar 13, 2023

When building on Linux, the libXCTest.so which is installed in /usr/lib/swift/linux/ ends up with no RUNPATHs whatsoever, neither $ORIGIN nor the toolchain's lib install directory. This has the effect of enforcing an entirely artificial link-ordering dependency when building Linux xctest executables due to its dependency on libswift_RegexParser. Control over link ordering is not generally available via SwiftPM, and is in fact actively discouraged by the default usage of swift-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 swiftlang/swift#64312; specific details are given by swiftlang/swift#64312 (comment) and swiftlang/swift#64312 (comment).

@finagolfin
Copy link
Contributor

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.

@finagolfin
Copy link
Contributor

@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.

@compnerd
Copy link
Member

@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).

@finagolfin
Copy link
Contributor

@gwynne, if you submit a pull adding that, we can finally get it in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants