`rust-lld` is using wrong zlib at runtime
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
After building rust 1.81.0 from sources, it configures with
-- Found ZLIB: /home/harmen/spack/opt/spack/linux-ubuntu23.10-zen2/clang-16.0.6/zlib-ng-2.1.6-xidpmzycb2jufhr6doa7anltbcyhu263/lib/libz.so (found version "1.3.0")
builds, and installs
<prefix>/lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-lld
which lists
libz.so.1
among the DT_NEEDED libraries, but due to a lacking RPATH, at runtime the wrong libz.so.1 is used:
$ ldd lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-lld | grep libz
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x000072120213b000)
This should have been the original zlib cmake has linked everything to.
Normally I would avoid this issue by passing -DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON, but I don't see how I can pass this since rust's bootstrap script invokes cmake with a fixed set of arguments.
I noticed a related issue with binaries from https://static.rust-lang.org/dist/rust-1.81.0-x86_64-unknown-linux-gnu.tar.gz: both libLLVM.so.* and rust-lld depend on system libz.so, which makes the bootstrap binaries less self-contained than necessary.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the Rust bootstrap script's fixed CMake invocation and how it configures the installed rust-lld binary. Reproduce the issue with the Rust 1.81.0 source build, then use ldd on rust-lld to verify that runtime resolution selects the zlib used during the build rather than the system library.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, rust
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100