clux / muslrust

Docker environment for building musl based static linux rust binaries
MIT License
965 stars 88 forks source link

explore building an arm64 variant #97

Closed clux closed 8 months ago

clux commented 2 years ago

As energy use and costs for arm64 compute is lower than ever (e.g. aws graviton), it makes sense to provide an arm64 tagged build if possible/necessary.

Do not have a lot of experience in this avenue yet so input welcome. But will try to look into this shortly. Only thing I've found so far is the rust on graviton doc.

Optimising for energy use is probably the main thing we as software engineers can do inside our occupation towards climate change (outside; direct action :fist_raised: :heart_on_fire:).

RobbieMcKinstry commented 1 year ago

Hello! I came across this issue because I was trying to build Rust images with musl for both x86_64 and arm64. I'd love to see this feature added because I had a lot of trouble getting SQLx to compile for arm64.

I had two errors around Ring (the cryptographic primitive library) cross-compiling, perhaps because it uses inline assembly, and finding OpenSSL headers for the native tlsfeature of tokio/SQLx. I feel confident this can be done, and perhaps without a ton of effort.

clux commented 1 year ago

Hey @RobbieMcKinstry! late response, but would love to see ideas for how if you have time!

SamTV12345 commented 1 year ago

I'd love to help. There is this image which works: https://github.com/rust-cross/rust-musl-cross but the owner refuses to add the relevant libraries for compiling sqlite, Postgres etc.

clux commented 1 year ago

Any help would be very much welcome here as I haven't gotten the time to really work on this.

Having this as a multiarch image here would even help me quite a bit with some of the upstream use-cases in kube-rs org so have a pretty good incentive to keep maintaining.

I did look around to see how to do this in august for a bit, so will inline the interesting links below for what could be helpful as resources (because people do do this elsewhere):

(it's also possible to push the image as a multi-arch image so people do not need to disambiguate with tags, but that can be a much later step two.)

clux commented 8 months ago

as of today muslrust now builds with both arm64 and amd64 thanks to @eranrund in #133 :1st_place_medal:

new stable and nightly images have now been pushed https://hub.docker.com/repository/docker/clux/muslrust/tags?page=1&ordering=last_updated and can be used without any tag suffixes (so you can in theory build both amd64 and arm64 variants without having different dockerfiles - will try to poc this in version-rs later)