Contributing to GHC
GHC is a BSD-licensed open-source project, and we welcome your help in making it better. This page and the side bar on the right have pointers to information you'll need.
-
Information for newcomers. This the first stop for those people who say, "I want to contribute to GHC, but I don't know quite where to begin." Begin here.
-
How to contribute a patch to GHC. For adding features, there are a few extra steps to follow.
Working conventions
-
Using Git: read how to use git with GHC. Information about our submodule setup is in WorkingConventions/Git/Submodules, and some useful Git tricks are in WorkingConventions/Git/Tricks.
-
GitLab conventions:
-
Releases and branches: Our conventions for making releases and how the branches are managed: Releases
-
Useful tools: Various tools which exist to make working on GHC more pleasant.
-
Coding style: When you are editing GHC's source code, please follow our coding guidelines:
-
Licensing: make sure you are familiar with GHC's Licensing. Unless you say otherwise, we will assume that if you submit a contribution to GHC, then you intend to supply it to us under the same license as the existing code. However, we do not ask for copyright attribution; you retain copyright on any contributions you make, so feel free to add your copyright to the top of any file in which you make non-trivial changes.
-
For boot libraries: GHC ships with a number of boot libraries maintained outside of GHC itself. Maintainers of such libraries should read WorkingConventions/BootLibraries for guidance on how to maintain their libraries.
Tips and Tricks
-
Loading GHC into GHCi can provide a more iterative development experience.
-
To have an easier time looking up tickets and searching trac, use the browser tips page to make your search and lookups for Trac tickets substantially easier.
-
If you use Emacs, see Emacs for some useful stuff to put in your
.emacs
file. -
If you have lots of Haskell installations, you may find Edsko's blog post Comprehensive Haskell Sandboxes useful.
-
ghc-artefact-nix is a Nix expression, which downloads a recent artifact from gitlab.haskell.org and enters a nix shell with the artefact available. This is a quick way to try some code out on a recent
HEAD
or a merge request.
Newcomers to GHC
This section is intended to have the details you will need to get rolling. In addition, note the building guide, working conventions, commentary and debugging pages have great information that will come in handy while you're working on your first patch(es) and are always available from the sidebar.
If you have any questions along the way don't hesitate to reach out to the community. There are people on the mailing lists and IRC who will gladly help you, though you may need to be patient. Don't forget all GHC developers are still learning; your question is never too silly to ask.
First steps
-
See Building/QuickStart to get started building GHC. Expect it all to take roughly between 30 minutes and a couple of hours, depending on your CPU speed, and the number of jobs you can run in parallel. Note that building older versions of GHC may require having an older version of GHC on your path.
-
While you are waiting for your build to finish, orient yourself to the general architecture of GHC. This article is written by two of the chief architects of GHC, Simon Marlow and Simon Peyton-Jones, is excellent and current (2012).
-
After a successful build, you should have your brand new compiler in
./inplace/bin/ghc-stage2
. (GHCi is launched with./inplace/bin/ghc-stage2 --interactive
). Try it out.
Finding a ticket
Now that you can build GHC, let's get hacking. But first, you'll need to identify a goal. GHC's Trac tickets are a great place to find starting points. You are encouraged to ask for a starting point on IRC or the ghc-devs
mailing list. There someone familiar with the process can help you find a ticket that matches your expertise and help you when you get stuck.
If you want to get a taste for possible starting tasks, the newcomer label collects tickets that appear to be "low-hanging fruit" -- things that might be reasonable for a newcomer to GHC hacking. Of course, we can't ever be sure of how hard a task is before doing it, so apologies if one of these is too hard.
Advice
-
Read up on the steps you are expected to take for contributing a patch to GHC.
-
Need help? You can email the ghc-devs list, or ask on IRC in
#ghc
. -
Don't get scared. GHC is a big codebase, but it makes sense when you stare at it long enough!
-
Don't hesitate to ask questions. We have all been beginners at some point and understand that diving in to GHC can be a challenge. Asking questions will help you make better use of your hacking time.
-
Be forewarned that many pages on the GHC Wiki are somewhat out-of-date. Always check the last modification date. Email
ghc-devs
if you're not sure. -
You may want to look at these "how it went for me" blog posts.
- Hacking on GHC (is not that hard) by Andrew Gibiansky
- Contributing to GHC by Annie Cherkaev
- Contributing to GHC via Phabricator by Moritz Angermann
- Andreas Herrmann's “GHC Hacking Newcomer Guide”](https://youtu.be/s9DkByHSdOg) talk is a wealth of information communicated clearly and succinctly. You can also just browse the slides.
-
There is a blog post series by Stephen Diehl that provides an overview of many important data structures and contains links to other sources of information: Dive into GHC
Happy hacking!