/cross-images

Docker images for cross-compiling Rust projects with dependencies

Primary LanguageDockerfile

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

Targets are defined in the targets folder. The currently defined targets are:

  • raspberrypi-bookworm: Raspberry Pi Zero/1 on Raspbian Bookworm

    Rationale: 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 Bullseye

    Rationale: same as above.

  • x86_64-bullseye: x86_64 native compiler on Debian Bullseye

    Rationale: for compatibility with other cross compiling images in this repository, even if you are targeting your host.

Usage

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> ....

raspberrypi-bookworm

[target.arm-unknown-linux-gnueabihf]
image = "ghcr.io/vtavernier/cross:raspberrypi-bookworm"

raspberrypi-bullseye

[target.arm-unknown-linux-gnueabihf]
image = "ghcr.io/vtavernier/cross:raspberrypi-bullseye"

x86_64-bullseye

[target.x86_64-unknown-linux-gnu]
image = "ghcr.io/vtavernier/cross:x86_64-bullseye"

Dependencies

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:

  1. Add the passthrough setting to Cross.toml:
[build.env]
passthrough = [
    "ENABLE_PYO3"
]
  1. Set the variable in your environment:
export ENABLE_PYO3=1
  1. Build as usual
cross build

Building the images

A Makefile is provided to build all images.

make

Testing the images

make test

Author

Vincent Tavernier vince.tavernier@gmail.com