Porting GHC to powerpc-unknown-linux

Simon Marlow simonmar@microsoft.com
Thu, 4 Sep 2003 10:29:30 +0100

> Following Donald Stewart efforts and Simon Marlow's new=20
> porting guide,=20
> I made two attempts of getting GHC working on Linux/PowerPC.
> I made a first attempt using cross-compiling from a Linux/i386 box. I=20
> followed every instruction on the guide, but the compiler was=20
> unusable,=20
> resulting in the following error message :
> hc-6.0.1: internal error: stg_ap_v_ret
>      Please report this as a bug to glasgow-haskell-bugs@haskell.org,
>      or http://www.sourceforge.net/projects/ghc/
> Don got the same message for his cross-compilation tests, so=20
> I decided=20
> to stay on the same computer using the official build for Mac OS X.

I think the stg_ap_v_ret panic might be due to using the wrong
AutoApply.hc, or some other mixup between registerised and
unregisterised code.

When I went through this bootstrap process recently I cross-compiled
from a 32-bit machine to a 64-bit machine - in theory this should be the
most difficult kind of port, but it went through surprisingly smoothly.
Ok, so it was the same OS at both ends which might have made things

There's a small possibility that I've missed something out from the
instructions, I suppose :)

> I had to add -Onot -fvia-C to prelude/PrimOp_HC_OPTS in=20
> ghc/compiler/Makefile to make GHC build. This failed on the=20
> RTS as said=20
> in the guide, so I decided to go on.
> But I was unable to build the libraries. I got a bunch of=20
> error message=20
> like : "cpp0: unkown -smart flag", and it failed later at :
> /compiler/ghc-inplace -H16m -O -fglasgow-exts -cpp -Iinclude=20
> -#include=20
> HsBase.h -funbox-strict-fields -package-name base -O -H32m=20
> - -keep-hc-files     -c GHC/Base.lhs -o GHC/Base.o  -ohi GHC/Base.hi
> GHC/Base.hc:1111: only 1 arg to macro 'HP_CHK_NP' (2 expected)
> [...]

It looks like a mismatch between the header files in ghc/includes and
the code the compiler is generating.  Are you sure you're using
*exactly* the same sources on both the host and the target machine?