GCW Zero Rust Cross Compilation - jquenee/gcw0-guide GitHub Wiki
Installation
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
rustup target add mipsel-unknown-linux-musl
- GCW toolchain >= 5.2 (uClibc v1)
Setting
[target.mipsel-unknown-linux-musl]
rustflags = ["-L dependency=/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/lib/"]
linker = "/opt/gcw0-toolchain/usr/bin/mipsel-gcw0-linux-uclibc-gcc"
Hello World
cargo new --bin hello
cd hello
cargo build --target=mipsel-unknown-linux-musl --release --verbose
file ./target/mipsel-unknown-linux-musl/release/hello
ELF 32-bit LSB pie executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked, interpreter /lib/ld-uClibc.so.0, with debug_info, not stripped
ldd ./target/mipsel-unknown-linux-musl/release/hello
Test
scp ./target/mipsel-unknown-linux-musl/release/hello [email protected]:~
ssh [email protected]
./hello
Useful links