emk / rust-musl-builder

Docker images for compiling static Rust binaries using musl-libc and musl-gcc, with static versions of useful C libraries. Supports openssl and diesel crates.
Apache License 2.0
1.54k stars 193 forks source link

WIP: Switch to cross-compilation toolchain to allow compilation on M1 CPUs #118

Closed TilBlechschmidt closed 2 years ago

TilBlechschmidt commented 3 years ago

This is a basic implementation of support for cross-compiling Rust crates from an aarch64 CPU like the new M1 chips in MacBooks to a statically linked x86_64-unknown-linux-musl binary.

It does not break any of the tests for the image on regular x86 machines. However, the current state of the PR does fail when trying the Diesel test compilation. Regardless, it is a step forwards and as long as the libpq is not required, it works.

@emk please let me know on how you'd like to proceed. In my eyes having the ability to at least compile some crates (including OpenSSL) is already a huge gain and since it does not appear to break the regular x86 compilation, it would make sense to merge these changes. However, publishing the aarch64 image on Docker-Hub requires integration in your publishing workflow. Let me know your thoughts 🙂

Related to #117

TilBlechschmidt commented 3 years ago

Fixed two slight mistakes on my side with remaining debugging code being commented out 🙈

TilBlechschmidt commented 3 years ago

I've encountered some issues when compiling code on GitHub Actions with the amd64 version built with my modifications. I'll investigate further.

emk commented 2 years ago

See #117 for further discussion.