Patches for NetBSD port and automatic .hc bootstrap (long)

Urban Boquist boquist@crt.se
Sun, 30 Mar 2003 21:03:47 +0200


--h2o8VefaQI
Content-Type: text/plain; charset=us-ascii
Content-Description: message body text
Content-Transfer-Encoding: 7bit

Hi GHC maintainers,

below find a set of patches that hopefully should fix the following
for ghc-5.04.3:

1. (re-)port to NetBSD/i386.
   - the last GHC to work for NetBSD was 4.04, I think. Since then,
     both GHC and NetBSD has changed a lot...

2. restore the ability to do an automatic bootstrap from .hc files.
   - at least the updated distrib/hc-build script runs to completion
     without errors for me now on NetBSD/i386, and the resulting
     compiler seems to work fine (at least it is able to compile
     itself once again). All this on a system with no previous GHC
     installed.

I think most of the patches should be more or less self-explanatory.
But please feel free to ask if something looks strange.

I will just mention one problem I had, that I think needs a cleaner
solution. This is marked "XXX_UB" in the patches below.

The problem is the readline library in NetBSD. There is one readline
in the base system (/usr/include and /usr/lib) but that is not the GNU
readline that GHC expects. Instead the readline in /usr/pkg/include
and /usr/pkg/lib must be used. The GCC in NetBSD does not include the
/usr/pkg paths by default, so we must pass explicit -I/-L/-R all the
time when using it. In particular this:

      -L/usr/pkg/lib -Wl,-R/usr/pkg/lib

needs to go into hslibs/util/util.conf.in. And the same needs to go
into ghc/rts/rts.conf.in for libgmp. I had to invent two new configure
variables to make this work, ExtraLdOptsReadline and ExtraLdOptsGmp.
Sofar this is OK I think, other systems should be able to use these
too if they have readline or gmp installed in non-standard places.

However, the problem is how to set these variables in the configure
script. Below you can see the hack I did for NetBSD, but that is not
very elegant. Maybe a better solution would be to add
--with-readline=... and --with-gmp=... options to the configure
script?  This would at least partly solve the problem.

I will also update the NetBSD package (port) with these patches. I
think I will try to keep the package booting from .hc files rather
than going the "first download small binary bootstrap kit" route that
you guys seem to have chosen for FreeBSD nowadays. It seems to me that
although booting from .hc files is very fragile business it has the
advantage that it makes the package less sensitive to the exact OS
versions involved (in particular the version the binary bootstrap kit
was built on).

Kinds regards,

      -- Urban Boquist <boquist@crt.se>

P.S. Please CC: any replies to me, I am not subscribed to this list.


--h2o8VefaQI
Content-Type: text/plain
Content-Description: ghc-5.04.3.diff
Content-Disposition: inline;
	filename="ghc-5.04.3.diff"
Content-Transfer-Encoding: 7bit

diff -bu -r --exclude=configure ghc-5.04.3.orig/Makefile ghc-5.04.3/Makefile
--- ghc-5.04.3.orig/Makefile	Wed Mar  5 11:11:34 2003
+++ ghc-5.04.3/Makefile	Sat Mar 29 00:38:06 2003
@@ -295,11 +295,11 @@
 	$(RM) -r $(ProjectNameShort)-$(ProjectVersion)
 	$(LN_S) . $(ProjectNameShort)-$(ProjectVersion)
 	$(FIND) $(ProjectNameShort)-$(ProjectVersion)/ghc/compiler \
-	     $(ProjectNameShort)-$(ProjectVersion)/ghc/driver \
+	     $(ProjectNameShort)-$(ProjectVersion)/ghc/utils \
 	     $(ProjectNameShort)-$(ProjectVersion)/libraries \
 	     $(ProjectNameShort)-$(ProjectVersion)/hslibs \
 	  \( -name "*.hc" -o -name "*_hsc.[ch]" -o -name "*_stub.[ch]" \) -print > hc-files-to-go
-	for f in `$(FIND) $(ProjectNameShort)-$(ProjectVersion)/ghc/compiler $(ProjectNameShort)-$(ProjectVersion)/ghc/driver $(ProjectNameShort)-$(ProjectVersion)/libraries $(ProjectNameShort)-$(ProjectVersion)/hslibs -name "*.hsc" -print` ""; do \
+	for f in `$(FIND) $(ProjectNameShort)-$(ProjectVersion)/ghc/compiler $(ProjectNameShort)-$(ProjectVersion)/ghc/utils $(ProjectNameShort)-$(ProjectVersion)/libraries $(ProjectNameShort)-$(ProjectVersion)/hslibs -name "*.hsc" -print` ""; do \
 	     if test "x$$f" != "x" && test -e `echo "$$f" | sed 's/hsc$$/hs/g'`; then \
 	        echo `echo "$$f" | sed 's/hsc$$/hs/g' ` >> hc-files-to-go ; \
 	     fi; \
diff -bu -r --exclude=configure ghc-5.04.3.orig/configure.in ghc-5.04.3/configure.in
--- ghc-5.04.3.orig/configure.in	Mon Feb 17 12:27:20 2003
+++ ghc-5.04.3/configure.in	Sat Mar 29 00:38:06 2003
@@ -718,6 +718,13 @@
 fi
 AC_SUBST(HaveReadlineHeaders)
 
+dnl ** XXX_UB: fix this in a better way!
+ReadlineIncludePath=
+if test x"$TargetOS_CPP" = x"netbsd"; then
+  ReadlineIncludePath=/usr/pkg/include
+fi
+AC_SUBST(ReadlineIncludePath)
+
 dnl ** check for DOS include files
 AC_CHECK_HEADERS(dos.h conio.h io.h std.h) 
 
@@ -734,14 +741,14 @@
 AC_CHECK_HEADERS(dlfcn.h dl.h) 
 
 dnl ** check for farcalloc (in bcc)
-AC_CHECK_HEADER(alloc.h,AC_CHECK_FUNCS(farcalloc))
+AC_CHECK_HEADER(alloc.h,[AC_CHECK_FUNCS(farcalloc)])
 
 dnl ** check for valloc (in sunos, solaris, mips, amiga, next, minix, ultrix)
-AC_CHECK_HEADER(malloc.h,AC_CHECK_FUNCS(valloc))
+AC_CHECK_HEADER(malloc.h,[AC_CHECK_FUNCS(valloc)])
 
 dnl ** check for POSIX regex
 HavePosixRegex=NO
-AC_CHECK_HEADER(regex.h,AC_CHECK_FUNC(regcomp, HavePosixRegex=YES))
+AC_CHECK_HEADER(regex.h,[AC_CHECK_FUNC(regcomp, HavePosixRegex=YES)])
 AC_SUBST(HavePosixRegex)
 
 dnl ** how do we get a timezone name, and UTC offset ?
@@ -942,6 +949,13 @@
 AC_SUBST(HaveLibGmp)
 AC_SUBST(LibGmp)
 
+dnl ** XXX_UB: fix this in a better way!
+ExtraLdOptsGmp=
+if test x"$TargetOS_CPP" = x"netbsd"; then
+  ExtraLdOptsGmp="-L/usr/pkg/lib -Wl,-R/usr/pkg/lib"
+fi
+AC_SUBST(ExtraLdOptsGmp)
+
 dnl ** (Mac OS X only: check for HaskellSupport.framework)
 HaveFrameworkHaskellSupport=NO
 if test $HostPlatform = "powerpc-apple-darwin"; then
@@ -1012,6 +1026,13 @@
   AC_DEFINE(HAVE_READLINE_4, 0)
   AC_DEFINE(HAVE_READLINE_4_2, 0)
 fi
+
+dnl ** XXX_UB: fix this in a better way!
+ExtraLdOptsReadline=
+if test x"$TargetOS_CPP" = x"netbsd"; then
+  ExtraLdOptsReadline="-L/usr/pkg/lib -Wl,-R/usr/pkg/lib"
+fi
+AC_SUBST(ExtraLdOptsReadline)
 
 dnl ** check for math library
 FPTOOLS_CHECK_LIBM()
