Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasmtime-wasi: introduce WasiP1Ctx #8053

Merged
merged 1 commit into from
Mar 8, 2024
Merged

wasmtime-wasi: introduce WasiP1Ctx #8053

merged 1 commit into from
Mar 8, 2024

Conversation

pchickey
Copy link
Contributor

@pchickey pchickey commented Mar 5, 2024

This PR adds wasmtime_wasi::WasiP1Ctx, which is a WasiCtx for just using WASI P1 (and P0).

This simplifies user experience for users migrating from wasi-common's P1 support - it means they don't have to know about the *View traits or the WasiPreview1Adapter, which are just implementation details to a P1 embedder.

The p1/p0 add_to_linker_{a?}sync functions now take a closure that is the lens for the T in Store, to be consistent with wasi-common and in general what wasmtime::Linker users expect.

WasiCtxBuilder now has a convenient function build_p1(&mut self) -> WasiP1Ctx that can be used in the place of build(&mut self) -> WasiCtx for users targeting a P1 embedding.

This PR also adds two trivial methods to WasiCtxBuilder to reflect ones that existed in wasi-common;s: inherit_env and inherit_args.

Finally, this PR adds AsyncStdinStream and AsyncStdoutStream as wrappers on AsyncReadStream and AsyncWriteStream to provide implementations of StdinStream and StdoutStream. (This could be separated into a totally different PR, but it doesnt seem worth the e-paperwork overhead to bother.) These provide parity with the wasi-common affordances for piping stdio to/from files, which happen to be used in the c-api.

The top-level tests and examples that were using wasi-common are updated to use wasmtime-wasi::WasiP1Ctx.

@github-actions github-actions bot added wasi Issues pertaining to WASI wasmtime:c-api Issues pertaining to the C API. labels Mar 6, 2024
Copy link

github-actions bot commented Mar 6, 2024

Subscribe to Label Action

cc @peterhuene

This issue or pull request has been labeled: "wasi", "wasmtime:c-api"

Thus the following users have been cc'd because of the following labels:

  • peterhuene: wasmtime:c-api

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

Copy link
Contributor

@lpereira lpereira left a comment

Choose a reason for hiding this comment

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

LGTM. (Looks like one of those things that if it builds and passes CI, it's most likely OK.)

… closure

and add a few missing bits of functionality for use in the c-api
@pchickey pchickey changed the title wasmtime-wasi: introduce WasiP1Ctx, use in c-api wasmtime-wasi: introduce WasiP1Ctx Mar 8, 2024
@pchickey pchickey marked this pull request as ready for review March 8, 2024 00:05
@pchickey pchickey requested a review from a team as a code owner March 8, 2024 00:05
@pchickey pchickey requested review from fitzgen and elliottt and removed request for a team and fitzgen March 8, 2024 00:05
Copy link
Member

@elliottt elliottt left a comment

Choose a reason for hiding this comment

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

🎉

@elliottt elliottt added this pull request to the merge queue Mar 8, 2024
@pchickey
Copy link
Contributor Author

pchickey commented Mar 8, 2024

This PR should be backported to the release-19.0.0 branch

Merged via the queue into main with commit 97e3a45 Mar 8, 2024
21 checks passed
@elliottt elliottt deleted the pch/wasip1ctx branch March 8, 2024 01:06
elliottt pushed a commit to elliottt/wasmtime that referenced this pull request Mar 8, 2024
… closure (bytecodealliance#8053)

and add a few missing bits of functionality for use in the c-api
elliottt added a commit that referenced this pull request Mar 8, 2024
* wasmtime-wasi: introduce WasiP1Ctx, re-jigger p0 & p1 linkers to take closure (#8053)

and add a few missing bits of functionality for use in the c-api

* wasmtime c-api: warn that wasi_config_preopen_socket is deprecated in next release (#8064)

this PR will be backported to the release-19.0.0 branch prior to the 19
release.

* Add release notes

---------

Co-authored-by: Pat Hickey <phickey@fastly.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasi Issues pertaining to WASI wasmtime:c-api Issues pertaining to the C API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants