The Glasgow Haskell Compiler (GHC) on OS X 10.9 (Mavericks)

Apple finally dropped the GNU C Compiler (GCC) from its developer tools and only supports the LLVM-based clang compiler. This causes the Glasgow Haskell Compiler (GHC) some grief, mainly due to its use of the C pre-processor (cpp) as a cheap macro system for Haskell[1].

Here is how to fix this for the latest version of the Haskell Platform for Mac — until the HP maintainers release an updated version. I am assuming you have installed Mavericks and that you have either (a) Xcode 5 (from the Mac App Store) with the command line tools installed or (b) have directly gotten the Command Line Tools for Xcode. Using the latest Haskell Platform for Mac, follow these two steps:

  1. Get and compile Luke Iannini’s clang-xcode5-wrapper[2] and put the binary into /usr/local/bin — or grab this already compiled binary and put it in /usr/local/bin/.
  2. Edit GHC’s settings file as described next.

Edit

/Library/Frameworks/GHC.framework/Versions/Current/usr/lib/ghc-7.6.3/settings

by changing the second line of the file, such that it reads

("C compiler command", "/usr/local/bin/clang-xcode5-wrapper")

That’s it! Happy Haskell hacking on the most advanced operating system ;)

And kudos to the kind Apple engineers who accepted last minute clang patches from the Haskell community, and to Austin Seipp and Carter Schonwald for developing the patches and working with Apple.

[1] I have long maintained the view that (ab)using cpp for Haskell is a Bad Idea.

[2] This is a Haskell program; so, either compile it before updating to Mavericks or grab my binary.

Tags: macos haskell ghc