diff -bu -r --exclude=configure ghc-5.04.3.orig/distrib/hc-build ghc-5.04.3/distrib/hc-build
--- ghc-5.04.3.orig/distrib/hc-build	Tue Jan 15 06:39:15 2002
+++ ghc-5.04.3/distrib/hc-build	Sun Mar 30 17:22:08 2003
@@ -2,6 +2,7 @@
 
 # Manuel M. T. Chakravarty <chak@acm.org>, June 2000
 # Updated for GHC 5.00, Simon Marlow, March 2001
+# Updated for GHC 5.04.3, Urban Boquist, March 2003
 #
 # Script to build GHC from .hc files (must be run in the fptools/ root
 # directory into which the source and .hc files must already have been
@@ -32,29 +33,37 @@
 # touch happy generated files; so that in non-bootstrapping mode for
 # installation, no attempt is made to call happy
 #
-touch ghc/compiler/rename/ParseIface.hs
 touch ghc/compiler/parser/Parser.hs
 touch ghc/compiler/main/ParsePkgConf.hs
 touch hslibs/hssource/HsParser.hs
 
 # We don't have genprimopcode yet so don't try to use it
 touch ghc/compiler/prelude/primops.txt
-touch ghc/lib/std/PrelPrimopWrappers.hs
+touch libraries/base/GHC/PrimopWrappers.hs
 
-echo "*** Building hsc..."
+echo "*** Building compiler..."
 ./configure --enable-hc-boot $configopts
+
+# A couple of Makefiles test BootingFromHc before including
+# boilerplate.mk, so we have to pass it explicitly:
+MAKEFLAGS="BootingFromHc=YES"
+export MAKEFLAGS
+
 $MAKE -C glafp-utils boot all
 $MAKE -C ghc boot
+$MAKE -C libraries boot all
 $MAKE -C hslibs boot all
 $MAKE -C ghc all
 
+MAKEFLAGS=
+
 echo "*** Building libraries..."
 
 # Reconfigure, using the newly-build ghc binary as our $(GHC), and
 # with hc bootstrapping disabled.
-HappyCmd="$PWD/distrib/fake-happy" ./configure --with-ghc="$PWD/ghc/compiler/ghc-inplace"
+HappyCmd="$PWD/distrib/fake-happy" ./configure --with-ghc="$PWD/ghc/compiler/ghc-inplace" $configopts
 
-PRIMOP_BITS=primop-data-decl.hs-incl \
+PRIMOP_BITS="primop-data-decl.hs-incl \
             primop-tag.hs-incl  \
             primop-list.hs-incl  \
             primop-has-side-effects.hs-incl  \
@@ -64,28 +73,30 @@
             primop-can-fail.hs-incl  \
             primop-strictness.hs-incl  \
             primop-usage.hs-incl  \
-            primop-primop-info.hs-incl
+            primop-primop-info.hs-incl"
 
 # The reconfigure step updates a few files, which can lead to
 # unnecessary recompilations.  Touch a bunch of things here to avoid
 # having to recompile stuff that we've already built.
-(cd ghc/compiler; touch $PRIMOP_BITS prelude/PrimOp.o main/Config.hs main/Config.o ghc-*)
+(cd ghc/compiler; touch $PRIMOP_BITS parser/hschooks.o prelude/PrimOp.o main/Config.hs main/Config.o ghc-*)
 
 # Remove the old libraries.  Don't use make clean, because we don't
 # want to delete the .hs files generated from the .hsc files, because
 # we don't have hsc2hs built yet.
-find ghc/lib/std hslibs | grep '\.\(o\|a\)' | xargs rm -f
+find libraries hslibs | grep '\.\(o\|a\)' | xargs rm -f
 
 # Do includes and RTS now
 $MAKE -C ghc/includes boot && $MAKE -C ghc/includes all
 $MAKE -C ghc/rts      boot && $MAKE -C ghc/rts      all
 
 # Now build a new set of libraries
-$MAKE -C ghc/lib boot all
+$MAKE -C libraries boot all
 $MAKE -C hslibs  boot all
 
-# Finally build ghc/utils, now that we have libraries
-$MAKE -C ghc/utils boot all
+# Finally build all of ghc/utils
+$MAKE -C ghc/utils clean && $MAKE -C ghc/utils boot all
 
