-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
musl staticlib builds include all of the musl symbols #65760
Copy link
Copy link
Closed
Labels
A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.Category: This is a bug.O-muslTarget: The musl libcTarget: The musl libcT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.Category: This is a bug.O-muslTarget: The musl libcTarget: The musl libcT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Observed Behaviour
If I produce a simple
staticlibcrate for thex86_64-unknown-linux-musltarget, I get a.afile that includes all the symbols from musl, including standard libc symbols like (for example)readlink. This makes it impossible to link this library into a C program that links against libc itself (or another Rust staticlib) as the linker will fail with duplicate symbol errors.Reproduction
A test repository is at https://github.com/Twey/musl-staticlib-test, along with a Nix description of the relevant build environment for those so inclined. You can execute
rustc -omusl-staticlib-test.a --target=x86_64-unknown-linux-musl --crate-type=staticlib lib.rsto get a library, and use a tool such asnmto view the symbols in the resulting binary. For example:Expected Behaviour
Normally, static libraries for consumption by C, like
rlibs, contain only symbols from the project itself, not symbols from dependencies. Certainly symbols from libc should never make it into the binary, as these will always conflict.For example, here's
libev, also built statically against musl: