Haskell Platform on Mac OS X (with clang 5)

The workaround presented in this blog post is somewhat cleaner and I would recommend usind it instead of the hack I describe below.

So, apparently Apple decided to ship a version of the C/C++ compiler clang that is somewhat stricter than gcc and consequently breaks building of a number of Haskell packages. There seems to be no easier fix than to install a version of gcc and instruct GHC to use it instead of clang. Assuming you use homebrew to install packages on Mac OS, here’s how:

$ brew tap homebrew/versions
$ brew install gcc48

This will install gcc-4.8, the current stable version in /usr/local/bin/gcc-4.8. Finally, you’ll have to edit the file


(or similar depending on which version of the Haskell Platform you have installed) by changing the second line from the top to

("C compiler command", "/usr/local/bin/gcc-4.8")

Now, you’ll have no trouble building Haskell packages using cabal or manually. A nice side-effect of installing gcc in addition to clang is that sometimes you’ll encounter other software that will not build with clang because it assumes the more lenient error checking of gcc.

Beware that some packages will not build with gcc but only with clang (GLFW being an example)


This entry was posted in Haskell, Tools. Bookmark the permalink.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.