snowleopard / hadrian

Hadrian: a new build system for the Glasgow Haskell Compiler. Now merged into the GHC tree!
https://gitlab.haskell.org/ghc/ghc/tree/master/hadrian
MIT License
208 stars 37 forks source link

Hadrian

Note: Hadrian has been merged to GHC and now lives in GHC's directory hadrian. The GitHub repository where Hadrian was originally developed (https://github.com/snowleopard/hadrian) is now out-of-date, although we may occasionally synchronise it with GHC's version. Please submit any new issues on GHC Trac.

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, since it places all build artefacts in a dedicated directory (called _build by default). See this guide if you'd like to start using Hadrian for building GHC.

Your first build

Beware, the build system is in the alpha development phase. Things are shaky and sometimes break; there are numerous known issues. Not afraid? Then put on the helmet and run the following command from root of the GHC tree:

hadrian/build.sh -j

or on Windows:

hadrian/build.bat -j

Here flag -j enables parallelism and is optional. We will further refer to the build script simply as build. Note that Hadrian can also run the boot and configure scripts automatically if you pass the flag --configure, or simply -c. See the overview of command line flags below.

Notes:

Using the build system

Once your first build is successful, simply run build to rebuild. Build results are placed into _build and inplace directories.

Command line flags

In addition to standard Shake flags (try --help), the build system currently supports several others:

User settings

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.

Clean and full rebuild

Documentation

To build GHC documentation, run build docs. Note that finer-grain documentation targets (e.g. building only HTML documentation or only the GHC User's Guide) are currently not supported.

Source distribution

To build a GHC source distribution tarball, run build source-dist.

Binary distribution

To build a GHC binary distribution, run build binary-dist. The resulting tarball contains just enough to support the

$ ./configure [--prefix=PATH] && make install

workflow, for now.

Testing

Troubleshooting

Here are a few simple suggestions that might help you fix the build:

If everything fails, don't hesitate to raise an issue.

Current limitations

The new build system still lacks many important features:

Check out milestones to see when we hope to resolve the above limitations.

How to contribute

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.

Acknowledgements

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.