Skip to content

haskell.compiler.ghc984: self-bootstrap on aarch64 musl#395724

Merged
alyssais merged 3 commits intoNixOS:stagingfrom
alyssais:ghc-musl-aarch64
Apr 11, 2025
Merged

haskell.compiler.ghc984: self-bootstrap on aarch64 musl#395724
alyssais merged 3 commits intoNixOS:stagingfrom
alyssais:ghc-musl-aarch64

Conversation

@alyssais
Copy link
Member

@alyssais alyssais commented Apr 3, 2025

GHC only provides bootstrap binaries for aarch64 musl since 9.8.x, so we can't bootstrap with the recommended 9.6.x in that case. Fortunately, bootstrapping with 9.8.x seems to work fine.

Some notes:

  • So far I've only confirmed that 9.8.4 builds. I've changed 9.8.1–9.8.3 as well, assuming that they'll build too.
  • I've left every other platform bootstrapping 9.8 with 9.6. Is that the right thing to do, or would it be better to bootstrap with 9.8 across the board for consistency?
  • I haven't made any attempt to factor out common stuff between the expressions for the bootstrap binaries, as it doesn't look like this has been done before. They also all seem to need slightly different fixups, and them presumably very limited maintenance thereafter, so probably not worth it?

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@alyssais alyssais requested a review from sternenseemann April 3, 2025 11:05
@github-actions github-actions bot added the 6.topic: haskell General-purpose, statically typed, purely functional programming language label Apr 3, 2025
@alyssais alyssais marked this pull request as draft April 3, 2025 11:07
@nix-owners nix-owners bot requested a review from maralorn April 3, 2025 11:07
@alyssais
Copy link
Member Author

alyssais commented Apr 3, 2025

Aaaa, I think my test build was not actually a musl one. This probably needs some more work…

@alyssais
Copy link
Member Author

alyssais commented Apr 3, 2025

Okay, that's better. Still wasn't too bad…

@alyssais alyssais marked this pull request as ready for review April 3, 2025 16:32
@alyssais
Copy link
Member Author

alyssais commented Apr 3, 2025

Result of test builds: 9.8.1–9.8.3 fail to build, but 9.8.4 (the important one) works.

@github-actions github-actions bot added 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. labels Apr 3, 2025
@nix-owners nix-owners bot requested review from cdepillabout and guibou April 3, 2025 16:43
@sternenseemann
Copy link
Member

I've left every other platform bootstrapping 9.8 with 9.6. Is that the right thing to do, or would it be better to bootstrap with 9.8 across the board for consistency?

If possible, this is preferrable, I think, but we probably don't have to change this right away (maybe do it via staging later?). Bootstrapping GHC is quite fragile (e.g. some weird RTS stuff needs to match), so everything not tested/supported by upstream may break even between minor versions (we've experienced this with self bootstrapping in the past). Since aarch64-musl isn't really exercised on CI as prominently as other platforms, it's probably best to always use the self bootstrapping path to avoid accidental regressions. For the obscure targets e.g. powerpc and armv7l that need to use a source built GHC, it's necessary to keep using 9.6, of course.

I haven't made any attempt to factor out common stuff between the expressions for the bootstrap binaries, as it doesn't look like this has been done before. They also all seem to need slightly different fixups, and them presumably very limited maintenance thereafter, so probably not worth it?

Yes, this has been my conclusion so far. I think going forward we can probably make a common expression since all bindists are theoretically produced in the same way since 9.6, but I haven't had time to look into it yet.

@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Apr 7, 2025
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Apr 8, 2025
@alyssais alyssais force-pushed the ghc-musl-aarch64 branch 2 times, most recently from 4e92c67 to aabce15 Compare April 9, 2025 10:24
@alyssais
Copy link
Member Author

alyssais commented Apr 9, 2025

Bootstrapping GHC is quite fragile (e.g. some weird RTS stuff needs to match), so everything not tested/supported by upstream may break even between minor versions (we've experienced this with self bootstrapping in the past).

Given this, I've dropped it from 9.8.1–9.8.3 where it didn't build, and left it just for 9.8.4. Still aarch64 musl only for now, but I'm happy to investigate building 9.8.4 with the 9.8.4 bindist where possible as follow-up after this PR is merged.

Copy link
Member

@sternenseemann sternenseemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should merge this into staging directly as to not interfere with the stabilization of the new haskell-updates rotation. the addition of the new bindist could be picked onto master directly, but not sure whether it's worth it. Overall it looks good to me, I'm running some sanity check builds now (though not on aarch64-linux since I don't have a machine available at the moment, but I trust you tested that…).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know whether this will overwrite config.sub / respects dontUpdateAutotoolsGnuConfigScripts? Otherwise this is a problem since GHC ships a non standard config.sub which is important for ghcjs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to build a ghcjs cross compiler, so it seems to be alright.

@sternenseemann sternenseemann changed the title ghc: bootstrap 9.8.x with 9.8.4 on aarch64 musl haskell.compiler.ghc984: self-bootstrap on aarch64 musl Apr 10, 2025
This is required to apply patches that modify configure.ac and
friends, but given we're already including most of it as inputs
anyway, we might as well just always do it and get the additional
benefit of knowing that the generated code corresponds to the source.
@alyssais alyssais changed the base branch from haskell-updates to staging April 11, 2025 07:43
The 9.8 binaries introduce support for aarch64 musl.  They can also be
used to build ghcHEAD, which previously wasn't buildable with a
bindist, so use it there and use the source-built 9.8.4 on platforms
without a bindist for consistency.  It fails to build 9.10.x and
9.12.x though, so I've left those as they are.
Upstream provides bindists for aarch64 musl since 9.8.x, so use that
for building 9.8.x for that platform.

A workaround from upstream is required because the bootstrap binaries
were built with the wrong target platform.
@alyssais alyssais merged commit cae70b0 into NixOS:staging Apr 11, 2025
24 of 27 checks passed
@alyssais alyssais deleted the ghc-musl-aarch64 branch April 11, 2025 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: haskell General-purpose, statically typed, purely functional programming language 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants