Why compiling Rust to WebAssembly is slow
Scored daily by a customisable AI persona to surface the most relevant engineering leadership news.
Deep technical analysis of Rust-to-WASM compilation performance, actionable for developers using WebAssembly.
Compiling Rust to WebAssembly with debug info (debug = 2) can be 40x slower than without, as demonstrated by a 40-line reproducer that takes 50 seconds with debug info vs 1.5 seconds without. The root cause is an LLVM bug in the Register Stackify pass for WebAssembly's stack machine: moving instructions to optimize operand stack usage also moves DBG_VALUE records, but the pass rescanning and duplicating records for each moved definition creates quadratic complexity. The fix for clang is incomplete for Rust's wasm target, and the default dev profile's debug = 2 alias triggers this for all wasm builds.