README.md 7.82 KB
Newer Older
Andrey Mokhov's avatar
Andrey Mokhov committed
1
2
Hadrian
=======
Andrey Mokhov's avatar
Andrey Mokhov committed
3

Andrey Mokhov's avatar
Andrey Mokhov committed
4
[![Linux & OS X status](https://img.shields.io/travis/snowleopard/hadrian/master.svg?label=Linux%20%26%20OS%20X)](https://travis-ci.org/snowleopard/hadrian) [![Windows status](https://img.shields.io/appveyor/ci/snowleopard/hadrian/master.svg?label=Windows)](https://ci.appveyor.com/project/snowleopard/hadrian)
Andrey Mokhov's avatar
Andrey Mokhov committed
5

Andrey Mokhov's avatar
Andrey Mokhov committed
6
Hadrian is a new build system for the [Glasgow Haskell Compiler][ghc]. It is based
7
8
9
on [Shake][shake] and we hope that it will eventually replace the current
[`make`-based build system][make]. If you are curious about the rationale and initial
ideas behind the project you can find more details on the [wiki page][ghc-shake-wiki]
Andrey Mokhov's avatar
Andrey Mokhov committed
10
and in this [blog post][blog-post-1]. This project was formerly known as *Shaking-up-GHC*.
11

12
13
The new build system can work side-by-side with the existing build system. Note, there is
some interaction between them: they put (some) build results in the same directories,
Andrey Mokhov's avatar
Andrey Mokhov committed
14
e.g. `inplace/bin/ghc-stage1`.
15

16
17
18
19
20
21
22
23
24
25
26
27
Your first build
----------------

Beware, the build system is in the alpha development phase. Things are shaky and often
break; there are numerous [known issues][issues]. Not afraid? Then put on the helmet and
follow these steps:

* If you have never built GHC before, start with the [preparation guide][ghc-preparation].

* This build system is written in Haskell (obviously) and depends on the following Haskell
packages, which need to be installed: `ansi-terminal`, `mtl`, `shake`, `QuickCheck`.

28
* Get the sources and run standard configuration scripts. It is important for the build
Andrey Mokhov's avatar
Andrey Mokhov committed
29
system to be in the `hadrian` directory of the GHC source tree:
30
31
32
33

    ```bash
    git clone --recursive git://git.haskell.org/ghc.git
    cd ghc
Andrey Mokhov's avatar
Andrey Mokhov committed
34
    git clone git://github.com/snowleopard/hadrian
35
36
    ./boot
    ./configure # On Windows run ./configure --enable-tarballs-autodownload
37
    ```
38
    
Andrey Mokhov's avatar
Andrey Mokhov committed
39
* Build GHC using `hadrian/build.sh` or `hadrian/build.bat` (on Windows) instead
40
41
of `make`. You might want to enable parallelism with `-j`. We will further refer to the
build script simply as `build`. If you are interested in building in a Cabal sandbox
42
43
or using Stack, have a look at `build.cabal.sh` and `build.stack.sh` scripts. Also
see [instructions for building GHC on Windows using Stack][windows-build].
44
45
46

Using the build system
----------------------
47
48
Once your first build is successful, simply run `build` to rebuild. Most build artefacts
are placed into `.build` and `inplace` directories ([#113][build-artefacts-issue]).
49

50
#### Command line flags
51
52
53

In addition to standard Shake flags (try `--help`), the build system
currently supports several others:
54
* `--flavour=FLAVOUR`: choose a build flavour. Two settings are currently supported:
55
56
`default` and `quick` (adds `-O0` flag to all GHC invocations and disables library
profiling, which speeds up builds by 3-4x).
Andrey Mokhov's avatar
Andrey Mokhov committed
57
* `--haddock`: build Haddock documentation.
58
59
60
* `--progress-info=STYLE`: choose how build progress info is printed. There are four
settings: `none`, `brief` (one line per build command), `normal` (typically a box per
build command; this is the default setting), and `unicorn` (when `normal` just won't do).
Andrey Mokhov's avatar
Andrey Mokhov committed
61
62
63
64
65
66
67
* `--setup[=CONFIGURE_ARGS]`: setup the build system by running the `configure` script 
with `CONFIGURE_ARGS` arguments; also run the `boot` script to create the `configure`
script if necessary. On Windows, download the required tarballs by executing
`mk/get-win32-tarballs.sh` with appropriate parameters. You do not have to
use this functionality of the new build system; feel free to run `boot` and `configure`
scripts manually, as you do when using `make`. Beware: `--setup` uses network I/O 
which may sometimes be undesirable.
68
69
70
* `--split-objects`: generate split objects, which are switched off by default. Due to
a GHC [bug][ghc-split-objs-bug], you need a full clean rebuild when using this flag.

71
#### User settings
72
73
74

The `make`-based build system uses `mk/build.mk` to specify user build settings. We
use [`src/Settings/User.hs`][user-settings] for the same purpose. Feel free to
75
experiment following the Haddock comments.
76

77
#### Clean and full rebuild
78

79
80
* `build clean` removes all build artefacts. Note, we are working towards a
complete separation of GHC sources and build artefacts: [#113][build-artefacts-issue].
81

82
83
* `build -B` forces Shake to rerun all rules, even if results of the previous build
are still in the GHC tree. 
Andrey Mokhov's avatar
Andrey Mokhov committed
84
85
86

#### Testing

87
88
89
* `build validate` runs GHC tests by simply executing `make fast` in `testsuite/tests`
directory. This can be used instead of `sh validate --fast --no-clean` in the existing
build system. Note: this will rebuild Stage2 GHC, `ghc-pkg` and `hpc` if they are out of date.
Andrey Mokhov's avatar
Andrey Mokhov committed
90

91
92
93
* `build test` runs GHC tests by calling the `testsuite/driver/runtests.py` python
script with appropriate flags. The current implementation is limited and cannot
replace the `validate` script (see [#187][validation-issue]).
Andrey Mokhov's avatar
Andrey Mokhov committed
94

95
96
* `build selftest` runs tests of the build system. Current test coverage is close to
zero (see [#197][test-issue]).
97

98
99
100
Current limitations
-------------------
The new build system still lacks many important features:
Andrey Mokhov's avatar
Andrey Mokhov committed
101
* We only build `vanilla` and `profiling` way: [#4][dynamic-issue].
102
* Validation is not implemented: [#187][validation-issue].
Andrey Mokhov's avatar
Andrey Mokhov committed
103
* Only HTML Haddock documentation is supported (use `--haddock` flag). 
104
105
* Build flavours and conventional command line flags are not implemented: [#188][flavours-issue].
* Cross-compilation is not implemented: [#177][cross-compilation-issue].
Andrey Mokhov's avatar
Andrey Mokhov committed
106
* There is no support for installation or binary/source distribution: [#219][install-issue].
107

Andrey Mokhov's avatar
Andrey Mokhov committed
108
109
Check out [milestones] to see when we hope to resolve the above limitations.

110
111
How to contribute
-----------------
112
113
114

The best way to contribute is to try the new build system, report the issues
you found, and attempt to fix them. Please note the codebase is very unstable
115
at present and we expect a lot of further refactoring. The documentation is
116
117
currently non-existent, but we are working on it: [#55][comments-issue],
[#56][doc-issue].
118

119
120
121
122
Acknowledgements
----------------

I started this project as part of my 6-month research visit to Microsoft
Andrey Mokhov's avatar
Andrey Mokhov committed
123
Research Cambridge, which was funded by Newcastle University, EPSRC, and
124
125
126
127
Microsoft Research. I would like to thank Simon Peyton Jones, Neil Mitchell
and Simon Marlow for kick-starting the project and for their guidance. Last
but not least, big thanks to the project [contributors][contributors], who
helped me endure and enjoy the project.
128
129

[ghc]: https://en.wikipedia.org/wiki/Glasgow_Haskell_Compiler
130
[shake]: https://github.com/ndmitchell/shake/blob/master/README.md
131
132
133
[make]: https://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
[ghc-shake-wiki]: https://ghc.haskell.org/trac/ghc/wiki/Building/Shake
[blog-post-1]: https://blogs.ncl.ac.uk/andreymokhov/shaking-up-ghc
Andrey Mokhov's avatar
Andrey Mokhov committed
134
[issues]: https://github.com/snowleopard/hadrian/issues
135
136
[ghc-preparation]: https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation
[ghc-windows-quick-build]: https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation/Windows#AQuickBuild
Andrey Mokhov's avatar
Andrey Mokhov committed
137
138
[windows-build]: https://github.com/snowleopard/hadrian/blob/master/doc/windows.md
[build-artefacts-issue]: https://github.com/snowleopard/hadrian/issues/113
139
[ghc-split-objs-bug]: https://ghc.haskell.org/trac/ghc/ticket/11315
Andrey Mokhov's avatar
Andrey Mokhov committed
140
141
142
143
144
145
146
147
148
149
150
[user-settings]: https://github.com/snowleopard/hadrian/blob/master/src/Settings/User.hs
[test-issue]: https://github.com/snowleopard/hadrian/issues/197
[dynamic-issue]: https://github.com/snowleopard/hadrian/issues/4
[validation-issue]: https://github.com/snowleopard/hadrian/issues/187
[flavours-issue]: https://github.com/snowleopard/hadrian/issues/188
[cross-compilation-issue]: https://github.com/snowleopard/hadrian/issues/177
[install-issue]: https://github.com/snowleopard/hadrian/issues/219
[milestones]: https://github.com/snowleopard/hadrian/milestones
[comments-issue]: https://github.com/snowleopard/hadrian/issues/55
[doc-issue]: https://github.com/snowleopard/hadrian/issues/56
[contributors]: https://github.com/snowleopard/hadrian/graphs/contributors