Stack can build packages from source with the following syntax:
With Stack 1.9.* we can’t use this kind of syntax to build GHC (and the other global packages such as
template-haskell) from source.
But as my patch has been merged, the next major release of Stack will support it! With it we can easily select the compiler repository, commit ID and Hadrian flavour with the following syntax:
Then we can use
stack build as usual.
This will be particularly useful for people developing software that depends on features only available in a fork of GHC (e.g. if it uses some GHC API not available in a released GHC).
I think it could also be used to implement custom CI for GHC. For instance, a cron job could track new commits pushed into GHC repository and could use this feature to easily try to build some packages (Stackage packages?) with the corresponding compiler to track build errors, GHC regressions, etc. To help revive something like https://perf.haskell.org/ghc/ maybe?
It could also be useful to make the use of derived compilers easier without having to provide bindists (GHCJS?).
It could also be used when the official bindist is broken (e.g. https://gitlab.haskell.org/ghc/ghc/issues/16408).
Hadrian is the newer build system of GHC. An Hadrian “flavour” is a set of configuration options for a GHC build (e.g. the
Integer library to use, the RTS ways, etc.). You can add or modify flavours in your GHC fork if necessary.
hadrian/build.stack.[sh,bat] scripts to build GHC, which themselves rely on Stack and on the
hadrian/stack.yaml file. It means that the bootstrap GHC compiler is installed by Stack and its version is defined in this file (e.g. at the time of writing, the resolver used in
hadrian/stack.yaml means that GHC 8.6.4 is used as bootstrap compiler). Other tools such as “alex” and “happy” are managed by Stack too. This makes the build environment quite reproducible!
- Stack documentation:
- Stack patches and ticket:
- GHC patches related to this work: