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

[SR-9315] Linux shared libraries contain unnecessary RUNPATH entries #51785

Closed
spevans opened this issue Nov 21, 2018 · 1 comment
Closed

[SR-9315] Linux shared libraries contain unnecessary RUNPATH entries #51785

spevans opened this issue Nov 21, 2018 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@spevans
Copy link
Collaborator

spevans commented Nov 21, 2018

Previous ID SR-9315
Radar None
Original Reporter @spevans
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Project Infrastructure
Labels Bug
Assignee None
Priority Medium

md5: 21c2b3e5a48fda65f3eba90ceff90722

duplicates:

  • SR-5755 AddSwift.cmake hardcodes "/usr/lib/swift/linux" into the RPATH of its shared libraries

relates to:

  • SR-1967 Need way to disable inclusion of hard-coded RPATH to stdlib dir
  • SR-5755 AddSwift.cmake hardcodes "/usr/lib/swift/linux" into the RPATH of its shared libraries

Issue Description:

From the swift-DEVELOPMENT-SNAPSHOT-2018-11-16-a-ubuntu18.04 snapshot:

~/swift-DEVELOPMENT-SNAPSHOT-2018-11-16-a-ubuntu18.04 $ for i in `find . -name 'lib*.so'`; do chrpath -l $i|grep RUNPATH ; done
./usr/lib/liblldb.so: RUNPATH=$ORIGIN/../lib:/home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/build/buildbot_linux/llvm-linux-x86_64/lib
./usr/lib/libswiftDemangle.so: RUNPATH=$ORIGIN:/usr/lib/swift/linux
./usr/lib/libXCTest.so: RUNPATH=/home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux
./usr/lib/libIndexStore.so: RUNPATH=$ORIGIN/../lib
./usr/lib/swift/pm/llbuild/libllbuildSwift.so: RUNPATH=/home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux:$ORIGIN:$ORIGIN/../../linux
./usr/lib/swift/pm/4/libPackageDescription.so: RUNPATH=/home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux:$ORIGIN/../../linux
./usr/lib/swift/pm/4_2/libPackageDescription.so: RUNPATH=/home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux:$ORIGIN/../../linux
./usr/lib/swift/linux/x86_64/libFoundation.so: RUNPATH=/home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux:/home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/build/buildbot_linux/libdispatch-linux-x86_64/src:$ORIGIN
./usr/lib/swift/linux/libswiftSwiftOnoneSupport.so: RUNPATH=$ORIGIN:/usr/lib/swift/linux
./usr/lib/swift/linux/libswiftCore.so: RUNPATH=$ORIGIN:/usr/lib/swift/linux
./usr/lib/swift/linux/libXCTest.so: RUNPATH=/home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux
./usr/lib/swift/linux/libFoundation.so: RUNPATH=/home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux:/home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/build/buildbot_linux/libdispatch-linux-x86_64/src:$ORIGIN
./usr/lib/swift/linux/libswiftDispatch.so: RUNPATH=/home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux
./usr/lib/swift/linux/libswiftRemoteMirror.so: RUNPATH=$ORIGIN:/usr/lib/swift/linux
./usr/lib/swift/linux/libswiftGlibc.so: RUNPATH=$ORIGIN:/usr/lib/swift/linux
./usr/lib/libsourcekitdInProc.so: RUNPATH=$ORIGIN/../lib/swift/linux:/usr/lib/swift/linux
./usr/lib/liblldbIntelFeatures.so: RUNPATH=$ORIGIN/../lib:/home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/build/buildbot_linux/llvm-linux-x86_64/lib

The path /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux gets added by swiftc -emit-library as it always calls the linker with -rpath.

The path /usr/lib/swift/linux seems to be added in via swift/cmake/modules/AddSwift.cmake: INSTALL_RPATH "$ORIGIN:/usr/lib/swift/linux")

Both of these absolute paths seem incorrect to include especially the jenkins one, which also causes problems with the tests that run against the installation as they will always work even if the RUNPATH is missing $ORIGIN, as there is an absolute path to the build directory containing libraries.

I think there are two solutions to this:

  1. Add a -no-add-rpath option to swiftc, although adding more options is probably best avoided if possible.

2. Install chrpath on the CI servers and modify the RUNPATH after the library is built:

$ chrpath -l ./usr/lib/swift/linux/libFoundation.so
./usr/lib/swift/linux/libFoundation.so: RUNPATH=/home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux:/home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/build/buildbot_linux/libdispatch-linux-x86_64/src:$ORIGIN
$ chrpath -r '$ORIGIN' ./usr/lib/swift/linux/libFoundation.so
./usr/lib/swift/linux/libFoundation.so: RUNPATH=/home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux:/home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/build/buildbot_linux/libdispatch-linux-x86_64/src:$ORIGIN
./usr/lib/swift/linux/libFoundation.so: new RUNPATH: $ORIGIN
$ chrpath -l ./usr/lib/swift/linux/libFoundation.so
./usr/lib/swift/linux/libFoundation.so: RUNPATH=$ORIGIN
@belkadan
Copy link
Contributor

I think this is covered by SR-1967 and SR-5755, but it's not clear what to do about them.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

2 participants