|Version 33 (modified by simonmar, 5 years ago) (diff)|
Installing the tools you need to build GHC
This page describes how to set up your system with all the tools you need to build, and develop, GHC. Jump to the relevant section for your operating system:
Preparing a Linux system
If you're on a recent Linux system, then you should be able to get a working build environment by installing the following packages using your system's package manager:
- python (only needed for the testsuite)
Note: currently you'll also need to install an older version of Haddock (0.9) manually, because the version of Haddock you'll get by default is 188.8.131.52 which doesn't work with GHC's build system yet.
To be able to build the documentation (User's Guide):
other packages that are useful for development:
- libcurl-devel and zlib-devel (for building darcs)
Preparing a Windows system
Installing the following will get you a working build environment with MSYS (ToDo: add Cygwin). For your convenience we've cached a working set of build tools that you can download.
- First install a recent stable version of GHC.
- Install MinGW: http://www.haskell.org/ghc/tools/Win32/MinGW-5.1.4.exe
- Install MSYS:
- http://www.haskell.org/ghc/tools/Win32/msysCORE-1.0.11-20080826.tar.gz (this is a tar file, which you have to unpack in c:/msys/1.0, or wherever you installed MSYS. Note that you can't do that using an MSYS shell, because you can't overwrite the files in use, so make a copy of c:/msys/1.0, unpack it there, and then rename the copy back to c:/msys/1.0).
- Install Python (version 2.5.x or 2.6.x, NOT 3.x).
The next three are just zip files, you can unpack them wherever you like, but you need to ensure that the programs can be found on your PATH. I usually put all these in c:/tools (NB. don't put them anywhere in c:/msys, that's special).
- Install Happy: http://www.haskell.org/ghc/tools/Win32/happy-1.17.zip
- Install Alex: http://www.haskell.org/ghc/tools/Win32/alex-2.2.zip
- Install Haddock: http://www.haskell.org/ghc/tools/Win32/haddock-0.8-Win32.zip
Now set your PATH. We recommend doing this by creating a file .profile in your home directory (by default c:/msys/1.0/home/<username>). The contents of your .profile should be something like this:
Modify the above according to where you installed things, and change the GHC version appropriately.
See also Building/Windows.
Preparing a MacOS X system
See Building/MacOSX. ToDo: move the relevant parts of the docs here.
Preparing a Solaris system
See Building/Solaris. ToDo: move the relevant parts of the docs here.
Here are the gory details about which programs and tools you need in order to build GHC. In most cases the configure script will tell you if you are missing something.
GHC is required to build GHC, because GHC itself is
written in Haskell, and uses GHC extensions. It is possible
to build GHC using just a C compiler, and indeed some
distributions of GHC do just that, but it isn't the best
supported method, and you may encounter difficulties. Full
instructions are in Porting GHC.
GHC can be built using either an earlier released version of GHC (currently 6.6 and later are supported), or bootstrapped using a GHC built from exactly the same sources. Note that this means you cannot in general build GHC using an arbitrary development snapshot, or a build from say last week. It might work, it might not - we don't guarantee anything. To be on the safe side, start your build using the most recently released stable version of GHC.
In general, we support building with the previous 2 major releases, so:
- To build 6.8.* you need GHC >= 6.4
- To build 6.10.* you need GHC >= 6.6
- Perl version 5 at least is required. GHC has been known to tickle bugs in Perl, so if you find that Perl crashes when running GHC try updating (or downgrading) your Perl installation. Versions of Perl before 5.6 have been known to have various bugs tickled by GHC, so the configure script will look for version 5.6 or later. Perl should be put somewhere so that it can be invoked by the #! script-invoking mechanism.
- GNU C (gcc)
Most GCC versions should work with the most recent GHC
sources. Expect trouble if you use a recent GCC with
an older GHC, though (trouble in the form of mis-compiled code,
link errors, and errors from the ghc-asm
If your GCC dies with "internal error"" on some GHC source file, please let us know, so we can report it and get things improved. (Exception: on x86 boxes, you may need to fiddle with GHC's -monly-N-regs option; see the User's Guide).
- GNU Make
- The GHC build system makes heavy use of features specific to recent versions of GNU make, so you must have at least GNU make 3.80 installed in order to build GHC.
Happy is a parser generator tool for Haskell, and is
used to generate GHC's parsers.
If you start from a source tarball of GHC (i.e. not a darcs checkout), then you don't need Happy, because we supply the pre-processed versions of the Happy parsers. If you intend to modify the compiler and/or you're using a darcs checkout, then you need Happy.
Happy version 1.15 is currently required to build GHC. Grab a copy from Happy's Web Page.
Alex is a lexical-analyser generator for Haskell,
which GHC uses to generate its lexer.
Like Happy, you don't need Alex if you're building GHC from a source tarball, but you do need it if you're modifying GHC and/or building a darcs checkout.
Alex is written in Haskell and is a project in the darcs repository. Alex distributions are available from Alex's Web Page.
Haddock is a documentation generator for Haskell,
used for making the docs for the libraries. If you don't want to build the docs then you don't need haddock.
Haddock is only needed for GHC 6.8.3 and older; GHC 6.10 comes with Haddock. For GHC 6.8 and older you need a 0.* version of haddock; 2.* versions won't work.
- autoconf and automake
These are needed if you intend to build from the
darcs sources, they are not needed if you
just intend to build a standard source distribution.
Version 2.52 or later of the autoconf package is required. NB. version 2.13 will no longer work, as of GHC version 6.1. Version 1.9 of automake is known to work, use others at your own risk.
autoreconf (from the autoconf package) recursively builds configure scripts from the corresponding configure.ac and aclocal.m4 files. If you modify one of the latter files, you'll need autoreconf to rebuild the corresponding configure.
- Most Unix installations and Cygwin/MSYS on Windows already come with sed, so you're probably OK. GNU sed version 2.0.4 is no good! It has a bug in it that is tickled by the build-configuration. 2.0.5 is OK. Others are probably OK too (assuming we don't create too elaborate configure scripts.)
- Most installations should have this by default, but inexplicably Cygwin does not bundle it by default.
- Required for running the testsuite. Version 2.5.2 or later is preferred, because you'll get support for running the testsuite in parallel. Stay away from 3.0 and later for now.
If libedit is installed, ghci will be built with a nice interactive line-editing interface.
Version 2.6.9 and later are known to work; note that the libeditline package listed on some distros is too old.
If a suitable version of libedit cannot be found, ghc/ghci will still build fine, just without the nice line-editing capabilities.
If your installation does not have libedit by default, you may either download and build it yourself from the link above, or else install your distro's relevant package (sometimes called "libedit-devel" or "libedit-dev").
GHC does not use libedit on Windows; instead, it uses the console's default line editor.