MSYS2 package for GHC 7.10.1

David Macek david.macek.0 at
Mon Mar 30 01:27:55 UTC 2015

Hi everyone.

After finally putting some uninterruped effort into it, I managed to create (hopefully) working prototypes of two GHC-related packages for MSYS2, namely ghc[1] and cabal-install[2]. I've prepared recipes (PKGBUILDs) for building from source, but 64-bit binaries[5][6] are also provided for those who'd like to test my build without building it themselves.

With this post, I'd like to start some work towards the following goals (I hope we can get some Windows discussion going again):

- verify that the build is reproducible (see below for instructions)
- make tests pass
- fix known issues (see below for list)
- discover and fix unknown issues
- review and upstream as many patches as possible
- make it easier for people on Windows to start hacking on GHC

I'll be glad to read any responses, notes, results, hints, comments and/or criticisms. Please note that I'm writing this after being submerged in the matter for some time, so don't be surprised to see any glaring omissions or obvious mistakes.

Known issues

Configure has a problem with docbook
- This mean Haddock is not built. It's probably some silliness on the part of MSYS2's docbook.

Integer-gmp object file has a reference to __mingw_vsnprintf
- Compiling seems to work fine, presumably because the final link command includes -lmingwex, but `runhaskell Setup.lhs` in the text package source tree gave me an undefined reference error, causing inability to load integer-gmp module. I don't know where to start fixing this, as I have not yet reached the depth of understanding of GHC source needed for that.

Wildly untested
- I didn't try building with LLVM and the testsuite is currently failing to start, giving some weird errors. Trying cross compiling or compiling a cross compiler didn't even cross my mind (har har).


A lot of the patches deal with the directory structure -- I tried to mirror the common FHS layout as closely as possible while still retaining the advantages of relocatability. I also removed the bundled toolchain and perl, in favor of packages included with MSYS2. I assume these changes are somewhat controversial for upstreaming, but it'd be nice to see the official bindists to adopt this layout.

There are several patches that I think are more of straight-forward fixes rather than design changes, namely numbers 0007, 0010, 0014 and 0015.

Build instructions

General build instructions[3] are available at our wiki. For convenience, I've compiled a sequence of commands that should get you the ghc and cabal-install packages, given that you start with an up-to-date installation of MSYS2 and a working GHC in PATH. Refer to our guide[4] for correct way of getting/upgrading your MSYS2.

## start MSYS2 shell
pacman --needed -S base-devel mingw-w64-x86_64-toolchain mingw-w64-i686-toolchain
git clone
cd mingw-packages
git checkout ghc
pushd mingw-w64-ghc
makepkg-mingw -sLf
pacman -U mingw-w64-*-ghc-*-any.pkg.tar.xz
## remove old GHC from PATH
pushd mingw-w64-cabal-install
makepkg-mingw -sLf
pacman -U mingw-w64-*-cabal-install-*-any.pkg.tar.xz

If you prefer to build only for one architecture, export a variable named MINGW_INSTALLS with a value of "mingw32" or "mingw64" before building.



David Macek

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4234 bytes
Desc: S/MIME Cryptographic Signature
URL: <>

More information about the ghc-devs mailing list