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-c-api: switch from wasi-common to wasmtime-wasi #8066

Merged
merged 3 commits into from
Apr 12, 2024

Conversation

pchickey
Copy link
Contributor

@pchickey pchickey commented Mar 8, 2024

Based on #8053

This PR switches the wasmtime-c-api from using wasi-common to wasmtime-wasi.

The c-api still only exposes WASI P1 support to the guests - this isn't attempting to solve the problem of exposing components and WASI P2 on the c-api. It is only changing the implementation used under the hood so that we can push wasi-common into maintenance mode.

This PR removes the wasi_config_preopen_socket symbol from the c-api. It should be deployed as part of release-20.0.0 (not backported to 19) so that users get 1 release of deprecation warning via #8064 . The idea of a preopen socket is a weird corner of P1 that never got any appropriate testing in the wasmtime tree, and doesnt have a translation in the P2 world. I sought out if there were any users of that part of the P1 / wasi-common code, because the company that contributed it is now defunct, and I never found any users. The warning in #8064 may alert us to some and the symbol going away in this PR may as well.

@pchickey pchickey requested a review from a team as a code owner March 8, 2024 00:30
@pchickey pchickey requested review from alexcrichton and elliottt and removed request for a team and alexcrichton March 8, 2024 00:30
@github-actions github-actions bot added wasi Issues pertaining to WASI wasmtime:c-api Issues pertaining to the C API. labels Mar 8, 2024
Copy link

github-actions bot commented Mar 8, 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.

@elliottt elliottt force-pushed the pch/wasmtime_wasi_c_api branch from a8180c7 to cee2a81 Compare April 12, 2024 15:28
@pchickey pchickey requested a review from a team as a code owner April 12, 2024 15:28
@elliottt elliottt force-pushed the pch/wasmtime_wasi_c_api branch 3 times, most recently from c5bf41e to 386d65e Compare April 12, 2024 18:15
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.

This looks good to me!

@elliottt elliottt requested a review from alexcrichton April 12, 2024 18:26
Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

Thanks!

@elliottt elliottt force-pushed the pch/wasmtime_wasi_c_api branch from 386d65e to d042f2e Compare April 12, 2024 20:31
@elliottt elliottt force-pushed the pch/wasmtime_wasi_c_api branch from d042f2e to 44dd07b Compare April 12, 2024 20:32
@elliottt elliottt added this pull request to the merge queue Apr 12, 2024
Merged via the queue into main with commit 0c62d93 Apr 12, 2024
22 checks passed
@elliottt elliottt deleted the pch/wasmtime_wasi_c_api branch April 12, 2024 21:37
elliottt added a commit to elliottt/wasmtime that referenced this pull request Apr 12, 2024
…iance#8066)

* wasmtime-c-api: switch from using wasi-common to wasmtime-wasi

* Fix WasiP1Ctx references, and stop eagerly opening dirs for preopens

* Add OutputFile to skip async writes in stdout/stderr

---------

