Hadrian to the rescue!
Hadrian, a new build system for GHC that I’ve been developing, is written in Haskell and can therefore be built and run via Stack that can install appropriate bootstrapping GHC and MSYS2 environment in an automated and robust way. This was first pointed out by Neil Mitchell, and I’ve recently simplified build instructions even further. The latest version of the instructions is maintained here.
♟ Get GHC sources:
git clone --recursive git://git.haskell.org/ghc.git
♞ Download and install the bootstrapping GHC and MSYS2:
♜ Install utilities required during the GHC build process:
stack exec -- pacman -S autoconf automake-wrapper make patch tar --noconfirm
♛ Build Hadrian and dependencies (including GHC dependencies Alex and Happy):
♚ Build GHC:
stack exec hadrian -- --directory ".." -j --flavour=quickest --configure
♝ Test GHC:
_build\stage1\bin\ghc -e 1+2
This takes about 20 minutes and builds GHC without optimisations. If you need an optimised GHC, drop the
--flavour=quickest flag from the build command line (this will slow down the build to about an hour).