I'm using the target arm-linux-musleabihf
for ARM v6 (Raspberry Zero is v6) with musl and hard float.
Following instructions from Rust (and C) Cross Compilation for the Raspberry Pi.
Create an output directory:
mkdir /data/cross
chown $USER /data/cross
Use musl-cross-make:
git clone [email protected]:richfelker/musl-cross-make.git
cd musl-cross-make
Create a config.mak
:
TARGET = arm-linux-musleabihf
OUTPUT = /data/cross/armv6
COMMON_CONFIG += CFLAGS="-g0 -Os" CXXFLAGS="-g0 -Os" LDFLAGS="-s"
GCC_CONFIG += --with-arch=armv6 --with-mode=arm --with-fpu=vfp
Build:
make install
Add binaries to path: add to .profile
:
export PATH=/data/cross/armv6/bin/:$PATH
Continue with instructions from rust-cross.
Configure cargo for cross compilation: add this section to ~/.cargo/config
:
[target.arm-unknown-linux-musleabihf]
linker = "arm-linux-musleabihf-gcc"
Install the cross compiled standard crates
rustup target add arm-unknown-linux-musleabihf
cargo build --target=arm-unknown-linux-musleabihf