You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lift a parameter-less `fn main()` into the WASI 0.2 (preview2) command
shape so `wasmtime run <component>` actually runs an AffineScript
program end-to-end, closing the "real-host main-invoke" gap left open
by S3 (reactor-only componentize) and S4a/b (preview1 import bridging).
Codegen (lib/codegen.ml):
- After exports_with_mem is assembled, when `main` is exported and
takes no parameters, append a `_start : () -> ()` shim whose body
is `Call main_idx; Drop` (drops main's i32 result — current ABI is
uniformly i32-returning even for `() -> ()`). Skips silently if a
user already exports `_start` or `main` has parameters.
- Purely additive: every existing consumer (reactor componentize,
game-loop hosts, `__indirect_function_table` for closures) sees the
same exports plus an extra `_start`. Lambda-table elem indices are
unaffected (start_func is appended after lambdas in all_funcs).
Tooling:
- tools/provision-component-toolchain.sh now fetches both the reactor
and command adapters (wasmtime v44.0.1), each sha256-pinned and
fail-closed. Back-compat: the S3-era `ADAPTER_URL`/`_SHA256`/`_PATH`
variables remain as reactor-aliased exports.
- tools/componentize.sh learns `--command` / `--reactor` modes;
`--command` selects the command adapter, fails fast with a pointer
to the codegen contract if the core is missing `_start`, and
asserts `wasi:cli/run` is exported in the resulting component.
Gate:
- tests/componentize/command_smoke.sh — opt-in, SKIPs cleanly without
the toolchain or wasmtime; otherwise compiles a fixture, asserts the
`_start` shim, runs the command componentize path, asserts the
ownership section survives + `wasi:cli/run` is lifted, and runs the
component under `wasmtime run` (exit 0 is the contract).
Verified end-to-end on this branch: `wasmtime run` succeeds on a
real fresh-compiled component (`fn consume(x) { x }` /
`fn main() { consume(42) }`), the existing S3 reactor smoke still
passes, and the full OCaml test suite stays green (295 tests).
Docs:
- TECH-DEBT.adoc / ECOSYSTEM.adoc INT-03 rows: S6 split into S6a
(WIT export lifting, DONE) + S6b (sockets) + S6c (default-flip).
- META.a2ml ADR-015 decision text mirrors the split.
- SETTLED-DECISIONS.adoc mirror updated in lockstep.
WIT world (`wit/affinescript.wit`) unchanged — already the contract
of record; the command-mode output exports a subset (`wasi:cli/run`
plus the adapter's required imports). Sockets + default-target flip
remain in scope for S6b/S6c per the ADR.
Refs #180
0 commit comments