|Version 28 (modified by simonmar, 7 years ago) (diff)|
Getting started with the build system
There is more complete documentation for the build system later on in this guide (see Building/Using), but this page gives a quick overview of how to get around the GHC build system.
Building after making changes
To bring the whole tree up to date after making a change, just
it might take a while, depending on what you changed. If you want to rebuild just part of the tree, for example the RTS, go into the appropriate subdirectory and say make there:
$ cd rts $ make
this should rebuild just the RTS. If you want to just build the stage 2 compiler, then
$ cd ghc $ make stage2
For more, see Developing in a GHC build tree.
To clean the whole tree:
$ make clean
there's also make distclean, which will clean files that are generated by configure, and make maintainer-clean, which cleans everything that is not in the source repository.
You can clean just a part of the tree, e.g. the RTS:
$ cd rts $ make clean
Another way to build GHC is to run the validate script, which does a build of GHC from scratch (it does make distclean first), using standard settings.
The GHC build system works with make's -j flag, which spawns multiple compile processes in parallel. Even on a single processor machine it's usually worthwhile using at least make -j2, because the I/O will be overlapped with compute-intensive compilation. On a multicore machine, higher -j values will speed up the build even more.
Controlling your build
The build is controlled in two ways:
- Flags given to ./configure. See Run the configure script.
- The file mk/build.mk. This is a file you create yourself, containing various build settings. There's a sample file in mk/build.mk.sample that you can copy to mk/build.mk and use as a starting point. For more information on what you can do with build.mk, see Build configuration. In particular, you might want to make GHC build quickly.
Running GHC from the build tree
You don't need to install GHC to use it. After the build has completed, you can run GHC like this:
and to start GHCi, just add the --interactive flag. You can also see what packages have been built:
$ ./inplace/bin/ghc-pkg list
Video: Getting and Building, layout of the source tree, how to set up build.mk (23'43")