-# At this point, the tree should be safe to do 'make install' in.
+# Avoid relinking the compiler during 'make install':
+(cd ghc/compiler; touch parser/hschooks.o ghc-*)
 
+# At this point, the tree should be safe to do 'make install' in.
diff -bu -r --exclude=configure ghc-5.04.3.orig/ghc/Makefile ghc-5.04.3/ghc/Makefile
--- ghc-5.04.3.orig/ghc/Makefile	Tue Jul  2 16:15:22 2002
+++ ghc-5.04.3/ghc/Makefile	Sat Mar 29 00:38:06 2003
@@ -18,10 +18,10 @@
 # before the rest to have a config.h, etc.
 #
 # If we're booting from .hc files, swap the order
-# we descend into compiler/ and lib/.
+# we descend into subdirs - to boot utils must be before driver.
 #
 ifeq "$(BootingFromHc)" "YES"
-SUBDIRS = includes utils rts docs compiler driver
+SUBDIRS = includes rts docs compiler utils driver
 else
 ifneq "$(ILXized)" "YES"
 SUBDIRS = includes utils driver docs compiler rts
diff -bu -r --exclude=configure ghc-5.04.3.orig/ghc/compiler/Makefile ghc-5.04.3/ghc/compiler/Makefile
--- ghc-5.04.3.orig/ghc/compiler/Makefile	Fri Jun 14 10:23:57 2002
+++ ghc-5.04.3/ghc/compiler/Makefile	Sat Mar 29 00:38:06 2003
@@ -4,6 +4,7 @@
 TOP = ..
 
 # Use GHC for compiling C bits (NB. must be before boilerplate include)
+# NB. this requires BootingFromHc to be set on the make command line!
 #
 ifneq "$(BootingFromHc)" "YES"
 UseGhcForCc = YES
diff -bu -r --exclude=configure ghc-5.04.3.orig/ghc/driver/mangler/ghc-asm.lprl ghc-5.04.3/ghc/driver/mangler/ghc-asm.lprl
--- ghc-5.04.3.orig/ghc/driver/mangler/ghc-asm.lprl	Sun Dec  8 15:29:50 2002
+++ ghc-5.04.3/ghc/driver/mangler/ghc-asm.lprl	Sat Mar 29 00:38:06 2003
@@ -197,7 +197,7 @@
         $T_hsc_cc_PAT   = '\.string.*\)(hsc|cc) (.*)\\\\t(.*)"';
     }
 
-    $T_DOT_WORD	    = '\.(long|value|byte|zero)';
+    $T_DOT_WORD	    = '\.(long|value|word|byte|zero)';
     $T_DOT_GLOBAL   = '\.globl';
     $T_HDR_literal  = "\.section\t\.rodata\n"; # or just use .text??? (WDP 95/11)
     $T_HDR_misc	    = "\.text\n\t\.align 4\n";
diff -bu -r --exclude=configure ghc-5.04.3.orig/ghc/mk/paths.mk ghc-5.04.3/ghc/mk/paths.mk
--- ghc-5.04.3.orig/ghc/mk/paths.mk	Mon Apr  1 15:57:10 2002
+++ ghc-5.04.3/ghc/mk/paths.mk	Sat Mar 29 00:38:06 2003
@@ -34,6 +34,7 @@
 GHC_DRIVER_DIR		= $(GHC_TOP)/$(GHC_DRIVER_DIR_REL)
 GHC_PKG_DIR		= $(GHC_TOP)/$(GHC_PKG_DIR_REL)
 GHC_GENPRIMOP_DIR	= $(GHC_TOP)/$(GHC_GENPRIMOP_DIR_REL)
+GHC_MANGLER_DIR 	= $(GHC_TOP)/$(GHC_MANGLER_DIR_REL)
 
 GHC_LIB_DIR	 	= $(FPTOOLS_TOP)/libraries
 
diff -bu -r --exclude=configure ghc-5.04.3.orig/ghc/rts/Linker.c ghc-5.04.3/ghc/rts/Linker.c
--- ghc-5.04.3.orig/ghc/rts/Linker.c	Sun Oct 13 19:50:54 2002
+++ ghc-5.04.3/ghc/rts/Linker.c	Sat Mar 29 00:38:06 2003
@@ -56,7 +56,7 @@
 #include <sys/mman.h>
 #endif
 
