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

x86_64-unknown-linux-musl does not always produce statically linked binaries #53

Open
smutt opened this issue Aug 25, 2020 · 0 comments

Comments

@smutt
Copy link

smutt commented Aug 25, 2020

This text in the guide is incorrect:
"To produce statically linked binaries, Rust provides two targets: x86_64-unknown-linux-musl and i686-unknown-linux-musl. The binaries produced for these targets are statically linked to the MUSL C library."

The reality is more complex.

$ cargo build --target=x86_64-unknown-linux-musl
Finished dev [unoptimized + debuginfo] target(s) in 0.82s
$ ldd target/x86_64-unknown-linux-musl/debug/danish-rust
linux-vdso.so.1 (0x00007ffc876d5000)
libpcap.so.0.8 => /usr/lib/x86_64-linux-gnu/libpcap.so.0.8 (0x00007fef24af2000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fef24931000)
/lib/ld64.so.1 => /lib64/ld-linux-x86-64.so.2 (0x00007fef24d3f000)
$ file target/x86_64-unknown-linux-musl/debug/danish-rust
target/x86_64-unknown-linux-musl/debug/danish-rust: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld64.so.1, BuildID[sha1]=c39a38306ce6f311f961c3477136f33c1b76bd10, with debug_info, not stripped

This is the project I'm compiling.
https://github.com/smutt/danish-rust

I suspect my problem is the dependency on libpcap. But I don't understand why this also results in libc being dynamically linked. What I would like to do either 1) produce a statically linked binary, or 2) dynamically link to libpcap on the target system.

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

No branches or pull requests

1 participant