So my approach is instead to use the fpco Docker images, so that also system libraries and the C toolchain are compatible. It’s problematic, though, because the newest Docker versions use a new manifest version, and as such they can’t pull old images and more.
You can run stack repl --package lens and it will make the global project configuration file /root/.stack/global-project/stack.yaml with the current resolver (right now it is lts-23.10), and then fail the build.
Patch the global project stack.yaml to point at lts-6.30. I suppose newer ones like lts-6.35 should also work.
Now commands like stack repl --package lens work. Using the right resolver and using the system GHC.
Note that the steps that modify the fpco image could of course be used to create new Docker image, and if that image is uploaded, it uses manifest v2, and should therefore work with current Docker versions. And hopefully a few years into the future.
To make this really future proof, I’d like to back up the source packages too at some point.
You may have to pass ‘–ghc-option=-optc-no-pie --ghc-option=-optl-no-pie’ to cabal build/install.
That worked for me last time I encountered this. I think you can even add these as defaults in your cabal config somewhere. Why take the drastic step of using Docker?
The more modern tools I use, the more likely I am to encounter an issue. Using Docker is almost as convenient as being on the host machine. GHCup might be able to install a working compiler, but I would also be relying on modern versions of Cabal working with these ancient library versions. My goal is not to get the latest libraries working with an old compiler, my goal is to conveniently access the ecosystem as it was back then.
For even older GHC releases like 6.2.2, I am considering extracting shared objects from a RedHat Linux 9 installation and manually constructing a i386 Docker image. How’s that for drastic? How would you prefer to set up GHC 6.2.2 environment?
If bootstrapping, I wonder if it could be useful to have a complete working environment for reference.
Let’s say a separate compiler for the GHC 8.0 sources were to be written. Maybe it would be useful to have a reference to compare with. To answer questions like “this module takes awfully long to compile, I wonder if GHC 7.10 also took ages”.
Suppose there is a bug in the type checker of GHC 7.10, which makes it able to compile a GHC 8.0 module even though it shouldn’t. The fact that for the last ~30 years, only GHC can compile itself, means that it is less likely that people would discover if GHC were too reliant on a quirk that it wasn’t supposed to be reliant on.
Does that make sense? Maybe I can retroactively come up with some other justification.