Skip to content

Instantly share code, notes, and snippets.

@stonehippo
Last active December 3, 2025 20:53
Show Gist options
  • Select an option

  • Save stonehippo/b44123d281c59f73855d31de0da1b146 to your computer and use it in GitHub Desktop.

Select an option

Save stonehippo/b44123d281c59f73855d31de0da1b146 to your computer and use it in GitHub Desktop.
Notes on cross-compiling Rust on Raspberry Pi

Some Rust cross-compiling resources for Raspberry Pi

As I work on setting up a Pi Zero W as a portable system for some lightweight dev, I'm running into 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 ttapa's docker-arm-cross-toolchain 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!

Some resources on Rust packaging and cross compiling

From the Rust Book

Other tutorials and docs

Compilers and tools

Compiling Microsoft Edit for older (armv6) Raspberry Pi

As mentioned above, the whole reason I started down this road was to compile Microsoft Edit for use on armv6 Raspberry Pi. Here's a step by step on how I made that work.

Get the source

git clone https://github.com/microsoft/edit.git

Install a cross-compiler toolchain

mkdir ~/opt
wget https://github.com/tttapa/docker-arm-cross-toolchain/releases/latest/download/x-tools-aarch64-rpi3-linux -gnu-armv6-rpi-linux-gnueabihf-gcc12.tar.xz
tar xJf x-tools-aarch64-rpi3-linux-gnu-armv6-rpi-linux-gnueabihf-gcc12.tar.xz -C ~/opt

Point cargo to the toolchain

Edit ~/.cargo/config.toml and add this:

[target.arm-unknown-linux-gnueabihf]
linker = "/home/georgew/opt/x-tools/armv6-rpi-linux-gnueabihf/bin/armv6-rpi-linux-gnueabihf-gcc"

Do the build

From inside the edit directory:

rustup component add rust-src --toolchain nightly-aarch64-unknown-linux-gnu
cargo build --config .cargo/release-nightly.toml --release --target=arm-unknown-linux-gnueabihf

Install ICU to support find

sudo apt install libicu-dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment