Monday, November 05, 2007

Compiling GHC on Scientific Linux V5

For a long time I wanted to go 'strictly functional' and what better way then to start with the beast, ghc. So about a couple of months back, I downloaded version 6.6.1 [ http://www.haskell.org/ghc/dist/6.6.1/rpm/rhel5/i386/ghc661-6.6.1-2.el5.i386.rpm ] and started reading YAHT [ http://darcs.haskell.org/yaht/yaht.pdf ]. Then the 'laziness' took over and my 'idea of being strictly functional' took a back-seat. The news of release of ghc Version 6.8.1 (3 November 2007) reignited the desire. This time I thought of compiling the ghc from source [ Main - http://www.haskell.org/ghc/dist/6.8.1/ghc-6.8.1-src.tar.bz2 , Extra Libs - http://www.haskell.org/ghc/dist/6.8.1/ghc-6.8.1-src-extralibs.tar.bz2 ]. Make sure you have 4-5 hours and 1-1.5 GB of disc space! Become 'root' and extract the above two files: tar xvjf ghc-6.8.1-src.tar.bz2 tar xvjf ghc-6.8.1-src-extralibs.tar.bz2 Both of them will extract in the directory ./ghc-6.8.1. For compiling there are some dependencies to be taken care of: 1. ghc [I already had v 6.6.1, http://www.haskell.org/ghc/dist/6.6.1/rpm/rhel5/i386/ghc661-6.6.1-2.el5.i386.rpm ] , it is interesting as the compilers compiles its next version [ http://en.wikipedia.org/wiki/Bootstrapping_(compilers) ]: rpm -ivhf ghc661-6.6.1-2.el5.i386.rpm 2. cabal, Common Architecture for Building Applications and Libraries, which can be downloaded from http://www.haskell.org/cabal/release/rc/cabal-1.2.2.0.tar.gz and installation instructions need to be followed [ http://haskell.org/haskellwiki/Cabal/How_to_install_a_Cabal_package ]: tar xzf cabal-1.2.2.0.tar.gz cd cabal-1.2.2 runhaskell Setup.hs configure runhaskell Setup.hs build runhaskell Setup.hs install 3. readline-devel, readline library which in turn has terminfo as dependence, so better to use yum for installation: yum install readline-devel 4. alex, A lexical analyser generator for Haskell, whose rpm can be downloaded from http://www.haskell.org/alex/dist/2.1.0/RH9/alex-2.1.0-1.i386.rpm and installed easily: rpm -ivhf alex-2.1.0-1.i386.rpm 5. happy, the yacc of haskell [I read on http://tritium.livejournal.com/ to compile happy you need old version of happy]. But for me simply getting the source http://www.haskell.org/happy/dist/1.17/happy-1.17.tar.gz and installation worked fine: tar xvzf happy-1.17-html.tar.gz cd happy-1.17 runhaskell Setup.hs configure runhaskell Setup.hs build runhaskell Setup.hs install We are all set for the ghc compilation: cd ghc-6.8.1 ./configure make make install Clean up ~300MB from the older ghc (v 6.6.1) installation, I went the brute force way: make a "list" using 'find /usr -name ghc-6.6.1' and clean 'rm -rf "list"' Now I have to dig deeper into the release note (http://www.haskell.org/ghc/docs/6.8.1/html/users_guide/release-6-8-1.html ), one thing which has really got me interested is the introduction of debugger to GHCi. --------------------------"The Answer Lies in the Genome"-------------------------- http://fuzzylife.org
clipped from www.haskell.org
HaskellWiki

Haskell is a general purpose, purely functional programming language featuring static typing, higher order functions, polymorphism, type classes, and monadic effects. Haskell compilers are freely available for almost any computer.

blog it