Hadrian is a new build system for the Glasgow Haskell Compiler. It is based on Shake and we hope that it will soon replace the current Make-based build system. If you are curious about the rationale behind the project and the architecture of the build system you can find more details in this Haskell Symposium 2016 paper and this Haskell eXchange 2016 talk.
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,
e.g. the resulting GHC is inplace/bin/ghc-stage2
.
Beware, the build system is in the alpha development phase. Things are shaky and often break; there are numerous known issues. Not afraid? Then put on the helmet and follow these steps:
-
If you have never built GHC before, start with the preparation guide.
-
Hadrian is written in Haskell and depends on the following packages:
ansi-terminal extra mtl quickcheck shake
. -
Get the sources. It is important for the build system to be in the
hadrian
directory of the GHC source tree:git clone --recursive git://git.haskell.org/ghc.git cd ghc git clone git://github.com/snowleopard/hadrian
-
Build GHC using
hadrian/build.sh
orhadrian/build.bat
(on Windows) instead ofmake
. You might want to enable parallelism with-j
. We will further refer to the build script simply asbuild
. Note that Hadrian runs theboot
andconfigure
scripts automatically when needed. Use--skip-configure
to suppress this behaviour (see overview of command line flags below). -
If the default build script doesn't work, you might want to give a try to a more specific one based on Cabal sandboxes (
build.cabal.sh
), Stack (build.stack.bat
) or the global package database (build.global-db.sh
). Also see instructions for building GHC on Windows using Stack.
Once your first build is successful, simply run build
to rebuild. Build results
are placed into _build
and inplace
directories.
In addition to standard Shake flags (try --help
), the build system
currently supports several others:
-
--flavour=FLAVOUR
: choose a build flavour. The following settings are currently supported:default
,quick
,quickest
,perf
,prof
,devel1
anddevel2
. As an example, thequickest
flavour adds-O0
flag to all GHC invocations and builds libraries only in thevanilla
way, which speeds up builds by 3-4x. Build flavours are documented here. -
--freeze1
: freeze Stage1 GHC, i.e. do not rebuild it even if some of its source files are out-of-date. This allows to significantly reduce the rebuild time when you are working on a feature that affects both Stage1 and Stage2 compilers, but may lead to incorrect build results. To unfreeze Stage1 GHC simply drop the--freeze1
flag and Hadrian will rebuild all out-of-date files. -
--haddock
: build Haddock documentation. -
--integer-simple
: build GHC using theinteger-simple
integer library (instead ofinteger-gmp
). -
--progress-colour=MODE
: choose whether to use colours when printing build progress info. There are three settings:never
(do not use colours),auto
(attempt to detect whether the console supports colours; this is the default setting), andalways
(use colours). -
--progress-info=STYLE
: choose how build progress info is printed. There are four settings:none
,brief
(one line per build command; this is the default setting),normal
(typically a box per build command), andunicorn
(whennormal
just won't do). -
--skip-configure
: use this flag to suppress the default behaviour of Hadrian that runs theboot
andconfigure
scripts automatically when needed, so that you don't have to remember to run them manually. With--skip-configure
you will need to manually run:./boot ./configure # On Windows run ./configure --enable-tarballs-autodownload
as you normally do when using
make
. Beware, by default Hadrian may do network I/O on Windows to download necessary tarballs, which may sometimes be undesirable;--skip-configure
is your friend in such cases. -
--split-objects
: generate split objects, which are switched off by default. Due to a GHC bug, you need a full clean rebuild when using this flag. -
--verbose
: run Hadrian in verbose mode. In particular this prints diagnostic messages by Shake oracles.
The Make-based build system uses mk/build.mk
to specify user build settings. We
use hadrian/UserSettings.hs
for the same purpose, see documentation.
-
build clean
removes all build artefacts. -
build -B
forces Shake to rerun all rules, even if the previous build results are are still up-to-date.
To build a GHC source distribution tarball, run Hadrian with the sdist-ghc
target.
To build and install GHC artifacts, run the install
target.
By default, GHC will be installed to the specified prefix path on your system,
relative to the root of the file system. For example on UNIX, GHC will be installed
to /usr/local/bin
. By setting the command line flag --install-destdir=[DESTDIR]
,
you can install GHC to path DESTDIR/<prefix>
instead. Make sure you use correct
absolute path as DESTDIR
on Windows, e.g. C:/path
, which installs GHC
into C:/path/usr/local
.
-
build validate
runs GHC tests by simply executingmake fast
intestsuite/tests
directory. This can be used instead ofsh validate --fast --no-clean
in the existing build system. Note: this will rebuild Stage2 GHC,ghc-pkg
andhpc
if they are out of date. -
build test
runs GHC tests by calling thetestsuite/driver/runtests.py
python script with appropriate flags. The current implementation is limited and cannot replace thevalidate
script (see #187). -
build selftest
runs tests of the build system. Current test coverage is close to zero (see #197).
The new build system still lacks many important features:
- Validation is not implemented: #187.
- Dynamic linking on Windows is not supported #343.
- There is no support for binary distribution: #219.
Check out milestones to see when we hope to resolve the above limitations.
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 at present and we expect a lot of further refactoring. If you would like to work on a particular issue, please let everyone know by adding a comment about this. The issues that are currently on the critical path and therefore require particular attention are listed in #239. Also have a look at projects where open issues and pull requests are grouped into categories.
I started this project as part of my 6-month research visit to Microsoft Research Cambridge, which was funded by Newcastle University, EPSRC, and Microsoft Research. I would like to thank Simon Peyton Jones, Neil Mitchell and Simon Marlow for kick-starting the project and for their guidance. Zhen Zhang has done fantastic work on Hadrian as part of his Summer of Haskell 2017 project, solving a few heavy and long-overdue issues. Last but not least, big thanks to all other project contributors, who helped me endure and enjoy the project.