... | @@ -9,40 +9,33 @@ modifications to others. This section contains a few nuggets of information |
... | @@ -9,40 +9,33 @@ modifications to others. This section contains a few nuggets of information |
|
that will help get you started right away. For more detailed documentation
|
|
that will help get you started right away. For more detailed documentation
|
|
on the build system, read on to the later sections.
|
|
on the build system, read on to the later sections.
|
|
|
|
|
|
## Setting up your build
|
|
## Controlling your build: `mk/build.mk`
|
|
|
|
|
|
|
|
`mk/build.mk` is a GNU makefile that contains all your build settings.
|
|
|
|
By default, this file doesn't exist, and all the parameters are set to
|
|
|
|
their defaults in `mk/config.mk` (`mk/config.mk` is the place to look for
|
|
|
|
*all* the things you might want to tune).
|
|
|
|
|
|
|
|
|
|
|
|
There's an example in
|
|
|
|
[mk/build.mk.sample](/trac/ghc/browser/ghc/mk/build.mk.sample), which you can copy to `mk/build.mk` and edit as required.
|
|
|
|
Alternatively if you want to understand a bit more about what's going on (recommended), read on.
|
|
|
|
|
|
|
|
## How to make GHC build quickly
|
|
|
|
|
|
|
|
|
|
The GHC build tree is set up so that, by default, it builds a compiler
|
|
The GHC build tree is set up so that, by default, it builds a compiler
|
|
ready for installing and using. That means full optimisation, and the
|
|
ready for installing and using. That means full optimisation, and the
|
|
build can take a *long* time. If you unpack your source tree and
|
|
build can take a *long* time. If you unpack your source tree and
|
|
right away say `./configure; make`, expect to have to wait a while.
|
|
right away say `./configure; make`, expect to have to wait a while.
|
|
|
|
|
|
|
|
|
|
For hacking, you want the build to be quick - quick to build in the
|
|
For hacking, you want the build to be quick - quick to build in the
|
|
first place, and quick to rebuild after making changes. Tuning your
|
|
first place, and quick to rebuild after making changes. Tuning your
|
|
build setup can make the difference between several hours to build
|
|
build setup can make the difference between several hours to build
|
|
GHC, and less than an hour. Here's how to do it.
|
|
GHC, and less than an hour.
|
|
|
|
|
|
|
|
|
|
If you're just interested in working on GHC, then you probably don't want
|
|
|
|
the "extralibs" libraries that we normally ship with GHC, having these in your
|
|
|
|
source tree will just make the build take longer. So when
|
|
|
|
[getting the sources](building/getting-the-sources), run `darcs-all` without
|
|
|
|
the `--extra` option.
|
|
|
|
|
|
|
|
### `mk/build.mk`
|
|
|
|
|
|
|
|
`mk/build.mk` is a GNU makefile that contains all your build settings.
|
|
|
|
By default, this file doesn't exist, and all the parameters are set to
|
|
|
|
their defaults in `mk/config.mk` (`mk/config.mk` is the place to look for
|
|
|
|
*all* the things you might want to tune).
|
|
|
|
|
|
|
|
|
|
|
|
There's an example in [mk/build.mk.sample](/trac/ghc/browser/ghc/mk/build.mk.sample), which you can copy to `mk/build.mk` and edit as required.
|
|
|
|
Alternatively if you want to understand a bit more about what's going on (recommended), read on.
|
|
|
|
|
|
|
|
|
|
|
|
A good `mk/build.mk` to start hacking on GHC is:
|
|
Here are the `build.mk` settings that
|
|
|
|
we use to build fast:
|
|
|
|
|
|
```wiki
|
|
```wiki
|
|
# My build settings for hacking on stage 1
|
|
# My build settings for hacking on stage 1
|
... | @@ -51,6 +44,7 @@ GhcStage1HcOpts = -O0 -DDEBUG -W |
... | @@ -51,6 +44,7 @@ GhcStage1HcOpts = -O0 -DDEBUG -W |
|
GhcLibHcOpts = -O -fgenerics
|
|
GhcLibHcOpts = -O -fgenerics
|
|
GhcLibWays =
|
|
GhcLibWays =
|
|
SplitObjs = NO
|
|
SplitObjs = NO
|
|
|
|
GhcBootLibs = YES
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
... | @@ -75,7 +69,7 @@ optimisation here, assuming you'll be modifying and testing stage1. |
... | @@ -75,7 +69,7 @@ optimisation here, assuming you'll be modifying and testing stage1. |
|
With optimisation off, rebuilding GHC after modifying it will be
|
|
With optimisation off, rebuilding GHC after modifying it will be
|
|
*much* quicker, not only because the individual compilations will be
|
|
*much* quicker, not only because the individual compilations will be
|
|
quicker, but also there will be fewer dependencies between modules,
|
|
quicker, but also there will be fewer dependencies between modules,
|
|
so less stuff needs to be rebuilt after each modification.
|
|
so much less stuff is recompiled after each modification.
|
|
|
|
|
|
Also we turn on `-DDEBUG`, because that enables assertions and
|
|
Also we turn on `-DDEBUG`, because that enables assertions and
|
|
debugging code in the compiler itself. Turning on DEBUG makes
|
|
debugging code in the compiler itself. Turning on DEBUG makes
|
... | @@ -106,6 +100,30 @@ linking against the library. It can be quite time and |
... | @@ -106,6 +100,30 @@ linking against the library. It can be quite time and |
|
memory-consuming, so turn it off when you're hacking.
|
|
memory-consuming, so turn it off when you're hacking.
|
|
</td></tr></table>
|
|
</td></tr></table>
|
|
|
|
|
|
|
|
<table><tr><th>`GhcBootLibs = YES`</th>
|
|
|
|
<td>
|
|
|
|
If you're just interested in working on GHC, then you probably don't want
|
|
|
|
to build the "extralibs" libraries that we normally ship with GHC.
|
|
|
|
So when [getting the sources](building/getting-the-sources),
|
|
|
|
run `darcs-all` without the `--extra` option. Alternatively, even if you have
|
|
|
|
the libraries in your tree, you can stop them being built by setting
|
|
|
|
`GhcBootLibs` in your `build.mk`.
|
|
|
|
</td></tr></table>
|
|
|
|
|
|
|
|
|
|
|
|
The other thing to remember is that for quick re-builds, you don't necessarily
|
|
|
|
want to go through the entire "make boot, make stage1, make libraries, make stage2"
|
|
|
|
sequence, which is the default if you type `make` in the root directory. Instead,
|
|
|
|
we often say:
|
|
|
|
|
|
|
|
- `cd compiler; make stage=1`: re-makes the stage-1 compiler only
|
|
|
|
- `cd libraries; make`: re-make the libraries only
|
|
|
|
- `cd compiler; make stage=2`: re-make the stage-2 compiler only
|
|
|
|
|
|
|
|
|
|
|
|
If you do things this way, it's your responsibility to say `make boot` when necessary
|
|
|
|
to rebuild dependencies.
|
|
|
|
|
|
## Actually building the bits
|
|
## Actually building the bits
|
|
|
|
|
|
|
|
|
... | | ... | |