Skip to content

wasm32-wasi: callable exports (reactor/library mode), then a Component Model target #522

Description

@oisindevlin10-fmg

Would you consider supporting a wasm32-wasi build whose exported functions a host can call, rather than only a _start command module?

Today scriptc build --lib is refused on wasm32-wasi with SC3002, and the compiler notes that the archive/reactor contract is not supported for WASI. What we're after, smallest first:

  1. Reactor exports on WASI Preview 1. Accept the existing library-mode profile on wasm32-wasi and emit its declared exports as wasm exports, with _initialize for setup and no _start. The async-free restriction that native library mode already has would be fine for a first version.
  2. Component Model output (WASI 0.2 / wasm32-wasip2). Take a WIT world and generate its typed imports and exports, so the output is a component that validates against that world. A documented stopgap would also help, for example reactor module + wasm-tools component new with the preview1 reactor adapter + hand-written WIT.
  3. Later, wasi:http outgoing requests on the component target, so fetch can work where the host grants it.

The use case is function-shaped: a host calls handle(input) -> output many times on one instance, rather than running main once. The static tier's small output and lack of an embedded engine make scriptc a very good fit for that, apart from this gap.

This looks related to #265: a WASI reactor would face the same async question, and a host-callable drain export would answer it for both.

Is this on the roadmap, or something you'd accept? We're happy to test preview builds under Wasmtime.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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