Building and developing GHC

The GHC Team

Abstract

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 13, “Instructions for building under Windows” for Windows notes.


Table of Contents

1. Getting the sources
2. Things to check before you start
3. What machines GHC runs on
4. Installing pre-supposed utilities
4.1. Tools for building parallel GHC (GPH)
4.2. Other useful tools
5. Building from source
6. Quick start for GHC developers
7. Working with the build system
7.1. Your source tree
7.2. Build trees
7.3. Getting the build you want
7.4. The story so far
7.5. Making things
7.6. Bootstrapping GHC
7.7. Standard Targets
7.8. Using a project from the build tree
7.9. Fast Making
8. The Makefile architecture
8.1. Debugging
8.2. A small project
8.3. A larger project
8.4. Boilerplate architecture
8.5. The main mk/boilerplate.mk file
8.6. Platform settings
8.7. Pattern rules and options
8.8. The main mk/target.mk file
8.9. Recursion
8.10. Way management
8.11. When the canned rule isn't right
9. Building the documentation
9.1. Tools for building the Documentation
9.2. Installing the DocBook tools
9.2.1. Installing the DocBook tools on Linux
9.2.2. Installing DocBook on FreeBSD
9.2.3. Installing from binaries on Windows
9.3. Configuring the DocBook tools
9.4. Building the documentation
9.5. Installing the documentation
10. Porting GHC
10.1. Booting/porting from C (.hc) files
10.2. Porting GHC to a new architecture
10.2.1. Cross-compiling to produce an unregisterised GHC
10.2.2. Porting the RTS
10.2.3. The mangler
10.2.4. The splitter
10.2.5. The native code generator
10.2.6. GHCi
11. Known pitfalls in building Glasgow Haskell
12. Platforms, scripts, and file names
12.1. Windows platforms: Cygwin, MSYS, and MinGW
12.1.1. MinGW
12.1.2. Cygwin and MSYS
12.1.3. Targeting MinGW
12.1.4. File names
12.1.5. Crippled ld
12.1.6. Host System vs Target System
12.2. Wrapper scripts
13. Instructions for building under Windows
13.1. Installing and configuring MSYS
13.2. Installing and configuring Cygwin
13.3. Configuring SSH
13.4. Other things you need to install
13.5. Building GHC
13.6. A Windows build log using Cygwin
Index

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: http://hackage.haskell.org/trac/ghc/wiki/GhcDarcs.

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.