I have installed ghc-2.05 on a sparc sunos4 with ghc-0.29 which was
distributed as ghc-0.29-sparc-sun-sunos4.  This note may help those
who are going to do same thing.


* Step 1. Preparation ---------------------------------------------------------

I decide that
        bindir = /usr/local/bin
        libdir = /usr/local/lib/ghc-2.05
and GHC used to make hsc is ghc-0.29 whose path is /usr/local/bin/ghc-0.29.

In addition I installed the following C-Shell script named `ghc-w' on
/usr/local/bin which is a ghc wrapper to rerun ghc with more bigger
heap automatically when the specified size causes heap exhausted.
Since compiling with -O causes very many heap exhausted messages,
I use this script.  Though this is awkward, I prefer it to change
many _HC_OPTS params to increase heap limits.

  ----------------------------- begin ghw-w -----------------------------

#!/bin/csh -f
# A GHC wrapper to rerun ghc with more bigger heap automatically
# when the specified size causes heap exhausted.

set hlimit = 30 # MB  Heap increasing limit.
set hstep  = 4  # MB  And the step added to previous value in each rerun.

usage:
if ($#argv == 0) then
        echo 'Usage: ghc-w [-v] ghc args...'
        exit 1
endif

if ($argv[1] == -v) then
        set verify
        shift argv
        goto usage
endif

set ghc = $argv[1]
shift argv


set tmp1 = /tmp/tmp1.$$
set tmp2 = /tmp/tmp2.$$
set heap
set hsize = 0

while ($hsize <= $hlimit)

$ghc $argv:q $heap >& $tmp1
set xst = $status # save ghc's exit status

egrep '^while trying to allocate .*byte heap' $tmp1 > $tmp2

if ($status == 0) then
        set hsize = `sed  's/^.*in a \([0-9]*\)......-byte.*/\1/' <$tmp2`
        @ hsize = $hsize + $hstep
        set heap = -H${hsize}m
        if ($?verify) then
                echo "*** ghc-w ${ghc}: Heap exhausted, rerun ghc with $heap."
        endif
else
        /bin/sh -c "cat $tmp1 1>&2"
        if ($hsize != 0) then
              echo "*** ghc-w ${ghc}: $hsize MB heap is required."
        endif
        goto exit
endif


end

echo "*** ghc-w ${ghc}: The heap can not be increased any more:"
/bin/sh -c "cat $tmp1 1>&2"

exit:
/bin/rm -f $tmp1 $tmp2
exit $xst

  ------------------------------ end ghw-w ------------------------------


* Step 2. configure & make boot -----------------------------------------------

# ./configure
# make boot


* Step 3. create mk/build.mk --------------------------------------------------

## The contents of the mk/build.mk
WithGhcHc       = ghc-w ghc-0.29
HC              = ghc-w $(FPTOOLS_TOP)/ghc/driver/ghc
GhcHcOpts       = -O
GhcLibHcOpts    = -O -split-objs -odir $(basename $*)
SRC_HC_OPTS     += -O
libdir          = ${exec_prefix}/lib/ghc-2.05


* Step 4. change ghc/compiler/Makefile ----------------------------------------

I don't know why (sorry for my no knowledge of ghc) but the following
line must be added to the Makefile

        absCSyn/PprAbsC_HC_OPTS         = -Onot

since the file absCSyn/PprAbsC.lhs will not be compiled with -O due to
the following errors:

        "codeGen/ClosureInfo.hi", line 72:
            undefined type constructor: StgSyn.StgBinderInfo

        "codeGen/ClosureInfo.hi", line 74:
            undefined type constructor: CgMonad.CgInfoDownwards

         [and number of similar errors]


* Step 5. make ----------------------------------------------------------------

Run the following make commands (at midnight :-).

# make all
# make install


* Step 6. re-ranlib -----------------------------------------------------------

re-ranlib was still necessary...

# cd /usr/local/lib/ghc-2.05
# ranlib *.a


-------------------------------------------------------------------------------

Sincerely yours,

--
Abe Seika

Reply via email to