Hey all, attempting to cross compile some code for an OpenWrt device I have. My device still uses 15.05, which has uclibc instead of musl.
I would like like to create a completely statically linked binary, so it is not necessary to switch to the unstable version of OpenWRT that includes musl for dynamic linkage.
Here is what I have tried:
#Compile the OpenWrt Toolchain for my device, including adding "mipsel-openwrt-linux-musl-gcc" to the path # Setup Rust rustup target add mips-unknown-linux-musl # Contents of ~/.cargo/config: [target.mipsel-unknown-linux-musl] linker = "mipsel-openwrt-linux-musl-gcc" # Make a project cargo new --bin hello cd hello # Build cargo build --target=mipsel-unknown-linux-musl # Results: ldd target/mipsel-unknown-linux-musl/hello not a dynamic executable strings target/mipsel-unknown-linux-musl/hello | head 1 /lib/ld-musl-mipsel-sf.so.1 _fini __libc_start_main ... # This fails to run on my OpenWrt device with a cryptic error # that I think is due to the missing shared library root@OpenWrt:/bin# ./hello -ash: hello: not found # I also tried creating a static hello world in C, and that DOES work. mipsel-openwrt-linux-musl-gcc -static hello_world.c ldd a.out not a dynamic executable strings a.out | head hB$# hB$# <lgB$hg ... root@OpenWrt:/bin# a./out Hello, World!
Am I missing a step? Are the items listed here: https://doc.rust-lang.org/book/advanced-linking.html still necessary, or should they be covered by the
rustup target add command I used above?