Skip to content

Building Rust binaries

Ryan Parman edited this page Apr 8, 2024 · 3 revisions

musl vs glibc

Like C, Rust is a low-level language. Also like C, many Rust programs appear to rely on the system's libc implementation. In practice, this means separate binaries for Alpine Linux vs other linuxes.

Check the Alpine Linux package repositories for a package first. If they're already packaging it, we should skip the duplicated effort unless their repositories are WAY behind.

Are there releases available?

If we can pull tarballed releases from GitHub, that's preferable.

With Rust, we often see a matrix of [gnu, musl] and [aarch64, x86_64]. I often see 3/4 of these builds as release assets. The one usually missing is aarch64 for musl. Some packages like lychee have one, but they don't label it clearly with aarch64. I ended up figuring it out by looking at their Dockerfile. You may need to do some investigation to figure this out.

serde_derive is unbuildable when virtualized

While we have the right things in-place to be able to build [aarch64, x86_64] on musl, the serde_derive crate takes so damn long to build.

GitHub Actions only provides x86_64 runners. So if we want to cross-compile, we need to use Docker and QEMU to emulate Alpine Linux on arm64. While virtualization is fast, emulation is really slow. When attempting to compile lychee in this way, we timed-out a build after 6 hours.

As a result, we may not be able to provide aarch64/musl builds of Rust projects until GitHub releases GitHub-hosted arm64 runners.