Segfault in RISC-V programs built by a registerised GHC
Summary
Most interesting programs segfault when compiled by a registerised GHC. This also includes GHC itself when compiling non-trivial programs.
I have tried cross-compiling GHC 9.2.7, 9.4.5, and 9.6.2, but none of them worked. I have also tried natively compiling GHC 9.6.2 using an unregisterised cross-compiled 9.4.5, but that didn't work either.
Steps to reproduce
Using Nix:
nix-build -p 'pkgsCross.riscv64.haskell.compiler.native-bignum.ghc945' -I nixpkgs=https://github.com/AlexandreTunstall/nixpkgs/archive/40f2e8f3abc55ff292cc3328ff22d4159893ad20.tar.gz
Then try using the resulting GHC to compile pandoc (this may require binfmt emulation or a RISC-V system).
Without Nix:
- Compile one of the affected versions registerised for RISC-V (both cross and native should reproduce this issue)
- Try using the stage 2 compiler to compile non-trivial software (e.g. pandoc).
I might not have tested native compilation properly, but it can definitely be reproduced with cross.
Expected behavior
pandoc compiles successfully; this is the case with unregisterised GHC.
Observed behavior
A segmentation fault with no additional details at some early stage of compiling pandoc.
Environment
- GHC version used: 9.2.7, 9.4.5, and 9.6.2
Optional:
- Operating System: Linux
- System Architecture: RV64GC (cross) and RV64GC_Zba_Zbb (native)