Version 3 (modified by thoughtpolice, 3 years ago) (diff)


This page documents the instructions for setting up a Windows build using msys2, which is a fairly complete build of MinGW + the msys tools. It is pretty self contained and fixes several pesky bugs with the traditional implementation. It's also smaller and has a convenient package manager, pacman.

NB: You can extract .tar.xz files with 7Zip:

32bit Windows

Extract the msys2 base package somewhere like C:\msys32

Extract the GHC binary somewhere like C:\msys32\ghc-7.6.3

Launch the shell with C:\msys32\mingw32_shell.bat

64bit Windows

Extract the msys2 base package somewhere like C:\msys64

Extract the GHC binary somewhere like C:\msys64\ghc-7.6.3

Launch the shell with C:\msys64\mingw64_shell.bat

Setting up your PATH

Create a ~/bin directory for the cabal.exe (and whatever else you want.) Also, put GHC in your $PATH by appending the following to ~/.bashrc:

$ mkdir ~/bin
$ echo 'export PATH=/ghc-7.6.3/bin:$PATH' >> ~/.bashrc
$ echo 'export PATH=$HOME/bin:$PATH'      >> ~/.bashrc

We'll also go ahead and add the default cabal.exe binary installation path:

$ echo 'export PATH=/c/Users/YourUserNameHere/AppData/Roaming/cabal/bin:$PATH' >> ~/.bashrc

Make sure you restart your shell.

Installing packages & tools

The msys2 package uses pacman (the venerable ArchLinux package manager) to manage packages. Once you're set up, upgrade everything, and install some dependencies:

$ pacman -Syu
$ pacman -S python2 git wget tar gzip binutils gcc autoconf make libtool automake xz

Now install a cabal.exe prebuilt binary, and install alex and happy:

$ wget
$ mv cabal.exe ~/bin
$ cabal update
$ cabal install alex happy
$ alex --version
$ happy --version

A Quick build

You should now be able to build GHC:

$ cd ~
$ git clone
$ cd ghc && ./sync-all --testsuite --nofib --extra get
$ ./boot && ./configure
$ make -j5

But be sure to read on for more!