30

Stack: building GHC from source

 5 years ago
source link: https://www.tuicool.com/articles/hit/Nbuquur
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Stack can build packages from source with the following syntax:

extra-deps:
   git: https://github.com/me/mypackage
   commit: aaaaabbbbccccdddeeeefff123456

With Stack 1.9.* we can’t use this kind of syntax to build GHC (and the other global packages such as base or 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:

compiler: ghc-git-aaaaabbbbccccdddeeeefff123456-perf
# commit ID: aaaaabbbbccccdddeeeefff123456
# Hadrian flavour: "perf"

compiler-repository: https://github.com/me/ghc
# OPTIONAL. Default compiler repository is "https://gitlab.haskell.org/ghc/ghc"

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 ).

Details

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.

Stack uses 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!

References


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK