ghc-stage1: panic! (the 'impossible' happened) creating cross compiler for PPC
We have a product based on a Freescale MPC8544E.
I have previously built powerpc-unknown-linux-gnuspe-ghc-7.8.3 and that produces viable code though annoyingly rather large binaries but this is covered elsewhere.
I looked at both 7.8.4 and 7.10 a while ago but they proved to be non-starters for reasons I no longer remember.
Now for reasons tooling reasons (Stack and friends) it would be nice to use 8.0.2
My procedure is as follows
In the (ghc-7.83 or) ghc-8.0.2 source directory
base=powerpc-unknown-linux-gnuspe; ./configure --prefix=/tmp/prefix --target=$base --with-gcc=$base-gcc --with-ld=$base-ld --with-nm=$base-nm --with-ar=$base-ar --with-ranlib=$base-ranlib --enable-unregisterised
I edit mk/build.mk to make flavour "quick-cross"
I edit ghc.mk and comment out anything with haskeline or terminfo
The bottom of settings says ("Unregisterised", "YES"), ("LLVM llc command", "/usr/bin/llc-3.7"), ("LLVM opt command", "/usr/bin/opt-3.7")
But the make itself (on Ubuntu 16 amd64) fails.
"inplace/bin/ghc-stage1" -hisuf hi -osuf o -hcsuf hc -static -O0 -H64m -Wall -this-unit-id ghc-prim-0.5.0.0 -hide-all-packages -i -ilibraries/ghc-prim/. -ilibraries/ghc-prim/dist-install/build -ilibraries/ghc-prim/dist-install/build/autogen -Ilibraries/ghc-prim/dist-install/build -Ilibraries/ghc-prim/dist-install/build/autogen -Ilibraries/ghc-prim/. -optP-include -optPlibraries/ghc-prim/dist-install/build/autogen/cabal_macros.h -package-id rts -this-unit-id ghc-prim -XHaskell2010 -O -fllvm -no-user-package-db -rtsopts -Wno-trustworthy-safe -Wno-deprecated-flags -Wnoncanonical-monad-instances -odir libraries/ghc-prim/dist-install/build -hidir libraries/ghc-prim/dist-install/build -stubdir libraries/ghc-prim/dist-install/build -c libraries/ghc-prim/./GHC/Types.hs -o libraries/ghc-prim/dist-install/build/GHC/Types.o ghc-stage1: panic! (the 'impossible' happened) (GHC version 8.0.2 for powerpc-unknown-linux): LlvmCodeGen.Ppr: Cross compiling without valid target info.