public
Last active

xcode 5 + OS X 10.9 mavericks GHC work around nuttiness

  • Download Gist
xcode5-haskell-directions.md
Markdown

TLDR version, if you have homebrew

xcode-select --install ; brew tap homebrew/versions ;   brew tap homebrew/dupes \
brew install apple-gcc42 ; brew link apple-gcc42 

NB: the xcode-select --install is how you (re)install the mavericks xcode 5 CLI tools, you HAVE to do that. Either way, you should make sure you have CLI tools installed.

NB: apple-gcc42 is quite old, but doesn't require a build from source (so it can work right away). Those who have a bit more patience and want a more modern GCC can use brew install gcc48 or the like (though the build may take a while)

then edit the settings file as follows:

  • type "ghc-pkg list"

  • the first line of the output will be a path like /Library/Frameworks/GHC.framework/Versions/7.6.3-x86_64/usr/lib/ghc-7.6.3/package.conf.d

  • go one directory up to /Library/Frameworks/GHC.framework/Versions/7.6.3-x86_64/usr/lib/ghc-7.6.3/

  • open the settings file.

  • there'll be a line indicating the path to the c compiler. It'll probably say /bin/gcc

  • change that line to /usr/local/bin/gcc-4.8 (or whichever gcc version you brew installed, such as /usr/local/bin/gcc-4.2)

  • you may also want to make sure that the gcc in your PATH points to this gcc. Many tools have calling gcc hard coded in.

  • if you point gcc to your gcc, be sure to also point cc to that gcc, and g++ to the g++ associated with that gcc. (otherwise when you're building a project that uses a mix of c and c++, you'll have really really weird build errors)

one Alternative approach that works with xcode 5 and doesnt need HomeBrew (by @lukexi and Manuel) here http://justtesting.org/post/64947952690/the-glasgow-haskell-compiler-ghc-on-os-x-10-9

another alternative see http://www.haskell.org/pipermail/haskell-cafe/2013-October/111174.html and https://gist.github.com/mzero/7245290 for tools that should work on a stock mac using haskell platform (work courtesy of Mark Lentczner)

NB: both these approaches use Clang, which hits some exotic corner cases in CPP still, along with some build system quirks.

more explanations

to recap -- the fastest way to have a working GHC / haskell platform install is the following. Much faster than the brew install approach, and uses the builds maintained by the official haskell platform folks.

so the total newb supervised install would be like

1) make sure the person has up to date CLI tools installed

2) brew install apple-gcc42

(3,optional, just skip to step 4 if you already have GHC)

3) install GHC or haskell platform etc (either) and make sure you've appropriately fixed up your path. 64 bit build here http://www.haskell.org/platform/mac.html

4) do my horrible edit your settings file thing to point the compiler to gcc42

(originaly shared here on reddit

the fastest work around is to use brew to build your own copy of GCC

brew install apple-gcc42 is fastest, i've used brew install gcc48

then type "ghc-pkg list"

the first line will be a path like /Library/Frameworks/GHC.framework/Versions/7.6.3-x86_64/usr/lib/ghc-7.6.3/package.conf.d

go one directory up to /Library/Frameworks/GHC.framework/Versions/7.6.3-x86_64/usr/lib/ghc-7.6.3/

then open the settings file.

there'll be a line indicating the path to the c compiler. It'll probably say "/bin/gcc"

change that line to "/usr/local/bin/gcc-4.8" (or whichever gcc version you brew installed, such as "/usr/local/bin/gcc-4.2")

enjoy life, haskell and mavericks/xcode 5.

NB: this is the power user fix. I recommend that most users instead do one of the approaches in http://www.haskell.org/pipermail/haskell-cafe/2013-September/110320.html

(directions for step 4 laid out below in the comments)

replicating the reddit remark for posterity

the fastest work around is to use brew to build your own copy of GCC

brew install apple-gcc42 is fastest, i've used brew install gcc48

then type "ghc-pkg list".

the first line will be a path like /Library/Frameworks/GHC.framework/Versions/7.6.3-x86_64/usr/lib/ghc-7.6.3/package.conf.d

go one directory up to
/Library/Frameworks/GHC.framework/Versions/7.6.3-x86_64/usr/lib/ghc-7.6.3/

then open the settings file.

there'll be a line indicating the path to the c compiler. It'll probably say "/bin/gcc"

change that line to "/usr/local/bin/gcc-4.8" (or whichever gcc version you brew installed)

enjoy life, haskell and mavericks.

NB: this is the power user fix. I recommend that most users instead do one of the approaches in http://www.haskell.org/pipermail/haskell-cafe/2013-September/110320.html

When compiling ghc 7.4.2 (and probably also 7.6), either compile with

make USE_DTRACE=NO

or else cherry-pick https://github.com/ghc/ghc/commit/8878541d02ad15fbdbd04608cbc6ea3fde5d5beb. Thanks Austin for helping with this.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.