GHC 9.x segfaults on 32-bit big-endian PowerPC
It's not possible to build GHC versions later than 9.0.2 on 32-bit big-endian PowerPC as the compiler segfaults during build:
(sid_powerpc-dchroot)glaubitz@perotto:~/ghc/ghc-9.4.6$ "/usr/bin/ghc" -hisuf hi -osuf o -hcsuf hc -static -H32m -O2 -lffi -optl-pthread -Wall -package-db libraries/bootstrapping.conf -this-unit-id template-haskell-2.19.0.0 -hide-all-packages -package-env - -i -ilibraries/template-haskell/./vendored-filepath -ilibraries/template-haskell/. -ilibraries/template-haskell/dist-boot/build -Ilibraries/template-haskell/dist-boot/build -ilibraries/template-haskell/dist-boot/build/./autogen -Ilibraries/template-haskell/dist-boot/build/./autogen -Ilibraries/template-haskell/. -optP-include -optPlibraries/template-haskell/dist-boot/build/./autogen/cabal_macros.h -package-id base-4.15.1.0 -package-id ghc-boot-th-9.4.6 -package-id ghc-prim-0.7.0 -package-id pretty-1.1.3.6 -Wall -this-unit-id template-haskell -XHaskell2010 -XNoImplicitPrelude -XImplicitPrelude -no-user-package-db -rtsopts -fno-warn-deprecated-flags -outputdir libraries/template-haskell/dist-boot/build -c libraries/template-haskell/./Language/Haskell/TH/Ppr.hs -o libraries/template-haskell/dist-boot/build/Language/Haskell/TH/Ppr.o
Segmentation fault (core dumped)
(sid_powerpc-dchroot)glaubitz@perotto:~/ghc/ghc-9.4.6$ gdb /usr/lib/ghc/bin/ghc ./core GNU gdb (Debian 13.2-1) 13.2 Copyright (C) 2023 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details.
This GDB was configured as "powerpc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/lib/ghc/bin/ghc...
(No debugging symbols found in /usr/lib/ghc/bin/ghc)
[New LWP 584005]
[New LWP 584007]
[New LWP 584006]
[New LWP 584009]
[New LWP 584008]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/powerpc-linux-gnu/libthread_db.so.1".
Core was generated by `/usr/lib/ghc/bin/ghc -B/usr/lib/ghc -hisuf hi -osuf o -hcsuf hc -static -H32m -'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x0e3a27e4 in base_GHCziFloat_fromRat_closure () from /usr/lib/ghc/bin/../base-4.15.1.0/libHSbase-4.15.1.0-ghc9.0.2.so
[Current thread is 1 (Thread 0xf7f9c2a0 (LWP 584005))]
(gdb) bt
#0 0x0e3a27e4 in base_GHCziFloat_fromRat_closure () from /usr/lib/ghc/bin/../base-4.15.1.0/libHSbase-4.15.1.0-ghc9.0.2.so
#1 0x0d867ddc in ghczmbignum_GHCziNumziBigNat_bigNatIsPowerOf2zh_info () from /usr/lib/ghc/bin/../ghc-bignum-1.1/libHSghc-bignum-1.1-ghc9.0.2.so
#2 0x0d41a560 in ?? () from /usr/lib/ghc/bin/../rts/libHSrts_thr-ghc9.0.2.so
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb)
I have been trying to work around this crash but so far haven't found a solution.
Building an unregisterised compiler fails due to integer overflows in the generated assembly code.