-#if defined(linux_TARGET_OS) || defined(solaris2_TARGET_OS) || defined(freebsd_TARGET_OS)
+#if defined(linux_TARGET_OS) || defined(solaris2_TARGET_OS) || defined(freebsd_TARGET_OS) || defined(netbsd_TARGET_OS)
 #  define OBJFORMAT_ELF
 #elif defined(cygwin32_TARGET_OS) || defined (mingw32_TARGET_OS)
 #  define OBJFORMAT_PEi386
diff -bu -r --exclude=configure ghc-5.04.3.orig/ghc/rts/Makefile ghc-5.04.3/ghc/rts/Makefile
--- ghc-5.04.3.orig/ghc/rts/Makefile	Sun Oct 13 19:50:55 2002
+++ ghc-5.04.3/ghc/rts/Makefile	Sat Mar 29 00:38:06 2003
@@ -21,6 +21,7 @@
 # set of suffix rules for compiling C code, using $(HC) rather than $(CC)
 # and prepending "-optc" to $(CC_OPTS).  NB. must be done before including
 # boilerplate.mk below.
+# NB. this requires BootingFromHc to be set on the make command line!
 ifneq "$(BootingFromHc)" "YES"
 UseGhcForCc = YES
 endif
@@ -126,6 +127,10 @@
 ifeq "$(HaveLibMingwEx)" "YES"
 PACKAGE_CPP_OPTS += -DHAVE_LIBMINGWEX
 endif
+
+# have to get ExtraLdOptsGmp in through CPP to rts.conf.in (see hslibs/util/Makefile)
+comma = ,
+PACKAGE_CPP_OPTS += -DExtraLdOptsGmp='$(patsubst %,"%"$(comma),$(ExtraLdOptsGmp))'
 
 #-----------------------------------------------------------------------------
 # Include the Front panel code?
