elm-format
elm-format copied to clipboard
Build linux-aarch64 (arm64) release binaries
This should be done in a reproducible way, preferably by being able to build locally using docker and buildx support for a locally-running arm container win docker-supported qemu.
Starting point: https://www.docker.com/blog/multi-arch-images/ https://docs.docker.com/buildx/working-with-buildx/ https://tech.smartling.com/building-multi-architecture-docker-images-on-arm-64-c3e6f8d78e1c
docker build ...
becomes docker buildx build --platform linux/arm64 ...
Related:
- possible dockerfile for aarch64 ghc https://github.com/haskell/docker-haskell/issues/1
- discussion of aarch64 alpine ghc https://gitlab.haskell.org/ghc/ghc/-/issues/18039
Blockers:
- [x] upgrade elm-format to ghc >= 8.10.1 (introduces aarch64 support) https://github.com/avh4/elm-format/pull/724
- [x] ghcup support for aarch64 https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/5
- [x] cabal-install aarch64 binary https://github.com/haskell/cabal/issues/6715
See https://github.com/mpizenberg/elm-test-rs/pull/91/files#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03fR44-R54 regarding github CI runners
Any chance this platform's support will be added? @avh4
I might be getting some new hardware that'll be able to build aarch64 binaries soon.
In the meantime, the issue is that Github Actions CI (or any other free-for-open-source-projects CI that I've found so far) doesn't provide any aarch64 or arm64 runners yet afaik. If anyone has any info about that, please share it!
@avh4 I noticed some people suggest using this:
https://github.com/uraimo/run-on-arch-action
https://github.com/marketplace/actions/run-on-architecture
https://github.com/uraimo/run-on-arch-action
Ooh, that's great! Thanks!
Hi, I use NixOS to successfully and simply build elm-format
for aarch64-linux
like:
nix-build -A pkgsCross.aarch64-multiplatform-musl.pkgsStatic.elmPackages.elm-format
You can easilly do this on github actions by following this tutorial.
You can also similarily build the aarch64-darwin
version of elm-format like:
nix-build -A pkgsCross.aarch64-darwin.elmPackages.elm-format
Actually.. the first one says multi-platform so maybe it also works for aarch64-darwin
? I can't say for sure since I haven't tried.
So it's possible this could solve this issue and the related #723.
I made a github action following the tutorial I linked above, let's see if it everything works the first time and gives us that binary :smile:
https://github.com/ParetoOptimalDev/elm-format/runs/8063581557?check_suite_focus=true
Looks like it's working just like it does for me locally, but first build will take forever. Since I setup cachix with it though, the subsequent ones will be fast.
Oh, exciting! I had tried pkgsCross
in the past and it didn't work (and had also filed some bugs with nixpkgs that got closed as "won't fix"). If it works now, that'd be great!
Cachix requires a paid account, right? Though it doesn't really matter, since if it works, I'll probably just build it locally with nix anyway.
Does nix-build -A pkgsCross.aarch64-darwin.elmPackages.elm-format
work for you on linux or only on MacOS? It gives "error: infinite recursion encountered" for me on Ubunutu with nix 2.8.1. That was one of the nixpkgs issues I filed that got closed "won't fix".
Huh, nix-build -A pkgsCross.aarch64-darwin.elmPackages.elm-format
evne gives me the inifinite recursion error on NixOS.
Cachix doesn't require a paid account for public caches like this one would be, you just have to signup through github and get a key. Maybe I can just make you owner of the one I created if aarch64-multiplatform
works for both linux and darwin.
I actually don't know if it will work for both or not, I'm new to cross compilation.
That was one of the nixpkgs issues I filed that got closed "won't fix".
The closest issue I could find was this one that's still open:
https://github.com/NixOS/nixpkgs/issues/126829
Here's an aarch64 multiplatform binary for testing:
https://github.com/ParetoOptimalDev/elm-format/suites/8023378224/artifacts/344661816
It finished in 2 hours. I reran and it took 40s with the cache.
Update: It works on aarch64-linux, but not aarch64-darwin/arm64 on an m1 mac.
Just for completeness I tried building pkgsCross.aarch64-darwin.elmPackages.elm-format
in the gihub action and it had infinite recursion encountered (as expected) here.
A workaround could be that when https://github.com/actions/runner-images/issues/2187 is finished, you don't have to use pkgsCross
at all and can just build pkgsStatic.elmPackages.elm-format
.
Of course you have other otpions at that point, and that run-on-arch-action looks promising as well.
Can anyone test running the aarch64 binary here: https://elm-format.avh4.net/manual/0.8.5-424-g9e071c6f/ and see if it works in the Linux ARM64 environment that they need it for?
Fixed in https://github.com/avh4/elm-format/pull/798 The next release (0.8.6) will include official linux-aarch64 static binaries.
Thanks @ParetoOptimalDev for the suggestion of using Nix pkgsCross -- it seems to work great now!