Tuesday, September 1, 2009

Running Haskell GHC on Snow Leopard

***UPDATE 2009/03/23***

There's a new version of the Haskell platform that works with Snow Leopard. If you install that then you shouldn't need to use the tip explained here. Please comment if it works for you

http://hackage.haskell.org/platform/mac.html

***UPDATE 2009/03/23***

After so much time spent trying to get a working GHC in my Mac with Snow Leopard I could arrive to the solution. Here it is, pretty simple:

1 - Download Haskell Platform for Mac: http://hackage.haskell.org/platform/
2 - Install GHC and the Haskell Platform that are inside the .dmg.
3 - Patch your ghc compiler to produce 32 bits code adding the following options:
-optc-m32 -opta-m32 -optl-m32
The ghc script that you have to patch is located here: /usr/bin/ghc
Open it with your favorite text editor and add those options. This at least will let you install new packages and compile your code with no problems until the Haskell team release a new version of GHC for mac.
Most of the tricks for this I got them from here: http://www.nabble.com/Snow-Leopard-Breaks-GHC-td25198347.html

15 comments:

thsutton said...

Does `cabal update` work with this approach? I patched the `/usr/bin/ghc` that was installed by the GHC pkg, and it will compile working programs, but the zlib package it built, and thus the cabal-install package as well, seem broken.

There's a post in that same haskell-cafe@ thread about reporting the same problem. If it *does* work, I'll have to install the platform package quick smart.

Alvaro Videla said...

It works and also I installed the Yi text editor from there, no problems.

eridius said...

`cabal install binary` just worked fine for me after making this change.

Syzygies2 said...

To be precise, I added these options in front of "-dynload", in the /usr/bin/ghc script. One doesn't need to also patch runhaskell, which interprets.

I started with GHC-6.10.4-i386.pkg, then cabal and the cabal packages I need.

With this patch, cabal itself, and various packages work fine. However, I too hit the zlib problem specifically with "cabal install". However, this is a shortcut. By abbreviating "runhaskell setup configure", "runhaskell Setup build", "sudo runhaskell Setup install" to in .bashrc as rsc, rsb, rsi, I was able to manually install a couple dozen packages I actually use.

Fafnr said...

How did you install 6.10.4? Once I start the installer, "Install" is greyed out in step 4?

Max said...

I'm having the same issue as Fafnr: the installer itself seems to be broken!

Max said...

D'oh! Just like the installer warns, Xcode must be installed. It's on the OS X 10.6 install dvd, or you can download it from Apple.

Fafnr said...

*Red face*

Fafnr said...

*Red in the face*

Chris said...

Thanks for the help!

Qerub said...

Thank you!

Ernie said...

Thanks, very helpful. BTW I don't think this qualifies as an 'obvious hint'!

Stephen Lavelle said...

thanks for this : )

reen said...
This comment has been removed by the author.
reen said...

Nice. Thanks for the help. My Blog : news chao!