Skip to content

[linux] remove absolute rpath of /usr/lib/swift/linux added to many shared libraries #34023

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

Merged
merged 1 commit into from
Oct 19, 2020

Conversation

finagolfin
Copy link
Member

@finagolfin finagolfin commented Sep 22, 2020

This was presumably added as a backup, in case the libraries in a toolchain couldn't be found, but will not work well, so take it out.

Here's a full list of shared library runpaths from the just-released official Swift 5.3 toolchain for linux:

> find swift-5.3-RELEASE-ubuntu20.04/ -name "lib*.so"| xargs readelf -d | ag "File:|runpath"
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/libsourcekitdInProc.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib/swift/linux:/usr/lib/swift/linux]
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/swift/pm/4_2/libPackageDescription.so
 0x000000000000001d (RUNPATH)            Library runpath: [/home/build-user/swift-nightly-install/usr/lib/swift/linux]
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/swift/pm/4/libPackageDescription.so
 0x000000000000001d (RUNPATH)            Library runpath: [/home/build-user/swift-nightly-install/usr/lib/swift/linux]
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/swift/pm/llbuild/libllbuildSwift.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:$ORIGIN/../../linux]
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/swift/pm/llbuild/libllbuild.so
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/swift/linux/libicuucswift.so
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/swift/linux/libswiftRemoteMirror.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:/usr/lib/swift/linux]
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/swift/linux/libdispatch.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN]
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/swift/linux/libBlocksRuntime.so
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/swift/linux/libFoundationNetworking.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN]
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/swift/linux/libicudataswift.so
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/swift/linux/libXCTest.so
 0x000000000000001d (RUNPATH)            Library runpath: [/home/build-user/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux]
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/swift/linux/libswiftDispatch.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN]
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/swift/linux/libswift_Differentiation.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:/usr/lib/swift/linux]
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/swift/linux/lib_InternalSwiftSyntaxParser.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:/usr/lib/swift/linux]
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/swift/linux/libswiftGlibc.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:/usr/lib/swift/linux]
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/swift/linux/libFoundationXML.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN]
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/swift/linux/libFoundation.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN]
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/swift/linux/libswiftSwiftOnoneSupport.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:/usr/lib/swift/linux]
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/swift/linux/libicui18nswift.so
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/swift/linux/libswiftCore.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:/usr/lib/swift/linux]
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/liblldb.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/home/build-user/build/buildbot_linux/llvm-linux-x86_64/./lib]
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/libIndexStore.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib]
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/clang/10.0.0/lib/linux/libclang_rt.hwasan-x86_64.so
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/clang/10.0.0/lib/linux/libclang_rt.ubsan_standalone-x86_64.so
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/clang/10.0.0/lib/linux/libclang_rt.scudo_minimal-x86_64.so
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/clang/10.0.0/lib/linux/libclang_rt.scudo-x86_64.so
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/clang/10.0.0/lib/linux/libclang_rt.ubsan_minimal-x86_64.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/home/build-user/build/buildbot_linux/llvm-linux-x86_64/./lib]
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/clang/10.0.0/lib/linux/libclang_rt.dyndd-x86_64.so
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/clang/10.0.0/lib/linux/libclang_rt.asan-x86_64.so
File: swift-5.3-RELEASE-ubuntu20.04/usr/lib/libswiftDemangle.so
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN:/usr/lib/swift/linux]

If there's any difference between the toolchain being used and the one installed in /usr/lib/swift/linux, say if you download this 5.3 toolchain for linux into your home directory but 5.2.5 is installed in /usr/lib/swift/linux, using that system runpath won't work properly. I checked and all these libraries already have a runpath relative to $ORIGIN, ie locally, so all this absolute path will do is supply the system Swift library if the local one is missing (obviously if the used toolchain is installed in the system, ie /usr/lib/swift/linux, this absolute path is redundant). But since using the system Swift libraries will not work properly if the Swift versions don't match, causing subtle bugs in the worst case, I think it's better not to add this absolute runpath at all.

It was added five years ago by @bitjammer, ad95b5f, and copied to SourceKit a couple years later, a93bddf. I brought up this issue earlier this year, but got no response at the time, so I let it go. I think this is worth getting in and into the 5.3 branch for the next patch release.

@gottesmm and @compnerd, I think this should be removed, similar to the other ELF runpath issues we discussed. @tachoknight, let us know what you think from your Fedora packaging perspective.

…hared libraries

This was presumably added as a backup, in case the libraries in a toolchain
couldn't be found, but will not work well, so take it out.
@finagolfin finagolfin changed the base branch from master to main September 25, 2020 17:39
@gottesmm
Copy link
Contributor

As we discussed offline, can you create a PR against swift-integration-test that validates that the snapshots maintain this property? Then I think you can do cross-repo testing to test it with this PR. Then first merge this and then the integration test one.

@finagolfin
Copy link
Member Author

Will do.

finagolfin added a commit to finagolfin/swift-integration-tests that referenced this pull request Sep 29, 2020
…rom the RUNPATH of several Swift libraries, stays that way.
finagolfin added a commit to finagolfin/swift-integration-tests that referenced this pull request Sep 30, 2020
…rom the RUNPATH of several Swift libraries, stays that way.
@finagolfin
Copy link
Member Author

@drexin, let me know what you think, I'd like to get this into the 5.3.1 patch release.

@drexin
Copy link
Contributor

drexin commented Oct 2, 2020

@swift-ci smoke test

Copy link
Contributor

@drexin drexin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@finagolfin
Copy link
Member Author

Thanks, sometimes adding a comment seems to get the CI to run?

@finagolfin
Copy link
Member Author

I think the CI needs a swift kick. 😉

@drexin
Copy link
Contributor

drexin commented Oct 3, 2020

@swift-ci smoke test

@finagolfin
Copy link
Member Author

Passes CI, ready to merge.

@gottesmm
Copy link
Contributor

@gottesmm
Copy link
Contributor

I validated in the CI job that swift-ci found the appropriate PR on swift-integration-tests.

@finagolfin
Copy link
Member Author

Confirmed that the CI checked out the new integration test and that those tests were run, but the log doesn't list them individually so my new test isn't listed. The Windows CI failure appears unrelated.

@gottesmm gottesmm merged commit 86b7bac into swiftlang:main Oct 19, 2020
gottesmm added a commit to swiftlang/swift-integration-tests that referenced this pull request Oct 19, 2020
Make sure swiftlang/swift#34023, which removes /usr/lib/swift/linux from the RUNPATH of several Swift libraries, stays that way
@finagolfin finagolfin deleted the rpath branch October 20, 2020 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants