Monday, August 11, 2008

Compiling GHC

<ChilliX> at least, I managed to build the head on two successive days now! That's not bad.

Recently I had hard time building GHC, The Glorious Glasgow Haskell Compilation System. So I decided to record my experience which I got from Google, IRC and other sources. This refers to darcs (development) version of GHC. Some bits of this can soon change another way, while other can stay.

  1. This page contains instruction on building GHC. It may seem that following the first 4 links is sufficient, but it's really important to read Using the build system and to set up separate build tree.
  2. While GHCi in stable releases use readline, HEAD migrated to editline due to license issues (editline is BSD-licensed, while GNU readline is GPL'ed). So, you need to get recent version of libedit library. Note that one in Debian is very old and editline Haskell bindings won't build with it. For ArchLinux, I wrote PKGBUILD for editline, get it here.
  3. If you got compile error, the first thing to do is to clean and build from scratch. That's why I advise to use build trees as pointed above -- make clean may miss some autogenerated files.
  4. Another source of build errors are warnings together with -Werror pragma. If you got one, just edit the file and remove -Werror from top line.
  5. "Real" compile errors are much less probable, but also possible. Then try asking at #ghc on FreeNode or at mailing list.
  6. If your build succeeds, don't upgrade (i.e. ./darcs-all pull -a) without need. It may not build next time. If you need to upgrade, start with fresh build tree.
  7. If build (i.e. make) succeeds, don't run make install. There are two problems with that.
    First, it does not correctly set permissions (I had umask 077, and after sudo make install binaries were not executable by me.
    Another thing is that /usr/local/bin/ghci (which is shell script) has incorrect path to actual binaries in it.
    Both problems are more or less easy fixable, but Igloo said there are more issues with make install. So, the best solution is to use GHC in-place. See instructions on "Using the Build System" page.

No comments: