Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Compiler development

简体中文

Puddi compiles source and WIT bindings to WebAssembly. The compiler architecture describes the current main branch in detail.

StageWhat it doesStarting point
SourcesDiscovers modules, loads dependencies and generates WIT bindingssrc/main.rs, src/deps.rs, src/wit.rs
Front endLexes and parses source, expands derives and resolves namessrc/lexer.rs, src/parser.rs, src/derive.rs, src/program.rs
ElaborationChecks types and patterns, monomorphizes generics and lowers to typed IRsrc/elab.rs, src/exhaust.rs, src/ir.rs
WebAssemblyLowers WasmGC types and instructions, encodes the module and wraps it as a componentsrc/codegen.rs, src/wit.rs
HostingRuns the component in Wasmtime or extracts the core module for a JavaScript hostsrc/runner.rs, src/runtime.mjs

Optimization and diagnostics

Puddi v0.1.1 includes an IR optimization pass, a built-in WebAssembly assembler, parallel parsing and code generation, and caches for builds and Wasmtime machine code. See the v0.1.1 release notes for details.

Environment variableWhat it does
PUD_TIME=1Print elapsed time at compiler phases
PUD_NO_CACHE=1Disable the build and Wasmtime caches
PUD_NO_OPT=1Skip the IR optimizer
PUD_WAT=1Use the wat crate instead of the built-in assembler
PUD_ASM_CHECK=1Assemble with both implementations and compare their output
PUD_SERIAL_CODEGEN=1Generate WebAssembly text on one thread

Finding the right test

Add a conformance case when a change affects a rule in the specification. Use the compiler repository’s tests/run for a runtime regression and tests/fail for a rejected program. The contribution guide explains the fixture formats.