|
|
# Getting the GHC sources
|
|
|
|
|
|
|
|
|
There are two ways to get sources to GHC: download a source distribution, or clone the [git](http://git-scm.com/) repositories.
|
|
|
There are two ways to get GHC sources:
|
|
|
1. downloading a [source distribution](#source-distributions)
|
|
|
2. cloning the [git repositories](#Git)
|
|
|
|
|
|
## 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. All the source distributions we provide are available from the [download page](http://www.haskell.org/ghc/).
|
|
|
|
|
|
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](http://www.haskell.org/ghc/).
|
|
|
Pros: source distributions are easier to build, because we also include the output from running certain external tools like [Happy](http://haskell.org/happy), so you don't need to install these tools.
|
|
|
|
|
|
Cons: source distributions are stuck to a particular GHC version and shouldn't be used to contribute to GHC.
|
|
|
|
|
|
Source distributions are easier to build, because we also include the output from running certain external tools like [Happy](http://haskell.org/happy), so you don't need to install these tools.
|
|
|
|
|
|
## Git
|
|
|
|
|
|
GHC uses [Git](http://git-scm.com/) for revision control (version 1.7.8 or newer recommended). You must install it on your platform before executing any "git" commands.
|
|
|
|
|
|
GHC uses Git for revision control (version 1.7.8 or newer recommended).
|
|
|
|
|
|
[Repositories](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:
|
|
|
The main GHC repository is located on a Gitlab instance on haskell.org and a complete GHC source tree can be obtained (located in `ghc`) by running the following command:
|
|
|
|
|
|
```
|
|
|
git clone --recursive https://gitlab.haskell.org/ghc/ghc
|
|
|
cd ghc # ensure you are in the ghc source tree for the following commands
|
|
|
```
|
|
|
|
|
|
**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](working-conventions/git) and [how to contribute a patch to GHC](working-conventions/fixing-bugs) for suggestions about this.
|
|
|
|
|
|
|
|
|
Notes:
|
|
|
|
|
|
- `git.haskell.org` 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](building/getting-the-sources/legacy) instructions.
|
|
|
|
|
|
### Using a Fork of GHC
|
|
|
|
|
|
|
|
|
You can create a fork of ghc by logging in and clicking the fork button at [https://gitlab.haskell.org/ghc/ghc](https://gitlab.haskell.org/ghc/ghc). Do NOT clone your fork directly. This will cause issues with relative submodule paths. Instead:
|
|
|
|
|
|
- Clone the official GHC repo as described [above](building/getting-the-sources#cloning-head).
|
|
|
- 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 git@gitlab.haskell.org:JohnDoe/ghc.git
|
|
|
```
|
|
|
|
|
|
|
|
|
You can then e.g. fetch and checkout a branch from your fork:
|
|
|
Notice that we need the unusual "--recursive" flag because GHC uses the "submodule" feature of Git. Using the "--recursive" flag ensures that submodules are cloned too (e.g. into ``libraries/..``). If you forgot the flag, you can perform the same operation later on with the following command:
|
|
|
|
|
|
```
|
|
|
git fetch myFork
|
|
|
git checkout myFork/myBranch
|
|
|
git submodule update --init
|
|
|
```
|
|
|
|
|
|
|
|
|
If you really must clone your fork directly, you can use the python script .gitlab-ci/fix-submodules.py which tweaks the git submodule paths to point to gitlab.haskell.org/ghc/ghc.
|
|
|
|
|
|
### 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](active-branches).
|
|
|
|
|
|
|
|
|
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:
|
|
|
The above instructions will checkout the HEAD (or "master"), 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. You can list the available branches with:
|
|
|
|
|
|
```
|
|
|
git clone -b <branchname> --recursive https://gitlab.haskell.org/ghc/ghc ghc-<branchname>
|
|
|
git branch -a
|
|
|
```
|
|
|
|
|
|
|
|
|
and switch between branches on an existing clone by
|
|
|
and switch between branches with:
|
|
|
|
|
|
```
|
|
|
git checkout <other-branchname>
|
|
|
git submodule update --init
|
|
|
```
|
|
|
|
|
|
**Note:** The instructions above apply to branches that contain the commit [\[db19c665ec5055c2193b2174519866045aeff09a/ghc\]](/trac/ghc/changeset/db19c665ec5055c2193b2174519866045aeff09a/ghc) which converted all sub-repos into submodules. To clone a branch prior to that commit, follow the [legacy](building/getting-the-sources/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:
|
|
|
You can update your fork of the repository with:
|
|
|
|
|
|
```
|
|
|
git clone -b ghc-7.10.1-release --recursive https://gitlab.haskell.org/ghc/ghc ghc-7.10.1
|
|
|
git fetch origin
|
|
|
# then checkout, rebase or merge the branch you want (out of the scope of this page)
|
|
|
```
|
|
|
|
|
|
Note: see [this page](active-branches) for a more thorough description of some branches available in the main repository
|
|
|
|
|
|
For 7.8 or earlier, follow the [legacy](building/getting-the-sources/legacy) instructions.
|
|
|
Note: [this page](repositories) gives a list of all the repositories used by GHC as Git submodules.
|
|
|
|
|
|
### Cloning from GitHub
|
|
|
Note: for cloning GHC 7.8 or earlier, see the [legacy](building/getting-the-sources/legacy) instructions.
|
|
|
|
|
|
|
|
|
The official mirror for GHC on GitHub is located at [https://github.com/ghc/ghc](https://github.com/ghc/ghc).
|
|
|
### Cloning from GitHub
|
|
|
|
|
|
Cloning from GitHub is also supported. The official mirror for GHC on GitHub is located at [https://github.com/ghc/ghc](https://github.com/ghc/ghc).
|
|
|
|
|
|
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):
|
|
|
|
... | ... | @@ -114,7 +71,6 @@ git config --global url."ssh://git@github.com/ghc/packages-".insteadOf ssh://git |
|
|
git config --global url."git@github.com:ghc/packages-".insteadOf git@github.com:ghc/packages/
|
|
|
```
|
|
|
|
|
|
|
|
|
and then simply proceed by
|
|
|
|
|
|
```
|
... | ... | |