diff -bu -r --exclude=configure ghc-5.04.3.orig/ghc/rts/Stats.c ghc-5.04.3/ghc/rts/Stats.c
--- ghc-5.04.3.orig/ghc/rts/Stats.c	Wed Feb  6 02:21:40 2002
+++ ghc-5.04.3/ghc/rts/Stats.c	Sat Mar 29 00:38:06 2003
@@ -749,7 +749,7 @@
 	  fprintf(sf, "<<ghc: %llu bytes, ", GC_tot_alloc*sizeof(W_));
 	  fprintf(sf, "%d GCs, %ld/%ld avg/max bytes residency (%ld samples), %luM in use, %.2f INIT (%.2f elapsed), %.2f MUT (%.2f elapsed), %.2f GC (%.2f elapsed) :ghc>>\n",
 		    total_collections,
-		    AvgResidency*sizeof(W_)/ResidencySamples, 
+		    (ResidencySamples==0) ? 0 : AvgResidency*sizeof(W_)/ResidencySamples,
 		    MaxResidency*sizeof(W_), 
 		    ResidencySamples,
 		    (unsigned long)(mblocks_allocated * MBLOCK_SIZE / (1024L * 1024L)),
diff -bu -r --exclude=configure ghc-5.04.3.orig/ghc/rts/rts.conf.in ghc-5.04.3/ghc/rts/rts.conf.in
--- ghc-5.04.3.orig/ghc/rts/rts.conf.in	Mon Feb 10 11:18:31 2003
+++ ghc-5.04.3/ghc/rts/rts.conf.in	Sat Mar 29 00:38:06 2003
@@ -67,6 +67,7 @@
                   so we force it to be included with special options to ld. */
         extra_ld_opts  =
          [
+	   ExtraLdOptsGmp
 #ifdef LEADING_UNDERSCORE
            "-u", "_GHCziBase_Izh_static_info"
          , "-u", "_GHCziBase_Czh_static_info"
diff -bu -r --exclude=configure ghc-5.04.3.orig/ghc/utils/Makefile ghc-5.04.3/ghc/utils/Makefile
--- ghc-5.04.3.orig/ghc/utils/Makefile	Tue Sep 11 13:13:22 2001
+++ ghc-5.04.3/ghc/utils/Makefile	Sat Mar 29 00:38:06 2003
@@ -6,7 +6,7 @@
 SUBDIRS = hp2ps stat2resid unlit
 else
 ifeq "$(BootingFromHc)" "YES"
-SUBDIRS = hp2ps parallel stat2resid prof unlit
+SUBDIRS = ghc-pkg unlit
 else
 SUBDIRS = hasktags ghc-pkg hp2ps hsc2hs parallel stat2resid prof unlit genprimopcode
 endif
diff -bu -r --exclude=configure ghc-5.04.3.orig/hslibs/util/Makefile ghc-5.04.3/hslibs/util/Makefile
--- ghc-5.04.3.orig/hslibs/util/Makefile	Tue Apr 23 11:31:39 2002
+++ ghc-5.04.3/hslibs/util/Makefile	Sat Mar 29 00:38:06 2003
@@ -23,16 +23,25 @@
   PACKAGE_DEPS := $(filter-out posix, $(PACKAGE_DEPS))
 endif
 
+# hsc2hs needs to find the correct readline includes:
+EXTRA_HSC2HS_OPTS += -I$(ReadlineIncludePath)
+
 # yeuch, have to get LibsReadline in through CPP to util.conf.in
 comma = ,
 PACKAGE_CPP_OPTS += -DLibsReadline='$(patsubst %,$(comma)"%",$(LibsReadline))'
 
+# ... same with ExtraLdOptsReadline:
+PACKAGE_CPP_OPTS += -DExtraLdOptsReadline='$(patsubst %,"%"$(comma),$(ExtraLdOptsReadline))'
+
 # Remove Readline.hs if it is not wanted or headers are not available.
 ifeq "$(GhcLibsWithReadline)" "YES"
   ifneq "$(ReadlineIncludePath)" ""
     SRC_HC_OPTS += -I$(ReadlineIncludePath)
   endif
   STUBOBJS += Readline_stub.$(way_)o
+  ifeq "$(BootingFromHc)" "YES"
+    all :: $(STUBOBJS)
+  endif
   CLEAN_FILES += Readline_stub.[ch] $(STUBOBJS)
 else
   EXCLUDED_SRCS += Readline.hsc Readline_stub.c
diff -bu -r --exclude=configure ghc-5.04.3.orig/hslibs/util/util.conf.in ghc-5.04.3/hslibs/util/util.conf.in
--- ghc-5.04.3.orig/hslibs/util/util.conf.in	Sun Feb 17 16:22:11 2002
+++ ghc-5.04.3/hslibs/util/util.conf.in	Sat Mar 29 00:38:06 2003
@@ -35,5 +35,8 @@
 			  ],
 	extra_ghc_opts	= [],
 	extra_cc_opts	= [],
-	extra_ld_opts	= []
+	extra_ld_opts	= [
+			    ExtraLdOptsReadline
+			    "" /* handle final comma... */
+			  ]
 }
diff -bu -r --exclude=configure ghc-5.04.3.orig/mk/bootstrap.mk ghc-5.04.3/mk/bootstrap.mk
--- ghc-5.04.3.orig/mk/bootstrap.mk	Tue May 14 10:25:46 2002
+++ ghc-5.04.3/mk/bootstrap.mk	Sat Mar 29 00:38:06 2003
@@ -123,10 +123,22 @@
 
 HC_BOOT_LIBS = -lHStext -lHStext_cbits -lHSutil -lHSposix -lHSposix_cbits -lHSconcurrent -lHSlang -lHSlang_cbits -lHShaskell98 -lHSbase -lHSbase_cbits -lHSrts -lgmp -lm $(EXTRA_HC_BOOT_LIBS)
 
+# XXX_UB: if we build ghc/utils with hc-bootstrapped compiler+libs,
+# the link fails, libHSrts uses a (new) symbol from libHSbase.
+# Maybe we should insert a ranlib somewhere?
+# Workaround the problem:
+HC_BOOT_LIBS += -lHSbase
+
 ifeq "$(GhcLibsWithReadline)" "YES"
 HC_BOOT_LIBS += $(patsubst %, -l%, $(LibsReadline))
