asterius
A Haskell to WebAssembly compiler. Work in progress.
What's already present:
- A framework which hijacks normal
ghc
pipeline and retrieves in-memory representation of raw Cmm. - A test suite for booting which compiles
ghc-prim
,integer-simple
andbase
. - Complete raw Haskell bindings of
binaryen
. - A serializable IR, roughly mapping to
binaryen
IR.
What comes next:
- A code generator/linker which collects relevant Cmm blocks at link-time and uses the
binaryen
relooper to handle arbitrary jumps. - An RTS written from scratch in native WebAssembly. Will implement enough primops & libc stubs for an MVP(Minimum Viable Product).
- A test suite for the generated WebAssembly code.
Building
Assumes x64 platform, only tested on Linux for now. Dependencies:
-
cmake
/make
/g++
: For building in-treebinaryen
-
autoconf
/sed
: For bootingghc-prim
/base
-
nodejs
: For running tests -
ghc-head
built withTABLES_NEXT_TO_CODE
disabled and integer library set tointeger-simple
. Get one viadocker pull terrorjack/meikyu:ghc-head
-
stack
.cabal
users need to runhpack
first to generateasterius.cabal
, and addhead.hackage
to the project config.
Simply run stack build
. Set MAKEFLAGS=-j8
to pass flags to make
for parallel building of binaryen
. Run stack test asterius:ahc-boot
to test if booting works.
Windows users need to run it in an mingw-w64
Win64 shell. stack
takes care of installing/launching it by default.
WebGHC
Differences from- Doesn't depend on Emscripten/LLVM. There is no plan to port the C runtime and support C libraries, at least for now.