Problem
At current main (60c30f2ff), the WASI toolchain unconditionally adds:
-Wl,--initial-memory=67108864
-z stack-size=10485760
internal/crosscompile/crosscompile_test.go also freezes the 64 MiB value. This applies even though targets/wasip1.json declares a much smaller default-stack-size and even when the generated program does not need a large host stack.
This makes a minimal WASI command reserve 1,024 WebAssembly pages (64 MiB) at instantiation, hides the resource benefit of stackless/embedded runtimes, and gives target authors no supported way to select an appropriate memory budget.
Small reproducer
Build any successful WASI command and inspect its memory section:
llgo build -target=wasip1 -o hello.wasm ./hello.go
wasm-objdump -x hello.wasm | grep -A2 '^Memory'
The result contains:
Memory[1]:
- memory[0] pages: initial=1024
The fixed values come directly from internal/crosscompile/crosscompile.go rather than the resolved target profile.
Suggested direction
- Add target/profile fields for initial (and optionally maximum) linear memory.
- Use the resolved target stack-size policy instead of the unconditional 10 MiB linker stack.
- Keep conservative defaults for the direct
GOOS=wasip1 GOARCH=wasm path, but allow named targets to override them.
- Add a linker-flag unit test plus a tiny module layout test proving the configured page count.
This is independent of the coroutine implementation; it is in the shared main-branch WASI toolchain.
Problem
At current
main(60c30f2ff), the WASI toolchain unconditionally adds:internal/crosscompile/crosscompile_test.goalso freezes the 64 MiB value. This applies even thoughtargets/wasip1.jsondeclares a much smallerdefault-stack-sizeand even when the generated program does not need a large host stack.This makes a minimal WASI command reserve 1,024 WebAssembly pages (64 MiB) at instantiation, hides the resource benefit of stackless/embedded runtimes, and gives target authors no supported way to select an appropriate memory budget.
Small reproducer
Build any successful WASI command and inspect its memory section:
The result contains:
The fixed values come directly from
internal/crosscompile/crosscompile.gorather than the resolved target profile.Suggested direction
GOOS=wasip1 GOARCH=wasmpath, but allow named targets to override them.This is independent of the coroutine implementation; it is in the shared main-branch WASI toolchain.