Skip to content

native-pointer-abi: size the wasm .bss to data high-water-mark, not the full declared memory page (blocks tiny-RAM targets) #383

Description

@avrabe

Surfaced by

Wiring the gust dissolved wasm kernel (kiln-async, --native-pointer-abi) into a bootable Cortex-M3 image (STM32F100, 8 KB SRAM; qemu lm3s6965evb 64 KB).

Problem

With --native-pointer-abi, the relocatable .o reserves the entire declared wasm linear-memory page as .bss (__synth_wasm_data):

.text    1402
.bss    65536      <-- full 1-page (64 KB) wasm memory
.data      156      <-- __synth_wasm_seg_0 (the only real data: kiln-async panic strings)

The wasm declares (memory 1) = 64 KB minimum (the wasm floor; can't go lower). But the kernel — scheduler state passed by pointer into native RAM — actually touches only ~1.2 KB of linmem (the rodata high-water-mark). synth reserves all 64 KB regardless, so the image fails to link on small targets:

rust-lld: error: section '.bss' will not fit in region 'RAM': overflowed by 983732 bytes   # vs 8KB

(64 KB .bss also leaves no room for stack even on the 64 KB lm3s6965evb.)

Ask

For --native-pointer-abi, size the emitted __synth_wasm_data .bss to the data/accessed high-water-mark (round up to alignment), not the full declared (memory N) minimum. The kernel here needs ~2 KB, not 64 KB. (Adjacent to #359's .bss sizing, but that was under-sizing the used region; this is over-reserving the unused page.)

Kill-criterion

Fixed when the gust kernel .o reserves .bss ≈ its data high-water-mark (~1–2 KB) and links into an 8 KB-RAM Cortex-M3 image. Verified: arm-zephyr-eabi-size -A gust_kernel.o shows .bss ≤ a few KB, and cargo build --bin gust_wasm links clean.

Impact / context

This is the last gap between "kiln-async kernel dissolves to ARM" (works: gust_poll = 812 B, see #382) and "the wasm kernel boots on an 8 KB MCU" — the gust maximal-wasm thesis. Code dissolution is proven; only the linmem .bss reservation blocks the tiny-target boot.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions