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 Building/QuickStart 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/

# configure build
cp mk/build.mk.sample mk/build.mk

## edit mk/build.mk to remove the comment marker # on the line "BuildFlavour = devel2"

./boot
./configure
# NOTE: On Windows you need to download some binary distributables before being able to build
# This only has to be done once and can be done by adding a flag to the call to configure:
./configure --enable-tarballs-autodownload

# build GHC
make -j8 # parallelize to at most 8 parallel jobs; adapt to actual number of cpu cores

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 ./inplace/bin/ghc-stage2. (GHCi is launched with ./inplace/bin/ghc-stage2 --interactive). Try it out.

Fast rebuilding

There are 4 things to remember:

  1. Select BuildFlavour = devel2 in your mk/build.mk file (copy mk/build.mk.sample to mk/build.mk first), to make GHC build more quickly.
  1. Don't run make directly in the ghc root directory (unless you just pulled in changes from others). Instead, first change to the directory (compiler, utils, ghc or libraries) where you're making your changes. See Building a single sub-component.

  1. Set stage=2 in your mk/build.mk file, to freeze the stage 1 compiler. This makes sure that only the stage-2 compiler will be rebuilt after this.
  1. Use make fast to skip dependency building (except after pulling in changes from others).

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 fast in the ghc directory), and recompile your file again with ./inplace/bin/ghc-stage2. If you see the changed message, you're good to go.

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:

#4239
-ddump-minimal-imports vs. type operators
#11068
Make Generic/Generic1 methods inlinable
#11777
RTS source code issues
#11789
Flag suggestion does not always work
#12056
Too aggressive `-w` option
#12126
Bad error messages for SPECIALIZE pragmas
#12379
WARN pragma gives warning `warning: [-Wdeprecations]'
#12488
Explicit namespaces doesn't enforce namespaces
#12502
Reject wrong find utility

Feature requests:

#393
functions without implementations
#4806
Make error message more user friendly when module is not found because package is unusable
#7169
Warning for incomplete record field label used as function
#7401
Can't derive instance for Eq when datatype has no constructor, while it is trivial do do so.
#8501
Improve error message when using rec/mdo keyword without RecursiveDo extention.
#10789
Notify user when a kind mismatch holds up a type family reduction
#11799
Legend for hpc markup colors
#12497
Make runtime linker be able to find POSIX functions under their deprecated name.

Tasks:

#4960
Better inlining test in CoreUnfold
#11031
Record Pattern Synonym Cleanup
#11392
Decide and document how semicolons are supposed to work in GHCi
#11791
Remove the `isInlinePragma prag` test

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 8 weeks ago Last modified on Jul 4, 2016 3:53:54 PM