Closed outkine closed 4 years ago
@outkine My guess is that cmake does not receive cross-compilation flags during the build and uses your OS's libc instead of the musl-libc.
We also cross-compile on musl but we have opted to build in the same environment using docker. You can try to hack around cmake but using docker is the only reliable way I know to cross-compile rust projects with c/c++ dependencies.
I hope this helps you!
@octavonce Thank you for the recommendation! Building inside of Docker yields yet another strange error:
/home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/libmimalloc-sys-0.1.15/c_src/mimalloc/src/os.c:26:10: fatal error: linux/mman.h: No such file or directory
#include <linux/mman.h> // linux mmap flags
^~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/mimalloc-static.dir/src/os.c.o] Error 1
make[2]: *** [CMakeFiles/mimalloc-static.dir/all] Error 2
make[1]: *** [CMakeFiles/mimalloc-static.dir/rule] Error 2
make: *** [mimalloc-static] Error 2
I'm using the rust-musl-builder configuration here.
Setting some Rust compiler flags solved the problem. Full command:
RUSTFLAGS='-Clink-arg=-Wl,-Bstatic -Clink-arg=-lc' cross build --target=x86_64-unknown-linux-musl --release --all-features
In case anyone is having a related issue: these flags are supposed to be a good general toolkit for musl builds, so try them out!
I'm having an issue compiling to
musl
. I'm using cross:mimalloc
compiles, but the final executable does not:You can view the
--verbose
version here. MyCargo.toml
:These errors look like a standard library linking issue, but unfortunately I am no CMAKE expert. Any ideas would be much appreciated :)