Subject: [PATCH] Add GHC 4 for the Haskell bootstrap

From: Ricardo Wurmus <[email-masked]>
Date: Fri, 28 Jan 2022 18:35:06 +0100

This patch adds GHC 4.08.2.  GHC 4.08.2 is sufficient to build GHC 6.0.

GHC 6.6 was released in April 2007. To build 6.6 you need GHC > 5.04
(http://web.archive.org/web/20070426051520/http://hackage.haskell.org:80/trac/ghc/wiki/Building/Prerequisites)
or maybe 6.0
(http://web.archive.org/web/20071224035747/http://hackage.haskell.org:80/trac/ghc/wiki/Building/Prerequisites)

To build 6.8.* you need GHC >= 6.4
To build 6.10.* you need GHC >= 6.6
To build 7.4.* you need GHC >= 6.12
To build 7.6.* you need GHC >= 7.0.1

So with this chain we should be able to bootstrap GHC:
4.08.2 -> 6.0 -> 6.6 -> 6.12(?) -> 7.4 -> 7.6

Back to 4.08.2.  It’s ancient and it’s not possible to build it even
with GCC 4.9; it will not fail, but it will print a bunch of serious
errors.  So I’m using GCC 2.95, which we already have for the
early GCC bootstrap.  That’s why all of this is in commencement.scm — it
may be worth exporting GCC 2.95, so that this whole GHC bootstrap can go
to haskell.scm instead of cluttering up commencement.scm.

I also need to use Perl 5.14, as one of the Perl scripts uses $*, which
used to enable multi-line regexp matching.  It’s not easy to just remove
this and update the regular expressions with the /s or /m modifiers
because there are dozens of non-trivial regexes there that are affected
by $*.  It would be very nice to patch this though.

Building with a more recent (but not latest) Perl works, but prints a
warning.  That’s not okay, because $* simply has no effect in these
versions of Perl.  Later this silent change was turned into a visible
error, which is why the build would fail with the latest Perl.

I used the “--enable-hc-boot” configure flag, which lets us bootstrap
from hc files.  I don’t see a reason not to use them as they are proper
code; they don’t look generated nor are they unintelligible.

Comments on all this would be very welcome!

-- 
Ricardo