← board

wasm32 never runs a unit's initialization section

unit u; interface var V: Integer; implementation initialization V := 42; end.
program p; uses u; begin WriteLn(V); end.     { x86-64: 42   wasm32: 0 }

It fails the same way with the begin ... end. form of a unit's initialization.

What it broke

Every RTL unit whose initialization does work was left uninitialised, with no error:

Cause

pasparser_prog.inc runs the constant global initialisers (CompilePendingGlobalInits), then EmitCallProc(InitProcs[i]) for each unit in dependency order, then the body. EmitCallProc writes machine code. On wasm32, each top-level piece of work becomes its own function (a "main chunk"), and the main/_start export is synthesised by WasmEmitMainWrapper as a call to each chunk in turn. Nothing ever called the init procs. DCE even kept them alive (WasmDceMarkProc(InitProcs[i])).

The fix

Measured (2026-09-29, fixedpoint b21689af5303)

Not in this fix