2.3 KiB
High-level architecture
The asterius
project is hosted at GitHub. The monorepo contains several packages:
asterius
. This is the central package of theasterius
compiler.binaryen
. It contains the latest source code of the C++ librarybinaryen
in tree, and provides complete raw bindings to its C API.ghc-toolkit
. It provides a framework for implementing Haskell-to-X compilers by retrievingghc
's various types of in-memory intermediate representations. It also contains the latest source code ofghc-prim
/integer-gmp
/integer-simple
/base
in tree.
The asterius
package provides an ahc
executable which is a drop-in replacement of ghc
to be used with Setup configure
. ahc
redirects all arguments to the real ghc
most of the time, but when it's invoked with the --make
major mode, it invokes ghc
with its frontend plugin. This is inspired by Edward Yang's How to integrate GHC API programs with Cabal.
Based on ghc-toolkit
, asterius
implements a ghc
frontend plugin which translates Cmm to binaryen
IR. The serialized binaryen
IR can then be loaded and linked to a WebAssembly binary (not implemented yet). The normal compilation pipeline which generates native machine code is not affected.
About "booting"
In order for asterius
to support non-trivial Haskell programs (that is, at least most things in Prelude
), it needs to run the compilation process for base
and its dependent packages. This process is known as "booting".
The asterius
package provides an ahc-boot
test suite which tests booting by compiling the wired-in packages provided by ghc-toolkit
and using ahc
to replace ghc
when configuring. This is inspired by Joachim Breitner's veggies
.