Cross-compiling Rust for Alpine Linux on Raspberry Pi
Tue 15 Oct 2019 13:45 BST
I’ve just figured out (with the assistance of pages like japaric’s rust-cross guide) how to cross-build a small Rust project for FRμITOS, which is an Alpine Linux based distribution (using musl libc) for Raspberry Pi, using a Debian x86_64 host.
It was ultimately very nicely straightforward.
- Install the Debian
binutils-arm-linux-gnueabihf
package. - Use
rustup
to install support for thearmv7-unknown-linux-musleabihf
target. - Set the
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_LINKER
environment variable appropriately. - Run
cargo build --target=armv7-unknown-linux-musleabihf
.
That’s it!
In shell script form: