Setup

You will need GHC 7.8 or newer as well as LLVM 4.0. For information on installing LLVM 4.0 (not 3.9 or earlier) on your platform of choice, take a look at the instructions posted by the llvm-hs maintainers.

With Haskell and LLVM in place, you can use either Stack or Cabal to install the necessary Haskell bindings and compile the source code from each chapter.

Building with Stack (Recommended)

  1. $ stack build

You can then run the source code from each chapter (starting with chapter 2) as follows:

  1. $ stack exec chapter2

Building with Cabal

Ensure that llvm-config is on your $PATH, then run:

  1. $ cabal sandbox init
  2. $ cabal configure
  3. $ cabal install --only-dependencies

Then to run the source code from each chapter (e.g. chapter 2):

  1. $ cabal run chapter2

Building with make

The source code for the example compiler of each chapter is included in the /src folder. With the dependencies installed globally, these can be built using the Makefile at the root level:

  1. $ make chapter2
  2. $ make chapter6

A smaller version of the code without the parser frontend can be found in the llvm-tutorial-standalone repository. The LLVM code generation technique is identical.