The GHC WebAssembly Backend
summary
GHC now ships a WebAssembly backend (Asterius → in-tree) that actually builds with ghc.nix with withWasiSDK=true, produces ~10–12 MB .wasm executables (example: a GHC-API pretty-printer and in-browser Ormolu), and runs under Wasmtime. Key engineering details: emit linkable wasm objects (linking convention / textual assembly), lower Cmm with a Relooper, fix the RTS megablock allocator by growing linear memory via osdump.c, and test via Hadrian plus a cross emulator; wasm-opt shrinks 40–50%.
AI-written summary · about
chapters (12)
- 0:00GHC WASM backend intro
- 4:28Building GHC WASM from source
- 7:07WebAssembly basics for GHC
- 29:01WebAssembly control flow
- 48:56Why Asterius failed
- 1:00:01Why WASM beats bytecode
- 1:02:52GHC WASM backend overview
- 1:05:49Porting GHC RTS storage
- 1:16:43RTS tweaks for WASM
- 1:23:23Lowering Cmm to WASM
- 1:39:08WASM code generation
- 1:43:53Testing GHC WASM backend








