I was recently reminded that we still don’t have a bootstrappable GHC build (in the sense of https://bootstrappable.org/), and that it would would be nice to have.
Somehow this caused me to try to combine all of GHC’s source code into one huge file, which I didn’t fully succeed, nor would it really directly help with bootstrapping GHC. But it made me wonder again.
A previous attempt to bootstrap GHC didn’t use hugs because it doesn’t support recursive modules. Presumably, adding that wouldn’t be too hard.
What else would be missing before we can compile a (oldish) version of GHC with Hugs? Could this plan of attack work:
-
Identify an old version of GHC that
- One can use to bootstrap subsequent versions until today.
- Is old enough to use as few features not supported by hugs as possible.
- Is still new enough so that one can obtain a compatible toolchain.
-
Wrangle the build system to tell you which files to compile, with which preprocessor flags etc.
-
Boostrap all pre-processing tools used by GHC (
cpphs
or use plan cpp,happy
,alex
). -
For every language feature not supported by Hugs, either
- Implement it in Hugs,
- Manually edit the source code to avoid compiling the problematic code, if it is optional (e.g. in an optimization pass)
- Rewrite the problematic code
- Write a pre-processing tool (like the one above) that compiles the feature away
-
Similarly, since Hugs probably ships a
base
that is different than what GHC, or the libraries used by GHC expects, either adjust Hugs’base
, or modify the GHC code that uses it.
@AntC2 seems to be the expert on Hugs here; what is your assessment?