emk / rust-musl-builder

Docker images for compiling static Rust binaries using musl-libc and musl-gcc, with static versions of useful C libraries. Supports openssl and diesel crates.
Apache License 2.0
1.54k stars 193 forks source link

Binary doesn't seem to be fully static #1

Closed r-darwish closed 8 years ago

r-darwish commented 8 years ago

First of all, thanks for this image.

When trying to compile this project using docker run --rm -it -v "$(pwd)":/home/rust/src ekidd/rust-musl-builder cargo build --release the resulted binary doesn't seem to be static:

$ ldd transporter
    linux-vdso.so.1 (0x00007ffe895f1000)
    libc.so => not found
$ ./transporter
-bash: ./transporter: /lib/ld64.so.1: bad ELF interpreter: No such file or directory

I'm probably doing something wrong here, but I couldn't figure out what is it

emk commented 8 years ago

I poked at this for a bit, and it looks like one of your dependencies is linking to the dynamic copy of libc:

$ readelf -a ./target/x86_64-unknown-linux-musl/debug/transporter | grep 'Shared library'
 0x0000000000000001 (NEEDED)             Shared library: [libc.so]

This might be a build.rs script in a crate somewhere that isn't portable enough, or something else of that nature. I don't think it appears in any of the hyper dependencies, because programs using hyper worked fine for me a couple of weeks ago. So to find this, we're going to need to look at your non-hyper dependencies, and see if one of them is misbehaving.

I haven't figured out a really efficient way to track errors like this down yet, unfortunately.

r-darwish commented 8 years ago

Thank you. I'll try to track down which dependency is causing this

r-darwish commented 8 years ago

It seems that my raven library is causing this, maybe to due to the libc dependency, so it's probably not a problem with your image. However, do you happen to know what should be changed in raven in order for it to be able to compile with MUSL?