wiki:Newcomers

Resources for newcomers to GHC

This page is intended to serve as 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. While the building guide, working conventions, commentary and debugging pages (always linked from the left sidebar) have great information that can come in handy while you're working on your first, or first several patches, this page is intended to have the details you will need to get rolling.

First steps

Prepare your machine, clone the git repo, and build GHC. For the short, short version, which may or may not work for your machine, you can try this:

# needed only once, URL rewrite rule is persisted in ${HOME}/.gitconfig
git config --global url."git://github.com/ghc/packages-".insteadOf git://github.com/ghc/packages/ 

# clone GHC's main Git repository (creates './ghc' folder in CWD)
git clone --recursive git://github.com/ghc/ghc
cd ghc/
git clone git://github.com/ghc/ghc-tarballs.git  # Windows only

# configure build
cd mk
cp build.mk.sample build.mk
## edit build.mk to remove the comment marker # on the line "BuildFlavour = devel2"
cd ..
./boot
./configure

# build GHC
make -j8 # parallelize to at most 8 parallel jobs; adapt to actual number of cpu cores
## edit build.mk to remove the comment marker # on the line stage=2

If your machine has all the prerequisites, this might just work. Expect it all to take roughly an hour.

  • 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 ghc/inplace/bin/ghc-stage2. (GHCi is launched with ghc/inplace/bin/ghc-stage2 --interactive). Try it out.
  • To speed up the development cycle, the final edit of build.mk makes sure that only the stage-2 compiler will be rebuild after this (see here about stages).
  • A good first sanity check is to twiddle some error message in the code, just to see that changed error message pop up when you compile a file. Write some Haskell code with an error in it, and look at the error message. Search through the code for that error message. Change the message, rebuild ghc (run make again), and recompile your file again with ghc/inplace/bin/ghc-stage2. If you see the changed message, you're good to go.
  • To further speed up the development cycle, after you make some changes, don't run make directly in the ghc root directory (where you ran make the first time). Instead run it in the directory where you are making your changes, usually compiler, ghc, rts or one of the libraries or utils subdirectories. This greatly speeds up a rebuild.

Finding a ticket

Below is a list of 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.

Bugs:

#7305
T5975a is broken on Windows
#7670
StablePtrs should be organized by generation for efficient minor collections
#8524
GHC is inconsistent with the Haskell Report on which Unicode characters are allowed in string and character literals
#8981
ghc-pkg complains about missing haddock interface files
#8990
Performance tests behave differently depending on presence of .hi file (even with -fforce-recomp)
#9579
Runtime suggests using +RTS when that's not possible
#10578
ghci line numbers are off by one

Feature requests:

#393
functions without implementations
#1262
RecursiveDo in Template Haskell
#1574
Broken link testing
#2742
The -> in ViewPatterns binds more weakly than infix data constructors.
#10089
feature: warn about unused data definitions (with typeclass instances)
#10153
GHC mode for converting files to explicit layout
#10162
Add unicode syntax for banana brackets
#10522
Add UInfixT, like UInfixE or UInfixP but for types

Tasks: No results

Practical advice

Less practical advice

  • Don't get scared. GHC is a big codebase, but it makes sense when you stare at it long enough!
  • Be forewarned that many pages on the GHC wiki are somewhat out-of-date. Always check the last modification date. Email if you're not sure.

Need help?

You can email the ghc-devs list, or ask on irc in #ghc.

Happy hacking!

Last modified 4 weeks ago Last modified on Jun 6, 2015 8:13:46 PM