This Docker image is used to cross compile Rust for FreeBSD.
In the directory containing your project run:
docker container run --rm --volume "$(pwd)":/src \
--init --tty --user "$(id --user):$(id --group)" \
"unixgeek2/rust-x86_64-freebsd:latest" \
build --release --target x86_64-unknown-freebsd
This example works out of the box in a run step with the ubuntu runner.
docker container run --rm
--volume ${{ github.workspace }}:/src
--user $(id --user):$(id --group)
unixgeek2/rust-x86_64-freebsd:latest build --release --target x86_64-unknown-freebsd
FROM unixgeek2/rust-x86_64-freebsd:latest
USER root
RUN apt-get update \
&& apt-get install --no-install-recommends -y libssl-dev
USER rust
ENTRYPOINT ["/bin/sh", "-c"]
There are two optional build args:
ARCH
: The target architecture (i586, i686 or x86_64). Default is x86_64.RUST_RELEASE
: The release of Rust to install. CheckDockerfile
for the default.
docker buildx build --tag rust-x86_64-freebsd .
docker buildx build --build-arg ARCH=i686 --tag rust-i686-freebsd .
docker buildx build --build-arg ARCH=i586 --build-arg RUST_RELEASE=1.51.0 --tag rust-i586-freebsd .
Note that RUST_RELEASE
must be 1.51.0 for i586. See below.
Rust has the i686 and x86_64 toolchains available, but not i586. In order to provide an i586 toolchain, the
build-rust-i586.sh
script builds Rust from a forked repository that has been patched to support the i586 target. It is
currently release 1.51.0. These artifacts have been uploaded to a server to be made available to the build.
There may be a technical reason the i586 toolchain is not available, but it works for my small
projects.