Witty subtitle here

How to install GHC 7.4.1 and friends in Ubuntu from source

2012-02-04 - Reading time: 4 minutes

If you'd like to install the newest version of the Glorious Haskell Compiler, you can either wait for the Haskell Platform to come out later in the Spring or for the adventurous you can pull all the pieces together yourself.

I first attempted installing GHC 7.4.1 from the prebuilt x86_64 binaries provided from haskell.org/ghc but they are linked against an old version of libgmp, and rather than try any ugly symlink hacks*, I decided to try compiling from source, which I've wanted to do for a while anyways. Luckily the process is quite simple due to the miraculous work put into the build system.

I like to install everything locally in my $HOME/src/ghc so that it is easy to remove everything later on down the line, but pick your own poison. Also, it is necessary to use cabal-install from darcs HEAD because the current stable version on Hackage is not updated for GHC 7.4.1. You will need > 3GB free space for this process and a healthy amount of RAM.

And you're off to the races!

Update 2: As hvr_ pointed out in the reddit comments, it is possible to get around the libgmp easily with a
sudo aptitude install libgmp3c2
to avoid recompiling GHC yourself. So you can go that route as well but you'll still need the latest cabal-install.

Update 3: To avoid much pain later on when trying to build profiling libraries with cabal-install, I have added the step of exporting the EXTRA_CONFIGURE_OPTS variable on line 19 before running bootstrap to generate those initial profiling libraries as well.
Are you not missing ./boot ?

I believe ./boot is only required after pulling GHC source from Git. It has already been done for the source tarball on the GHC download page.


True. I did not realise that.

This comment has been removed by the author.