... | @@ -7,7 +7,7 @@ This section covers making changes to the GHC build system. We'll give some gen |
... | @@ -7,7 +7,7 @@ This section covers making changes to the GHC build system. We'll give some gen |
|
Note that before making any non-trivial changes to the build system you should acquaint yourself with the overall [architecture](building/architecture). Even if you're already familiar with GNU make, the GHC build system is probably quite different from most `Makefile`-based build systems you've encountered before.
|
|
Note that before making any non-trivial changes to the build system you should acquaint yourself with the overall [architecture](building/architecture). Even if you're already familiar with GNU make, the GHC build system is probably quite different from most `Makefile`-based build systems you've encountered before.
|
|
|
|
|
|
|
|
|
|
Incedentally, it's a good idea to have a copy of the
|
|
Incidentally, it's a good idea to have a copy of the
|
|
[ GNU make documentation](http://www.gnu.org/software/make/manual/make.html) to hand when working with the build system.
|
|
[ GNU make documentation](http://www.gnu.org/software/make/manual/make.html) to hand when working with the build system.
|
|
|
|
|
|
## Debugging
|
|
## Debugging
|
... | @@ -26,7 +26,7 @@ Here are the techniques that we use. Note, for many of these diagnosis techniqu |
... | @@ -26,7 +26,7 @@ Here are the techniques that we use. Note, for many of these diagnosis techniqu |
|
|
|
|
|
<table><tr><th>`$(warning ... message ...)`</th>
|
|
<table><tr><th>`$(warning ... message ...)`</th>
|
|
<td>
|
|
<td>
|
|
equivalent to "printf-debugging\` in a C program: this causes
|
|
equivalent to "printf-debugging" in a C program: this causes
|
|
**make** to print a message when it reads the `$(warning ..)`
|
|
**make** to print a message when it reads the `$(warning ..)`
|
|
expression, and the message can include variable references. Very
|
|
expression, and the message can include variable references. Very
|
|
useful for finding out what **make** thinks the value of a
|
|
useful for finding out what **make** thinks the value of a
|
... | @@ -41,7 +41,7 @@ prints the value of variable `VAR`. Useful for quick diagnosis. |
... | @@ -41,7 +41,7 @@ prints the value of variable `VAR`. Useful for quick diagnosis. |
|
|
|
|
|
<table><tr><th>`make TRACE=1`</th>
|
|
<table><tr><th>`make TRACE=1`</th>
|
|
<td>
|
|
<td>
|
|
prints messages about certain macros that are called and their arguments. This is basically a system of `$(warning)` calls enabled when the value of `$(TRACE)` is non-empty. To see how it works, look at the file [rules/trace.mk](/trac/ghc/browser/ghc/rules/trace.mk), and feel free to add trace calls to more places in the build system.
|
|
prints messages about certain macros that are called and their arguments. This is basically a system of `$(warning)` calls enabled when the value of `$(TRACE)` is non-empty. To see how it works, look at the file [rules/trace.mk](/trac/ghc/browser/rules/trace.mk)[](/trac/ghc/export/HEAD/ghc/rules/trace.mk), and feel free to add trace calls to more places in the build system.
|
|
</td></tr></table>
|
|
</td></tr></table>
|
|
|
|
|
|
<table><tr><th>`make --debug=b --debug=m`</th>
|
|
<table><tr><th>`make --debug=b --debug=m`</th>
|
... | @@ -73,12 +73,12 @@ GHC is in two parts: |
... | @@ -73,12 +73,12 @@ GHC is in two parts: |
|
- the `ghc` program itself, consists of a single `Main` module that imports the `ghc` package. It is found in the `ghc` directory.
|
|
- the `ghc` program itself, consists of a single `Main` module that imports the `ghc` package. It is found in the `ghc` directory.
|
|
|
|
|
|
|
|
|
|
Like any Cabal package, the `ghc` package has a `ghc.cabal` file, except that in this case the file is preprocessed by `configure` from the original: [compiler/ghc.cabal.in](/trac/ghc/browser/ghc/compiler/ghc.cabal.in). Be careful not to modify the preprocessed version, `ghc.cabal`, as it will be overwritten next time you run `configure`.
|
|
Like any Cabal package, the `ghc` package has a `ghc.cabal` file, except that in this case the file is preprocessed by `configure` from the original: [compiler/ghc.cabal.in](/trac/ghc/browser/compiler/ghc.cabal.in)[](/trac/ghc/export/HEAD/ghc/compiler/ghc.cabal.in). Be careful not to modify the preprocessed version, `ghc.cabal`, as it will be overwritten next time you run `configure`.
|
|
|
|
|
|
|
|
|
|
To add a module to the `ghc` package:
|
|
To add a module to the `ghc` package:
|
|
|
|
|
|
- Add your module to the `exposed-modules` section of [compiler/ghc.cabal.in](/trac/ghc/browser/ghc/compiler/ghc.cabal.in)
|
|
- Add your module to the `exposed-modules` section of [compiler/ghc.cabal.in](/trac/ghc/browser/compiler/ghc.cabal.in)[](/trac/ghc/export/HEAD/ghc/compiler/ghc.cabal.in)
|
|
- `cd compiler; make stage2`
|
|
- `cd compiler; make stage2`
|
|
|
|
|
|
### Removing a source file from GHC
|
|
### Removing a source file from GHC
|
... | @@ -87,8 +87,9 @@ To add a module to the `ghc` package: |
... | @@ -87,8 +87,9 @@ To add a module to the `ghc` package: |
|
To retire a GHC source file that is no longer needed:
|
|
To retire a GHC source file that is no longer needed:
|
|
|
|
|
|
- Remove the working copy of the file (git will notice it is gone), or use `git rm`.
|
|
- Remove the working copy of the file (git will notice it is gone), or use `git rm`.
|
|
- Remove the module from the list of modules in [compiler/ghc.cabal.in](/trac/ghc/browser/ghc/compiler/ghc.cabal.in).
|
|
- Remove the module from the list of modules in [compiler/ghc.cabal.in](/trac/ghc/browser/compiler/ghc.cabal.in)[](/trac/ghc/export/HEAD/ghc/compiler/ghc.cabal.in).
|
|
- To remove all mention of the file from derived dependency files, it is necessary to do something on the order of
|
|
- To remove all mention of the file from derived dependency files, it is necessary to do something on the
|
|
|
|
order of
|
|
|
|
|
|
```wiki
|
|
```wiki
|
|
cd $TOP
|
|
cd $TOP
|
... | @@ -118,9 +119,9 @@ To have the change propagated to the stage 2 compiler, either go and make stage |
... | @@ -118,9 +119,9 @@ To have the change propagated to the stage 2 compiler, either go and make stage |
|
|
|
|
|
Adding a new package is quite straightforward:
|
|
Adding a new package is quite straightforward:
|
|
|
|
|
|
- To arrange that the package is checked out by `sync-all`, add an entry to the [packages](/trac/ghc/browser/ghc/packages) file.
|
|
- To arrange that the package is checked out by `sync-all`, add an entry to the [packages](/trac/ghc/browser/packages)[](/trac/ghc/export/HEAD/ghc/packages) file.
|
|
- run `perl boot` to generate the `ghc.mk` and `GNUmakefile` files in your package's build.
|
|
- run `perl boot` to generate the `ghc.mk` and `GNUmakefile` files in your package's build.
|
|
- Add an entry to the `PACKAGES` variable in [ghc.mk](/trac/ghc/browser/ghc/ghc.mk). The list in `PACKAGES` is kept in dependency order: each package must appear after the packages it depends on.
|
|
- Add an entry to the `PACKAGES` variable in [ghc.mk](/trac/ghc/browser/ghc.mk)[](/trac/ghc/export/HEAD/ghc/ghc.mk). The list in `PACKAGES` is kept in dependency order: each package must appear after the packages it depends on.
|
|
|
|
|
|
|
|
|
|
That's it: doing a top-level `make` should now build your package and bring everything else up to date.
|
|
That's it: doing a top-level `make` should now build your package and bring everything else up to date.
|
... | @@ -179,7 +180,7 @@ $(eval $(call build-prog,utils/hpc,dist,1)) |
... | @@ -179,7 +180,7 @@ $(eval $(call build-prog,utils/hpc,dist,1)) |
|
```
|
|
```
|
|
|
|
|
|
|
|
|
|
This is a call to the `build-prog` macro, whose definition can be found in [rules/build-prog.mk](/trac/ghc/browser/ghc/rules/build-prog.mk). This expands to the code for actually building the program, and it takes three arguments: the directory, the distdir, and the GHC stage to use for building (in this case we're using stage 1). The `build-prog` macro expects to find certain variables defined, namely *directory*_*distdir*`_PROG`, and *directory*_*distdir*`_MODULES`.
|
|
This is a call to the `build-prog` macro, whose definition can be found in [rules/build-prog.mk](/trac/ghc/browser/rules/build-prog.mk)[](/trac/ghc/export/HEAD/ghc/rules/build-prog.mk). This expands to the code for actually building the program, and it takes three arguments: the directory, the distdir, and the GHC stage to use for building (in this case we're using stage 1). The `build-prog` macro expects to find certain variables defined, namely *directory*_*distdir*`_PROG`, and *directory*_*distdir*`_MODULES`.
|
|
|
|
|
|
|
|
|
|
Finally, for programs that we want to install, we need to include the `ghc.mk` file in a binary distribution:
|
|
Finally, for programs that we want to install, we need to include the `ghc.mk` file in a binary distribution:
|
... | | ... | |