As I work on setting up a Pi Zero W as a little portable system for some lightweight dev, I'm running the challenge of compiling certain binaries on-system. To say that the Pi Zero W's resources are limited is an understatement; it can take days to compile something that might take minutes on a more robust system.
What I wanted was to cross-compile Microsoft Edit. I got it working by installing rust on my Raspberry Pi 400 with the 64-bit OS, then adding the appropriate target:
rustup target add arm-unknown-linux-gnueabihf
I also installed the right version of the GCC cross compiler toolchain. At first, I did this with apt
, but that wasn't right: if I'm using 64-bit for the host, it's going to link a 64-bit version for the target.
Instead, I installed a GCC toolchain manually (see the link to ttpapa below), then set up armv6-rpi-linux-gnueabihf-gcc
as the linker for the arm-unknown-linux-gnueabihf
target in ~/.cargo/config.toml. This set up worked and I was able to compile and run Microsoft edit on the Pi Zero W!
- https://rust-cli.github.io/book/tutorial/packaging.html - Packaging in Rust
- https://rust-lang.github.io/rustup/cross-compilation.html - Cross-compiling in Rust
- https://doc.rust-lang.org/nightly/rustc/platform-support.html - Platform support in Rust, i.e., Tier 1/2/3
- https://kerkour.com/rust-cross-compilation
- https://github.com/japaric/rust-cross - some notes on cross-compiling with Rust
- https://reemus.dev/tldr/rust-cross-compilation-github-actions
- https://github.com/tttapa/docker-arm-cross-toolchain
- https://github.com/abhiTronix/raspberry-pi-cross-compilers - a collection of cross-compilers meant to run from x86_64 Linux systems
- https://github.com/cross-rs/cross - cross-compilers + containers to reduce installed components and dependencies