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

Simon Marlow simonmar@microsoft.com
Mon, 31 Mar 2003 13:54:14 +0100


> below find a set of patches that hopefully should fix the following
> for ghc-5.04.3:
>=20
> 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...
>=20
> 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.
>=20
> I think most of the patches should be more or less self-explanatory.
> But please feel free to ask if something looks strange.

Thanks, I've committed most of your patches...
=20
> I will just mention one problem I had, that I think needs a cleaner
> solution. This is marked "XXX_UB" in the patches below.
>=20
> 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:
>=20
>       -L/usr/pkg/lib -Wl,-R/usr/pkg/lib
>=20
> 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=3D... and --with-gmp=3D... options to the configure
> script?  This would at least partly solve the problem.

Yes, I think this would be a better solution - at least more consistent
with the way configure handles other such things.  The right thing to do
is to add

  --with-readline-includes=3D...
  --with-readline-libraries=3D...

and=20

  --with-gmp-includes=3D...
  --with-gmp-libraries=3D...

Incidentally, why are the -Wl,-R<dir> options needed?  I've never come
across that before, usually the runtime linker just finds the libraries
in the place they were originally linked from.

> 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).

Note that HC files can also be platform dependent, since they depend in
some cases on the values of symbols from config.h.  We used to try to
keep .hc files completely platform-independent, but I've come around to
the conclusion that this isn't a realistic goal.  As soon as you use a
platform-dependent #ifdef or #define in the Haskell source (and we do
that a fair bit in the libraries and even the compiler), the property is
lost.

So, while one set of .hc files might work for all the versions of NetBSD
you want to build the compiler on, we don't guarantee it.

Cheers,
	Simon