You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add an rpath flag to disable the default of looking in the local directory for shared libraries (#6947)
This is useful when deploying build products, as most executables are
not installed in the same directory as libraries and system libraries do
not need it for system paths. Use the new flag when installing SwiftPM
itself and the {Manifest,Plugin}API libraries on ELF platforms.
On linux, I currently see this with Swift 5.9:
```
> readelf -d swift-5.9-RELEASE-ubuntu20.04/usr/lib/swift/pm/*I/lib*so swift-5.9-RELEASE-ubuntu20.04/usr/bin/swift-package|ag "File:|runpath"
File: swift-5.9-RELEASE-ubuntu20.04/usr/lib/swift/pm/ManifestAPI/libPackageDescription.so
0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN:$ORIGIN/../../linux]
File: swift-5.9-RELEASE-ubuntu20.04/usr/lib/swift/pm/PluginAPI/libPackagePlugin.so
0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN:$ORIGIN/../../linux]
File: swift-5.9-RELEASE-ubuntu20.04/usr/bin/swift-package
0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN:$ORIGIN/../lib/swift/linux]
```
After applying this pull to trunk on Android, the extraneous rpath is
gone:
```
> llvm-readelf -d build/Ninja-Release/toolchain-android-aarch64/usr/lib/swift/pm/*I/lib*so build/Ninja-Release/toolchain-android-aarch64/usr/bin/swift-package|ag "File:|runpath"
File: build/Ninja-Release/toolchain-android-aarch64/usr/lib/swift/pm/ManifestAPI/libPackageDescription.so
0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN/../../android]
File: build/Ninja-Release/toolchain-android-aarch64/usr/lib/swift/pm/PluginAPI/libPackagePlugin.so
0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN/../../android]
File: build/Ninja-Release/toolchain-android-aarch64/usr/bin/swift-package
0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN/../lib/swift/android:/data/data/com.termux/files/usr/lib]
```
I have no idea if this is useful on Darwin too, but I went ahead and
disabled adding `@loader_rpath` too. Let me know if that's worthwhile.
0 commit comments