Docker images for cross-compiling Rust with native dependencies. This repository builds rust-based images with the extra support needed for cross-compiling on unusual targets.
Targets are defined in the targets
folder. The currently defined targets are:
-
raspberrypi-bookworm
: Raspberry Pi Zero/1 on Raspbian BookwormRationale: arm-linux-gnueabihf toolchains are now configured by default to use ARMv7, which is only supported by Raspberry Pi 2 and later. This builds a arm-linux-gnueabihf toolchain for ARMv6 so we can cross-compile Rust programs for those targets.
-
raspberrypi-bullseye
: Raspberry Pi Zero/1 on Raspbian BullseyeRationale: same as above.
-
x86_64-bullseye
: x86_64 native compiler on Debian BullseyeRationale: for compatibility with other cross compiling images in this repository, even if you are targeting your host.
The images built by this repository are compatible with
cross. In order to use them, add a
Cross.toml
file referencing the image for your target as described below.
Then, use cross
as usual: cross build --target <TARGET> ...
.
[target.arm-unknown-linux-gnueabihf]
image = "ghcr.io/vtavernier/cross:raspberrypi-bookworm"
[target.arm-unknown-linux-gnueabihf]
image = "ghcr.io/vtavernier/cross:raspberrypi-bullseye"
[target.x86_64-unknown-linux-gnu]
image = "ghcr.io/vtavernier/cross:x86_64-bullseye"
All the targets in this repository include the following common dependencies:
- sqlite3: available as-is
- python3: feature-gated behind
ENABLE_PYO3=1
To enable extra features, you need to:
- Add the
passthrough
setting toCross.toml
:
[build.env]
passthrough = [
"ENABLE_PYO3"
]
- Set the variable in your environment:
export ENABLE_PYO3=1
- Build as usual
cross build
A Makefile is provided to build all images.
make
make test
Vincent Tavernier vince.tavernier@gmail.com