Setting up a Linux system for building GHC

If you're on a recent Linux system, then you should be able to get a working build environment by installing the following packages using your system's package manager.


If you are familiar with docker, this is a 1 step install for a development image (ghc build requirements plus a few development related tools). First cd into your ghc directory that you should check out according to Building/GettingTheSources, then

   sudo docker run --rm -i -t -v `pwd`:/home/ghc gregweber/ghc-haskell-dev /bin/bash

That's it! This mounts your ghc source code into the docker container. This way you can still hack on ghc with Emacs, etc, but you are just building from the docker container. Note that arc (the GHC patch submission tool) is installed in the image (although you can also use it from your docker host) along with vim-tiny for editing commit messages.

Send pull requests to if something is out-of-date.


Install the required tools using the following command for Fedora 22 and later (for earlier versions of Fedora, use yum instead of dnf):

   sudo dnf install glibc-devel ncurses-devel gmp-devel autoconf automake libtool gcc make perl python ghc happy alex git

For building the documentation: (User's Guide and Cabal guide): (optional)

   # GHC > 7.10 (untested)
   sudo dnf install python-sphinx
   # GHC <= 7.10
   sudo dnf install docbook-utils docbook-utils-pdf docbook-style-xsl

other packages that are useful for development: (optional)

   sudo dnf install strace patch

Now the system should be ready to build GHC.

For a quickstart, follow the commands listed under:

Debian, Ubuntu, and other Debian-based systems

You can make sure you have all dependencies by

   sudo apt-get build-dep ghc

But this might install some packages you do not use in your system (e.g. Sphinx). Alternatively install the following:

   sudo apt-get install git autoconf automake libtool make gcc g++ \
     libgmp-dev ncurses-dev libtinfo-dev python3 xz-utils

(ncurses-dev is needed by the terminfo package, and g++ is needed by a couple of tests, ghcilink003 and ghcilink006).

Optional: install LLVM from <> (only necessary to make the -fllvm flag work). Commentary/Compiler/Backends/LLVM/Installing will tell you which version to install.

Due to the nature of Debian, you may have difficulty building GHC >7.6 due to version incompatibilities with the Happy and Alex packages. To alleviate this issue simply install both packages using the haskell-platform provided cabal.

   cabal install alex happy

If you install alex and happy using cabal as shown above, you will need to add the cabal installation directory to PATH before running the configure script.

   export PATH=$HOME/.cabal/bin:$PATH

For building the documentation (User's Guide):

   # GHC > 7.10:
   sudo apt-get install python-sphinx texlive-xetex texlive-fonts-recommended fonts-lmodern texlive-latex-recommended texlive-latex-extra
   # GHC <= 7.10:
   sudo apt-get install dblatex docbook-xsl docbook-utils libxml2-utils texlive-font-utils

other packages that are useful for development:

   sudo apt-get install linux-tools-generic xutils-dev

The package linux-tools includes perf, see Debugging/LowLevelProfiling/Perf. The package xutils-dev provides the lndir program, need for running make sdist and useful for maintaining a separate build tree, see Building/Using.

For validating patches :


Install the required tools:

   sudo pacman -S ghc ghc-static perl gcc make happy alex cabal-install autoconf automake python python-sphinx libedit


First, you need to clone Nixpkgs, so you could use recent Nix recipes:

   git clone  

Then, you can build the environment needed for compiling HEAD (assuming that the nixpkgs directory is in /home/user):

   cd ~
   nix-shell '<nixpkgs>' -A haskell.compiler.ghcHEAD

Finally, clone, configure, and build GHC (see Newcomers for details), but replace the usual configure && make with the Nix build phases:

   git clone --recursive
   cd ghc/
   # patchPhase (sometimes this is necessary if there are patches which need to be applied as of Dec 2016 with the unstable channel it is unnecessary)

   #edit mk/ as normal
   # This command needs to be used so that the right paths to libraries are passed to ./configure
   # edit to remove the comment marker # on the line stage=2

If you have come this way it is assumed you know what you are doing! The ghcHEAD derivation does not include the dependencies needed for the test suite. I (mpickering, Dec 2016) don't know exactly what these dependencies are but you should add them to your environment by defining a suitable shell.nix.

Enable parallel builds in the nix build environment:

   export NIX_BUILD_CORES=4


If you need more control over your GHC build environment there is a shell.nix file that defines (hopefully) all dependencies: You can use it as is or a base for your own.

Last modified 2 weeks ago Last modified on Oct 5, 2017 2:48:00 AM