Build GHC on Windows using Hadrian and Stack

To build GHC on Windows you usually need to jump through a lot of hoops, which may be confusing even for experienced GHC developers.

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://
cd ghc

♞ Download and install the bootstrapping GHC and MSYS2:
cd hadrian
stack setup

♜ 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):
stack build

♚ Build GHC:
stack exec hadrian -- --directory ".." -j --flavour=quickest --configure

♝ Test GHC:
cd ..
_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).

The above instructions work on a clean machine with Git and Stack installed (tested with default installation settings), which you can get from here and here, respectively.

Leave a Reply

Your email address will not be published. Required fields are marked *