Essentially, LHC uses GHC 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 and ongoing change. Installation requires the darcs version of cabal/cabal-install, but is otherwise pretty easy to do. See Current Status for more up-to-date information on what does and does not work.
LHC was previously a derivative of John Meacham’s JHC project (circa late 2008/mid 2009.) That code has since been retired in its entirety.
The current version of LHC available is lhc 0.10. It can be installed off Hackage.
Currently, if you have ‘cabal install’ and ghc 6.12 at least, the whole installation procedure for lhc + libraries is like so:
$ darcs get http://darcs.haskell.org/cabal $ cd cabal && cabal install && cd ../ $ darcs get http://darcs.haskell.org/cabal-install $ cd cabal-install && cabal install && ../ $ cabal update $ cabal unpack lhc $ cd lhc-0.10 $ cabal install -fwith-libs # pass -flhc-regress for regression tool
This will install Cabal 1.9 and cabal-install 0.9, and get you lhc with its base libraries off hackage.
Afterwords, you should have a
lhc-pkg executable, and running
lhc-pkg list should report:
$ lhc-pkg list /home/david/.lhc/x86_64-linux-0.9/package.conf.d base-184.108.40.206 ghc-prim-0.2.0.0 integer-gmp-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)
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 -O2 -c test.hs $ lhc compile test.hcr $ ./test hi $
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
If you’d like to help out, please contact us (David/“Lemmih” & Austin/“thoughtpolice”) on IRC: #lhc-compiler irc.freenode.org.