Front Page
The Luxurious LHC Haskell Optimization System
LHC is a backend for the Glorious Glasgow Haskell Compiler, adding low-level, whole-program optimization to the system. It is based on Urban Boquist’s GRIN language, and using GHC as a frontend, we get most of its great extensions and features.
Essentially, LHC uses the GHC API to convert programs to external core format - it then parses the external core, and links all the necessary modules together into a whole program for optimization. We currently have our own base library (heavily and graciously taken from GHC.) This base library is similar to GHC’s (module-names and all,) and it is compiled by LHC into external core and the package is stored for when it is needed. This also means that if you can output GHC’s external core format, then you can use LHC as a backend.
Currently, LHC is under a lot of development. Installation is not so simple right now and hard to get right; but many programs do already work. See Current Status for more up-to-date information.
If you want to join the effort,
We also have a mailing list and a blog.
LHC was previously based on John Meacham’s JHC project. That code has since been retired.
Installing
The current version of LHC available is lhc 0.8. It can be installed off Hackage.
Currently, if you have ‘cabal install’ and ghc 6.10.2 at least, the whole installation procedure for lhc + libraries is like so:
$ darcs get http://darcs.haskell.org/cabal
$ cd cabal
$ cabal install
$ cd ../
$ cabal update
$ cabal unpack lhc
$ cd lhc-0.8
$ cabal install -fwith-libs # pass -flhc-regress for regression tool
This will install Cabal 1.7 and get you lhc with its base libraries off hackage. The build will very likely fail while compiling Foreign.Ptr in the base package. This is a known GHC bug. Simply rerun the ‘cabal install’ command and the build will proceed.
Afterwords, you should have a lhc-pkg executable, and running lhc-pkg list should report:
$ lhc-pkg list
/Users/austinseipp/.lhc/i386-darwin-0.7/package.conf:
base-4.1.0.0, ghc-prim-0.1.0.0, integer-0.1
$
If you installed the lhc-regress tool, then please run it while you are in the top of lhc’s source directory, and report any failures if you get them! (see ‘development & contact’ below)
Test it
After you install lhc, you can use it just like GHC as it takes all the same flags. Then evaluate the resulting .hcr file with lhc. So, to compile a file and evaluate it with lhc,
$ cat > test.hs
main = putStrLn "hi"
$ lhc --make -O2 -c test.hs
$ lhc eval test.hcr
hi
$
You can also compile the .hcr file:
$ lhc compile test.hcr
$ ./test.lhc
hi
$
Development & Contact
If you want to hack on LHC, then get yourself a copy of the darcs repository:
$ darcs get --lazy http://code.haskell.org/lhc
Send any patches to our mailing list and we’ll look them over. Please run lhc-regress beforehand!
Aside from the mailing list, we also have a blog.
If you’d like to help out, please contact us (Lemmih & thoughtpolice) on IRC: #lhc-compiler irc.freenode.org.
