Getting the GHC Sources (GHC 7.8 or earlier)
These instructions refer to GHC 7.8 or earlier. For more recent GHC versions, see Building/GettingTheSources
Getting a branch
It is best to check out the desired branch directly in a fresh clone, as follows:
$ git clone -b ghc-7.8 git://git.haskell.org/ghc.git ghc-7.8 $ cd ghc-7.8 $ ./sync-all get -b ghc-7.8
Getting a tag
Each release is tagged in the git repository, making it possible to check out an old version of GHC by tag. To see all available tags, run
git tag in the GHC repository.
To check out a specific version of GHC, run
$ git clone http://git.haskell.org/ghc.git $ cd ghc $ git checkout <tag> $ ./sync-all get
For checking out a tag after you have already done
./sync-all [OPTIONS] get
$ shopt -s extglob $ rm -rf !(.git) $ git checkout -f <tag> $ ./sync-all get
Getting a GHC repository from GitHub
$ git clone git://github.com/ghc/ghc $ cd ghc $ ./sync-all get
If you want to clone your own fork instead, add an argument to
sync-all to tell it where it can find the other repositories it needs.
$ git clone <your preferred github.com GHC fork URL> ghc $ cd ghc $ ./sync-all -r git://github.com/ghc get
Making a local clone
You can make a local clone of a GHC tree with
$ git clone ~/ghc ~/ghc-branch
~/ghc is the repository you want to branch and
~/ghc-branch is where you want to put the branch. Then use
sync-all (see Building/SyncAll) to clone the rest of the repositories. Note that the
origin for the local clone will point back to the repository that it was cloned from - if you want
origin to point back to the main GHC repo then do this:
$ ./sync-all -r git://git.haskell.org remote set-url origin
Tracking the full repository state (pre-March 2014, e.g., the 7.8.* branches)
Since db19c665e/ghc, all used repositories are submodules, so this is only relevant to track older states, e.g., for GHC 7.8.*.
The full state of a GHC repository includes the current state of the repositories for all of the GHC boot libraries that are used to to build GHC (list of boot libraries). For GHC 7.8.* the repositories for these libraries are fetched and updated by the
sync-all script. To record the full repository state (including boot libraries), git submodules can be used starting from March 2014, but for 7.8.* they are not fully usable, so fingerprints are provided instead in annotated & gpg-signed release tags, such as http://git.haskell.org/ghc.git/tag/refs/tags/ghc-7.8.3-release.
That way you're able to restore via the fingerprint for a given release, as in:
$ ./utils/fingerprint/fingerprint.py restore -f <(git show ghc-7.8.3-release | grep -F '|')
Here is how such fingerprints are created. The
fingerprint.py script in
utils/fingerprint/ can create a "fingerprint" to uniquely identify a GHC repository state by recording the current commits of the GHC and boot library repositories. This fingerprint can be used later to restore the state of all repositories to the state captured by the fingerprint.
To create a new fingerprint, run the
create command in the top level ghc repo. The fingerprint can also be created from a Builder log that contains the appropriate output from the
sync-all command by passing the log file to the create command with the
$ ./utils/fingerprint/fingerprint.py create $ ./utils/fingerprint/fingerprint.py create -l builder.log
This command will create a new fingerprint, which is just pairs of repositories and commits.
To restore a fingerprint use the
restore command and pass either a fingerprint file with the
-f flag or a builder log file with the
$ ./utils/fingerprint/fingerprint.py restore -f 2011-05-23.fp $ ./utils/fingerprint/fingerprint.py restore -l builder.log
This command will read the fingerprint and perform a checkout of the appropriate commit for each repository found in the fingerprint. By default, the
restore command will create a new branch in the top level ghc repository and add an entry to git config that sets the new branch's remote to
origin. The config options are added so that future
sync-all commands will work as expected. Passing the
-n flag will cause the fingerprint script not to create a new branch. To "unrestore" a fingerprint, simply use
sync-all to checkout the
master branch in each repository
$ ./sync-all checkout master
To make the best use of fingerprinting, you need to collect fingerprints for the states you may wish to restore. To ease the automatic collection of fingerprints, the
fingerprint.py script allows a
-d DIR option that will output a fingerprint to the directory
DIR with the current time stamp as a file name. The
-g DIR option tells the script to run in the ghc repository pointed to by
DIR. These options can be useful for collecting fingerprints as a cron job or on a post-commit hook.
To restore the repository state as of a particular date, you can grab a fingerprint emitted by one of the nightly builds. The nightly build emails are sent to the ghc-builds mailing list, and have subjects like "[nightly] 06-Oct-2012 build of HEAD on x86_64-unknown-linux (cam-04-unx)". Copy and paste the fingerprint section, which looks something like this:
Respository hashes: .|4a138b708463a99a1087ce2d8a70239de3aa04e4 ghc-tarballs|18e0c37f8023abf469af991e2fc2d3b024319c27 libraries/Cabal|31c3f404dceb221d7281467a66bf68cc166fc2d9 libraries/Win32|21335a30161c099da79ae9619c9782e5e32e4644 libraries/array|e4b800af700cd7a5d42286086f17713ec98698a0 libraries/base|219ea0e539aca217fe1819baf02d4cdd1d670f51 ... and so on
Put it in a file, and run
./utils/fingerprint.py restore -f <file> to restore your repository tree to that state.