+HC_BOOT_LIBS += $(ExtraLdOptsReadline)
+ifneq "$(ReadlineIncludePath)" ""
+HC_BOOT_CC_OPTS += -I$(ReadlineIncludePath)
+endif
 endif
 
+HC_BOOT_LIBS += $(ExtraLdOptsGmp)
+
 ifeq "$(HaveLibDL)" "YES"
 HC_BOOT_LIBS += -ldl
 endif
@@ -149,7 +161,7 @@
 	$(CC) -x c $< -o $@ -S -O $(HC_BOOT_CC_OPTS) -I.  `echo $(patsubst -monly-%-regs, -DSTOLEN_X86_REGS=%, $(filter -monly-%-regs, $($*_HC_OPTS))) | sed 's/^$$/-DSTOLEN_X86_REGS=4/'`
 
 %.s : %.raw_s
-	$(FPTOOLS_TOP)/$(GHC_MANGLER_DIR)/$(GHC_MANGLER) $< $@ $(patsubst -monly-%-regs, %, $(filter -monly-%-regs, $($*_HC_OPTS)))
+	$(GHC_MANGLER) $< $@ $(patsubst -monly-%-regs, %, $(filter -monly-%-regs, $($*_HC_OPTS)))
 
 %.o : %.s
 	$(CC) -c -o $@ $<
diff -bu -r --exclude=configure ghc-5.04.3.orig/mk/config.mk.in ghc-5.04.3/mk/config.mk.in
--- ghc-5.04.3.orig/mk/config.mk.in	Wed Feb 12 22:41:18 2003
+++ ghc-5.04.3/mk/config.mk.in	Sat Mar 29 00:38:06 2003
@@ -338,10 +338,13 @@
 # Libraries needed for linking with readline
 LibsReadline=@LibsReadline@
 
+# Additional linker flags needed for linking with readline
+ExtraLdOptsReadline=@ExtraLdOptsReadline@
+
 # Include path to readline.h
 # (no path == in standard include path)
 #
-ReadlineIncludePath=
+ReadlineIncludePath=@ReadlineIncludePath@
 
 # Math library
 LIBM=@LIBM@
@@ -678,6 +681,9 @@
 #
 HaveLibGmp	= @HaveLibGmp@
 LibGmp		= @LibGmp@
+
+# Additional linker flags needed for linking with gmp (when HaveLibGmp=YES)
+ExtraLdOptsGmp=@ExtraLdOptsGmp@
 
 #-----------------------------------------------------------------------------
 # Mingwex Library
diff -bu -r --exclude=configure ghc-5.04.3.orig/mk/package.mk ghc-5.04.3/mk/package.mk
--- ghc-5.04.3.orig/mk/package.mk	Tue Jul 23 12:19:50 2002
+++ ghc-5.04.3/mk/package.mk	Sat Mar 29 00:38:06 2003
@@ -17,8 +17,10 @@
 		| sed 's/^#.*$$//g' >$@
 
 boot all :: $(PACKAGE).conf.inplace $(PACKAGE).conf.installed
+ifneq "$(BootingFromHc)" "YES"
 	$(GHC_PKG_INPLACE) --update-package <$(PACKAGE).conf.inplace
 	$(GHC_PKG_INPLACE)  -f $(GHC_DRIVER_DIR)/package.conf --update-package <$(PACKAGE).conf.installed
+endif
 
 CLEAN_FILES += $(PACKAGE).conf.installed $(PACKAGE).conf.inplace
 
@@ -31,7 +33,7 @@
 
 SRC_HSC2HS_OPTS += -I.
 
-ifeq "$(NON_HS_PACKAGE)" ""
+ifeq "$(NON_HS_PKG)" ""
 SRC_HC_OPTS 	+= -package-name $(PACKAGE)
 SRC_HC_OPTS 	+= $(GhcLibHcOpts)
 SRC_HC_OPTS     += $(patsubst %, -package %, $(PACKAGE_DEPS))

--h2o8VefaQI--