Unreg/registerised hc booting success

Donald Bruce Stewart dons@cse.unsw.edu.au
Tue, 2 Sep 2003 21:02:37 +1000


simonmar:
> Thanks for all this.  I recently went through the unregisterised
> bootstrap process myself (for amd64), and I've written some detailed
> instructions in the Building Guide - you might want to take a look and
> see if you have anything to add.  

I've been working from that document the last few days. See below.

> I've applied your patches, with some small tweaks by myself to avoid
> breaking the unregisterised bootstrap, which is normally done with a

Thanks.

> compiler without interpreter support, hence the lack of the readline,
> haskell-src and other libraries.

Ah! Of course. That is what's going on.

I continued my 6.0.1 unregisterised bootstrapping efforts
following the latest version of building/building.sgml. 
The steps therein are successful, and I have nothing to add at
this point.

Unregisterised, the news is a bit frustrating. Of the cross-port
machines that went through successfully (3 of 5), none produced a
working compiler. They all resulted in:

    ghc-6.0.1: internal error: stg_ap_v_ret
        Please report this as a bug to glasgow-haskell-bugs@haskell.org,

However, I have been entirely successfully generating
registerised and unregisterised hc on x86-{linux,openbsd} and
then bootstrapping on the same platform: this is how the i386
GHC 6.0.1 port in the OpenBSD ports tree now bootstraps (from
nothing to full Haskell in 31 minutes on my work box :)

The furthest I've made it cross-porting, using a variety of paths
in, has been the stg_ap_v_ret bug above. I haven't looked into
this further, but will do so in weeks to come. I thought it might
be useful to report these results, though.

Cheers,
    Don

Below is a list of machines I attempted to port from and to, and
any bugs fixed along the way. All host machines had a full
installation of GHC 6.0.1. The ports at listed in "$Target from
$Host" pairs by their canonical name.

--------------------------------------------------------------
[1] sparc-unknown-openbsd from i386-unknown-openbsd
--------------------------------------------------------------

Host:
1. gmake -k ..etc caused errors. Unresolved as whether this is
   bad or not:
     undefined reference to `GHCziWeak_runFinalizzerBatch_closure'

Target:
2. PrimOp.hc dies unless -O is turned off in the gcc flags:
   Looks like a gcc bug.

    gcc -x c prelude/PrimOp.hc -o stage1/prelude/PrimOp.o -c
    -O  -w -DNO_REGS -DUSE_MINIINTERPRETER  -D__GLASGOW_HASKELL__=600
    -O -DNO_REGS -DUSE_MINIINTERPRETER
    -I/usr/obj/ports/ghc-6.0.1/ghc-6.0.1/ghc/includes
    -I/usr/obj/ports/ghc-6.0.1/ghc-6.0.1/libraries/base/include
    -I/usr/obj/ports/ghc-6.0.1/ghc-6.0.1/libraries/unix/include
    -I/usr/obj/ports/ghc-6.0.1/ghc-6.0.1/libraries/readline/include
    -Iparser -I.  -O -D__GLASGOW_HASKELL__=600    -I.  `echo  | sed
    's/^$/-DSTOLEN_X86_REGS=4/'` prelude/PrimOp.hc: In function
    `skkX_ret': prelude/PrimOp.hc:58811: virtual memory exhausted
    gmake[1]: *** [stage1/prelude/PrimOp.o] Error 1 gmake: *** [all]
    Error 1 gmake: Leaving directory
    `/usr/obj/ports/ghc-6.0.1/ghc-6.0.1/ghc' 4682.23s real  3440.07s
    user   873.16s system

3.  Everything then goes through fine, producing a binary that dies:

    $ /usr/obj/ports/ghc-6.0.1/ghc-6.0.1/ghc/compiler/ghc-inplace  -v
    ghc-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/

--------------------------------------------------------------
[2] sparc-unknown-openbsd <- i386-unknown-linux
--------------------------------------------------------------


Host:
1. On linking GHC: solution (generate .hc files without SIGPOLL),
same as [4].1, so comment out SIGPOLL in mk/config.h

Target:
This was a problem using Linux as a host machine in general,
otherwise you get:
    l98 -lHSbase -lHSbase_cbits -lHSrts -lgmp -lm   -lreadline  -lncurses
    /usr/obj/ports/ghc-6.0.1/ghc-6.0.1/libraries/base/libHSbase.a(Signals.o):
    In function `SystemziPosixziSignals_sigPOLL_entry':
    Signals.o(.text+0x4c6c): undefined reference to `__hsposix_SIGPOLL'
    collect2: ld returned 1 exit status
    gmake[1]: *** [stage1/ghc-6.0.1] Error 1
    gmake: *** [all] Error 1
    gmake: Leaving directory `/usr/obj/ports/ghc-6.0.1/ghc-6.0.1/ghc'

2. gcc complains without turning -O off on PrimOp.hc, same as
   [1].3. So compile without -O for this file:

    gcc -x c prelude/PrimOp.hc -o stage1/prelude/PrimOp.o -c -O  -w -DNO_REGS
    -DUSE_MINIINTERPRETER  -D__GLASGOW_HASKELL__=600  -O -DNO_REGS
    -DUSE_MINIINTERPRETER -I/usr/obj/ports/ghc-6.0.1/ghc-6.0.1/ghc/includes
    -I/usr/obj/ports/ghc-6.0.1/ghc-6.0.1/libraries/base/include
    -I/usr/obj/ports/ghc-6.0.1/ghc-6.0.1/libraries/unix/include -Iparser -I.
    -O -D__GLASGOW_HASKELL__=600    -I.  `echo  | sed
    's/^$/-DSTOLEN_X86_REGS=4/'`
    prelude/PrimOp.hc: In function `skkX_ret':
        prelude/PrimOp.hc:58811: virtual memory exhausted
        gmake[1]: *** [stage1/prelude/PrimOp.o] Error 1
        gmake: *** [all] Error 1
        gmake: Leaving directory `/usr/obj/ports/ghc-6.0.1/ghc-6.0.1/ghc'

3. Goes through to the end without problems:
$ ghc/compiler/ghc-inplace        
ghc-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/
        

--------------------------------------------------------------
[3] i386-unknown-freebsd <- i386-unknown-openbsd
--------------------------------------------------------------

Host: no changes!

Target: 
1. Went through cleanly generating a compiler that dies with:

   % ghc/compiler/ghc-inplace 
     ghc-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/

     This is the same bug I've been unable to resolve in ports [1,2]


--------------------------------------------------------------
[4] i386-unknown-freebsd <- i386-unknown-linux
--------------------------------------------------------------

Host:
1. Linking ghc on the target will fail because SIGPOLL (same as
above) is defined on linux, not on *BSD, so turn it off in the
generation of unreg .hc files in the first place.

Target:
3. 
    System/Sendfile.hc: In function `sae6_ret':
    System/Sendfile.hc:526: warning: passing arg 3 of `sendfile'
    makes integer from pointer without a cast
    System/Sendfile.hc:526: too few arguments to function `sendfile'
    gmake[1]: *** [System/Sendfile.o] Error 1
    gmake: *** [all] Error 1
    gmake: Leaving directory `/usr/home/dons/ghc/ghc-6.0.1/libraries'

Haven't gone further with this.

--------------------------------------------------------------
[5] m68k-unknown-netbsd <- i386-unknown-linux
--------------------------------------------------------------

Host:
1. comment out SIGPOLL in mk/config.h

Target:
Made it through the libraries, haven't come back to this yet.