Building and developing GHC

The GHC Team


This Guide is primarily aimed at those who want to build and/or hack on GHC. It describes how to get started with building GHC on your machine, and how to tweak the settings to get the kind of build you want. It also describes the inner workings of the build system, so you can extend it, modify it, and use it to build your code.

The bulk of this guide applies to building on Unix systems; see Section 12, “Instructions for building under Windows” for Windows notes.

Table of Contents

1. Getting the sources
2. Things to check before you start
3. Installing pre-supposed utilities
3.1. Tools for building parallel GHC (GPH)
4. Building from source
5. Quick start for GHC developers
6. Working with the build system
6.1. History
6.2. Build trees
6.3. Getting the build you want
6.4. The story so far
6.5. Making things
6.6. Bootstrapping GHC
6.7. Standard Targets
6.8. Using GHC from the build tree
6.9. Fast Making
7. The Makefile architecture
7.1. Debugging
7.2. A small example
7.3. Boilerplate architecture
7.4. The mk/ file
7.5. Platform settings
7.6. Pattern rules and options
7.7. The main mk/ file
7.8. Recursion
7.9. Way management
7.10. When the canned rule isn't right
8. Building the documentation
8.1. Tools for building the Documentation
8.2. Installing the DocBook tools
8.2.1. Installing the DocBook tools on Linux
8.2.2. Installing DocBook on FreeBSD
8.2.3. Installing from binaries on Windows
8.3. Configuring the DocBook tools
8.4. Building the documentation
8.5. Installing the documentation
9. Porting GHC
9.1. Booting/porting from C (.hc) files
9.2. Porting GHC to a new platform
9.2.1. Cross-compiling to produce an unregisterised GHC
9.2.2. Porting the RTS
9.2.3. The mangler
9.2.4. The splitter
9.2.5. The native code generator
9.2.6. GHCi
10. Known pitfalls in building Glasgow Haskell
11. Platforms, scripts, and file names
11.1. Windows platforms: Cygwin, MSYS, and MinGW
11.1.1. MinGW
11.1.2. Cygwin and MSYS
11.1.3. Targeting MinGW
11.1.4. File names
11.1.5. Crippled ld
11.1.6. Host System vs Target System
11.2. Wrapper scripts
12. Instructions for building under Windows
12.1. Installing and configuring MSYS
12.2. Installing and configuring Cygwin
12.3. Configuring SSH
12.4. Other things you need to install
12.5. Building GHC
12.6. A Windows build log using Cygwin

1. Getting the sources

You can get your hands on the GHC sources in two ways:

Source distributions

You have a supported platform, but (a) you like the warm fuzzy feeling of compiling things yourself; (b) you want to build something ``extra”—e.g., a set of libraries with strictness-analysis turned off; or (c) you want to hack on GHC yourself.

A source distribution contains complete sources for GHC. Not only that, but the more awkward machine-independent steps are done for you. For example, if you don't have happy you'll find it convenient that the source distribution contains the result of running happy on the parser specifications. If you don't want to alter the parser then this saves you having to find and install happy. You will still need a working version of GHC (version 5.x or later) on your machine in order to compile (most of) the sources, however.

The darcs repository.

We make releases infrequently. If you want more up-to-the minute (but less tested) source code then you need to get access to our darcs repository.

Information on accessing the darcs repository is on the wiki:

The repository holds source code only. It holds no mechanically generated files at all. So if you check out a source tree from darcs you will need to install every utility so that you can build all the derived files from scratch.