Getting the GHC sources

There are two ways to get sources to GHC: download a source distribution, or clone the git repositories.

Source distributions

A source distribution is a file like ghc-7.8.3-src.tar.xz, which contains a complete snapshot of the source tree for a particular version of GHC. Source distributions for all versions of GHC are available from the download page.

Source distributions are easier to build, because we also include the output from running certain external tools like Happy, so you don't need to install these tools.


GHC uses ​Git for revision control (version 1.7.8 or newer recommended).

Repositories gives a list of all the git repositories used by GHC. A source tree consists of more than one repository: at the top level there is the main GHC repository, and certain subdirectories contain separate git repositories.

Cloning HEAD

A complete GHC source tree can be obtained (located in ghc) by running the following command:

git clone --recursive

PLEASE READ THIS: There are some specific Git workflows which will make GHC development a lot more pleasant; read how to use git with GHC and how to contribute a patch to GHC for suggestions about this.


  • is reachable via IPv6 as well as IPv4.
  • If you're behind a firewall blocking port 9418 (or git clone git://... fails for some other reason), try replacing git:// by http:// or https:// in the instructions above.
  • The above directions are valid for cloning GHC 7.9 or newer. For cloning GHC 7.8 or earlier, see the legacy instructions.

Using a Fork of GHC

You can create a fork of ghc by logging in and clicking the fork button at Do NOT clone your fork directly. This will cause issues with relative submodule paths. Instead:

  • Clone the official GHC repo as described above.
  • Add your fork as a new remote with the following command. "myFork" can be any name you choose. The exact url is given on your fork's gitlab page.
    git remote add myFork

You can then e.g. fetch and checkout a branch from your fork:

git fetch myFork
git checkout myFork/myBranch

If you really must clone your fork directly, you can use the python script .gitlab-ci/ which tweaks the git submodule paths to point to

Getting a branch

The above instructions will get the HEAD, the main trunk of GHC development. There is also a branch for each stable release line, as well as branches for development of major new features. The active branches are listed on ActiveBranches.

To get a branch, you need to get from a repo that contains the branch; in particular, local clones of the central repo will normally not include the branches that are in the central repo.

You can clone a specific branch via:

git clone -b <branchname> --recursive ghc-<branchname>

and switch between branches on an existing clone by

git checkout <other-branchname>
git submodule update --init

Note: The instructions above apply to branches that contain the commit [db19c665ec5055c2193b2174519866045aeff09a/ghc] which converted all sub-repos into submodules. To clone a branch prior to that commit, follow the legacy instructions instead. It is best not to attempt to cross that commit with git checkout; instead make a fresh clone of the desired branch directly.

Getting a tag

Starting with GHC 7.10.1, you can simply clone a specific tag via:

git clone -b ghc-7.10.1-release --recursive ghc-7.10.1

For 7.8 or earlier, follow the legacy instructions.

Cloning from GitHub

The official mirror for GHC on GitHub is located at

First configure the following Git url rewrites to account for the different naming scheme on GitHub (due to GitHub not supporting / in repository names) before cloning (those rules are persisted in ${HOME}/.gitconfig so you need to perform it only once):

git config --global url."git://".insteadOf     git:// 
git config --global url."".insteadOf 
git config --global url."".insteadOf 
git config --global url."ssh://".insteadOf ssh:// 
git config --global url."".insteadOf 

and then simply proceed by

git clone --recursive git://
Last modified 11 months ago Last modified on Jan 8, 2019 12:01:49 AM