TL;DR
Building my code using the x86_64-unknown-linux-musl
target works on one computer, but not on another with the same Cargo.lock
, and same versions of rustc
. I believe it to be different versions of musl
... how can I tell what version of musl
is being used?
Full Story
I'm trying to build a static binary w/musl that uses jemalloc for the allocator. I get the following error when I build:
= note: /usr/bin/ld: target/x86_64-unknown-linux-musl/debug/deps/libjemalloc_sys-0ea9152d514c746d.rlib(prof_sys.pic.o): in function `prof_sys_thread_name_read_impl':
target/x86_64-unknown-linux-musl/debug/build/jemalloc-sys-05a180e44afaaef0/out/build/src/prof_sys.c:308: undefined reference to `pthread_getname_np'
collect2: error: ld returned 1 exit status
= note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
= note: use the `-l` flag to specify native libraries to link
= note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)
The weird thing is that the same code builds on a different machine w/out any issues. As I started to debug why, I noticed the deps seem to be different:
non-working machine
sha1sum ../target/x86_64-unknown-linux-musl/debug/deps/*jemalloc*
51dd24da63e456ff4dc2ba0a5cb1bde45be4f78a ../target/x86_64-unknown-linux-musl/debug/deps/jemallocator-f23099e6266abcc6.d
b9b8af877654ff8cb8fdcbc5dba3e07ea77b66b2 ../target/x86_64-unknown-linux-musl/debug/deps/jemalloc_sys-0ea9152d514c746d.d
871580a3508083aef522ac6935a0ecd68c96922d ../target/x86_64-unknown-linux-musl/debug/deps/libjemallocator-f23099e6266abcc6.rlib
383c9622e91fe0280a5b0886f91c35b131bae332 ../target/x86_64-unknown-linux-musl/debug/deps/libjemallocator-f23099e6266abcc6.rmeta
052dc61a820dcaefb7ee37dbf0d67a4d127b605c ../target/x86_64-unknown-linux-musl/debug/deps/libjemalloc_sys-0ea9152d514c746d.rlib
7e975d0669c965223d097eaf458c18faddc30cb5 ../target/x86_64-unknown-linux-musl/debug/deps/libjemalloc_sys-0ea9152d514c746d.rmeta
working machine
sha1sum ../target/x86_64-unknown-linux-musl/debug/deps/*jemalloc*
48a00695412202e4a2742fe29837ae5095b461c3 ../target/x86_64-unknown-linux-musl/debug/deps/jemallocator-ac4ef0434b9e9d61.d
cece3611044a5ced4ac248cbd71e9680f62c99bf ../target/x86_64-unknown-linux-musl/debug/deps/jemalloc_sys-60220cfee7b2b8e5.d
83d6a46cadfb8807e0c9e45ef17215adf782a7df ../target/x86_64-unknown-linux-musl/debug/deps/libjemallocator-ac4ef0434b9e9d61.rlib
699cdd9c9d9d07548215c6ee7f88f6f8432f79a1 ../target/x86_64-unknown-linux-musl/debug/deps/libjemallocator-ac4ef0434b9e9d61.rmeta
e70df2d617fa061921d46546c99109f4714f7150 ../target/x86_64-unknown-linux-musl/debug/deps/libjemalloc_sys-60220cfee7b2b8e5.rlib
8abfc5834746b35287b721839b3224cc4df1b01d ../target/x86_64-unknown-linux-musl/debug/deps/libjemalloc_sys-60220cfee7b2b8e5.rmeta
I am using pyoxidizer to include pyo3, but all of the pyoxidizer deps are the same on both machines. The Cargo.lock
files and of course the version of rustc
are the same on both machines as well.
So ultimately I have 3 questions:
- What determines the contents of the deps files in
target/x86_64-unknown-linux-musl/debug/deps/
different for*jemalloc*
? - How can I tell which version of
musl
is being used when I compile? My issue seems similar to this (pprof 0.9.1: Databend cannot be built on musl targets · Issue #138 · tikv/pprof-rs · GitHub), which they solve by upgrading the version of musl to 1.2.3 used to compile databend. - Is there something else that could be causing these builds to be different besides the version of
rustc
used, and the versions of crates inCargo.lock
?