NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.16k stars 14.19k forks source link

native riscv64-linux: error: cannot bootstrap GHC on this platform ('riscv64-linux' with libc 'defaultLibc') #231537

Open colemickens opened 1 year ago

colemickens commented 1 year ago

Describe the bug

I am trying to ramp back up on riscv64-linux stuff. I have a minimal builder config that cross-compiles. I'm trying to get the "full" interactive config ready to natively build, but it doesn't even evaluate.

It blows up on GHC. If I were guessing, it seems like some versions of GHC are pulled as binary releases, probably to bootstrap a GHC-from-source build.

However, it seems that GHC does not publish binary releases of GHC.

I'm not in the Haskell scene, so I don't know how to proceed:

  1. Ask GHC to publish riscv64 releases? Not sure if they're ready yet, etc
  2. Use an unsupported binary release from ... someone else? Maybe this couldn't/shouldn't be merged, but could live in one of the various riscv64 branches that various folks maintain.
colemickens commented 1 year ago

Can we cross-compile a riscv64-linux release and then use that as our own binary bootstrap?

colemickens commented 1 year ago

cc: @zhaofengli @NickCao

sternenseemann commented 1 year ago

Feel free to ping the actual GHC maintainers on such issues!

I agree that cross compiling GHC and using it as part of a stdenv bootstrap-esque solution is probably the best bet for the future, especially since GHC upstream has rather opted to get rid of troublesome platforms than continue to maintain CI support in the past (see also #193058). Cross compiling GHC is not yet supported and would be an investment in the past sadly, since it has apparently regressed in 9.6 (with no news since). More details on this here: https://github.com/NixOS/nixpkgs/issues/193058#issuecomment-1266938098

colemickens commented 1 year ago

That sounds... rough. To be honest, I'm not a big Haskell person, I'm not even sure what in my toplevel requires it... I'm a bit surprised that the situation is still seemingly so behind for GHC. Even Go seems to be gearing up for publishing riscv64-linux releases. Just wanted to raise a risc-y flag.

Hope things improve and much appreciation to Haskell folks and Haskell nixpkgs maintainers! <3

colemickens commented 1 year ago

BTW, I did find that there was like 9.0.2 built by Debian in an unofficial port, maybe we can leverage that to bootstrap? At least that might get something functional while side-stepping the GHC-cross-compile rats-nest.

sternenseemann commented 1 year ago

BTW, I did find that there was like 9.0.2 built by Debian in an unofficial port, maybe we can leverage that to bootstrap? At least that might get something functional while side-stepping the GHC-cross-compile rats-nest.

Reusing other distribution's package outputs is unfortunately very painful: https://github.com/NixOS/nixpkgs/issues/193058#issuecomment-1258519949. With >= 9.6 we could ask other distributions if they'd like to publish the intermediate bindist that has to be built with hadrian, but as they don't really have an interest in that themselves, it seems like a better option to just figure it out for ourselves

I'm a bit surprised that the situation is still seemingly so behind for GHC.

I mean you can always ask, seems like there is no request for riscv64-linux bindists on their bug tracker at the moment.

colemickens commented 1 year ago

Hm, while interested, I'm reluctant, mostly due to my own Haskell ignorance. For example, skimming this issue, https://gitlab.haskell.org/ghc/ghc/-/issues/16783, points to an in-progress effort for native riscv64 code generation, and I simply don't have the context for knowing if that's a pre-requisite for a "riscv64-linux bindist" to bootstrap with.

sternenseemann commented 1 year ago

It is not a prerequisite (it already supports riscv64-linux via the “generic” LLVM backend), but if merged it will become more likely that GHC upstream publishes a bindist (but also not guaranteed).