Co-authored-by: Trevor Elliott <[email protected]>
alexcrichton pushed a commit that referenced this pull request Apr 12, 2024
* wasmtime-c-api: switch from wasi-common to wasmtime-wasi (#8066)

* wasmtime-c-api: switch from using wasi-common to wasmtime-wasi

* Fix WasiP1Ctx references, and stop eagerly opening dirs for preopens

* Add OutputFile to skip async writes in stdout/stderr

---------

Co-authored-by: Trevor Elliott <[email protected]>

* Add release notes for 8066

---------

Co-authored-by: Pat Hickey <[email protected]>
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Apr 14, 2024
github-merge-queue bot pushed a commit that referenced this pull request Apr 14, 2024
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Apr 15, 2024
fitzgen added a commit that referenced this pull request Apr 15, 2024
* c-api: Better differentiate between `wasm.h` and `wasmtime.h` APIs (#8344)

This renames some types and adds some type aliases to help us better distinguish
between `wasm.h` APIs and `wasmtime.h` APIs, primarily for `Store`-related
types. In general, `WasmFoo` is related to `wasm.h` and `WasmtimeFoo` is related
to `wasmtime.h`.

* `StoreRef` -> `WasmStoreRef`
* Introduce the `WasmStore[Data]` and `WasmStoreContext[Mut]` aliases
* `StoreData` -> `WasmtimeStoreData`
* `CStoreContext[Mut]` -> `WasmtimeStoreContext[Mut]`
* Introduce the `Wasmtime{Store,Caller}` aliases

* `wasmtime-c-api`: Improve non-support of GC references in `wasm.h` APIs (#8345)

* c-api: Better differentiate between `wasm.h` and `wasmtime.h` APIs

This renames some types and adds some type aliases to help us better distinguish
between `wasm.h` APIs and `wasmtime.h` APIs, primarily for `Store`-related
types. In general, `WasmFoo` is related to `wasm.h` and `WasmtimeFoo` is related
to `wasmtime.h`.

* `StoreRef` -> `WasmStoreRef`
* Introduce the `WasmStore[Data]` and `WasmStoreContext[Mut]` aliases
* `StoreData` -> `WasmtimeStoreData`
* `CStoreContext[Mut]` -> `WasmtimeStoreContext[Mut]`
* Introduce the `Wasmtime{Store,Caller}` aliases

* c-api: Improve non-support of GC references in `wasm.h` APIs

A couple small tweaks: error message improvements, exhaustive matching, etc...

* Fix running wasi-common tests on CI (#8353)

* Fix running wasi-common tests on CI

Turns out we haven't been running wasi-common tests for some time in CI
and they've started failing. Force enable the test at all times and then
fix the test failures. The test failures here were introduced in #8277
and weren't caught due to the test not running and the fix was to relax
the implementation of `fd_pread` to avoid taking multiple mutable
borrows.

* Fix CI

* Update release notes for 20.0.0 (#8358)

A busy release!

* Enable the gc feature by default in the c-api (#8356)

Match the Wasmtime crate in this respect

* wasmtime-c-api: Add support for GC references in `wasmtime.h` APIs (#8346)

Restores support for `externref` in `wasmtime_val_t`, methods for manipulating
them and getting their wrapped host data, and examples/tests for these things.

Additionally adds support for `anyref` in `wasmtime_val_t`, clone/delete methods
similar to those for `externref`, and a few `i31ref`-specific methods. Also adds
C and Rust example / test for working with `anyref`.

* Fix calculation of gc refs in functions (#8355)

* Fix calculation of gc refs in functions

In addition to excluding i31 also exclude funcrefs.

* Review comments

* Remove `wasi_config_preopen_socket` from C header (#8364)

This was removed in #8066

* Tidy up some headers related to shared memory (#8366)

* Tidy up some headers related to shared memory

* Don't declare an anonymous `struct wasmtime_sharedmemory`, instead
  `#include` the actual definition.
* Fix an issue where a header in `sharedmemory.h` referred to a type in
  `extern.h` which wasn't `#include`'d. This function,
  `wasmtime_sharedmemory_into_extern`, additionally isn't necessary as
  it's no different than manually constructing it. Fix this by removing
  this function.

* Run clang-format

* c-api: Fix alignment of `wasmtime_val_*` (#8363)

* c-api: Fix alignment of `wasmtime_val_*`

This commit fixes an issue where `wasmtime_val_raw_t` had an incorrect
alignment. In Rust `ValRaw` contains a `u128` which has an alignment of
16 but in C the representation had a smaller alignment meaning that the
alignment of the two structures was different. This was seen to cause
alignment faults when structure were passed from C++ to Rust, for
example.

This commit changes the Rust representation of `ValRaw`'s `v128` field
to do the same as C which is to use `[u8; 16]`. This avoids the need to
raise the alignment in C which appears to be nontrivial. Cranelift is
appropriately adjusted to understand that loads/stores from `ValRaw` are
no longer aligned. Technically this only applies to the `v128` field but
it's not too bad to apply it to the other fields as well.

* Try alternate syntax for alignof

* Use `--locked` on all `cargo install` in CI, also remove non-locked example (#8369)

* Use `--locked` on all `cargo install` in CI

Prevents any updates to rustc or crates from accidentally causing issues
by ensuring that the same set of deps is used over time.

* Remove rust/WASI markdown parser example

The documentation referring to this example was removed in #6994 and
that forgot to remove this as well. This example is building without a
lock file which is causing issues in #8368.

---------

Co-authored-by: Nick Fitzgerald <[email protected]>
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