Skip to content

Conversation

pchickey
Copy link
Contributor

@pchickey pchickey commented Jun 25, 2025

This is a pretty big PR towards making component-init usable standalone:

  • Introduce a new crate component-init-wasmtime that provides a wasmtime-based Invoker. Right now this Invoker only supports trapping on calls to any imports, will add WASI support in a follow-up PR
  • Introduce a new crate component-init-cli that provides a CLI interface to component-init-wasmtime. Just adds the clap dep here.
  • redesign component-init-get-memory to no longer try to use a __stack_pointer global, which only exists in the way component-init expects in components crated with wasm-tools component link. Instead, a new allocation strategy is used that ignores all contents of the module and just calls mem.grow, which it uses to store the return value pointing to the previous full range of memory.
  • add tests for component-init-wasmtime: two handwritten wat components show it handles initialization of memory and a mut global, and one rust guest shows it works for a "real" component
  • add a CI job that runs the above tests, checks formatting, and checks docs. You can see that CI runs here: Pch/wasmtime and cli pchickey/component-init#1

In addition to the newly written tests, I tested my work against componentize-py and posted the following PR to update componentize-py to this version of component-init bytecodealliance/componentize-py#159. That PR should wait to land until we publish component-init to crates.io, in my opinion.

@pchickey pchickey force-pushed the pch/wasmtime_and_cli branch 2 times, most recently from b7c1aca to b916474 Compare June 25, 2025 19:54
@pchickey pchickey force-pushed the pch/wasmtime_and_cli branch from b916474 to 9a45c2f Compare June 27, 2025 20:33
@pchickey pchickey force-pushed the pch/wasmtime_and_cli branch from 292733b to eb6d3ae Compare June 27, 2025 22:32
@pchickey pchickey force-pushed the pch/wasmtime_and_cli branch from eb6d3ae to 47a6c40 Compare June 27, 2025 22:33
Copy link
Owner

@dicej dicej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; thanks so much for doing this! Just a couple of inline comments, both optional.

with:
toolchain: stable
target: wasm32-wasip2
- name: check
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be in favor of running clippy here unless there's a good reason not to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! 10a0482

}"
});

// rustc won't allow using a a Cell in a static, but since this is a component (which is always
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: using AtomicBool here would be simpler and require less explanation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep 24fb6dd

@pchickey pchickey requested a review from dicej June 30, 2025 21:50
@dicej dicej merged commit b0132c7 into dicej:main Jun 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants