Skip to content

add WASIp2 support via wasi-libc#1

Open
dicej wants to merge 4 commits intomasterfrom
wasip2-using-wasi-libc
Open

add WASIp2 support via wasi-libc#1
dicej wants to merge 4 commits intomasterfrom
wasip2-using-wasi-libc

Conversation

@dicej
Copy link
Copy Markdown
Owner

@dicej dicej commented Feb 17, 2026

This adds support for WASIp2 networking using the poll(2)-based selector and leaving most of the details to wasi-libc.

I've triaged each previously-disabled-on-WASI integration test into one of three categories:

  • Enabled for p2; (still) disabled for p1
  • Disabled for both p1 and p2 (e.g. due to use of thread::spawn)
    • We should be able to enable some of these for p3 once it has multithreading
  • Temporarily disabled for p2 due to bugs in wasi-libc and/or wasmtime-wasi
    • These bugs have all been fixed, but have yet made their way to a stable release

Note that I've bumped the MSRV to 1.82, which allows us to use target_env = "p1" in cfg directives. I've also added a TestWASI job to CI to run the tests using Wasmtime.

Comment on lines 492 to +511
#[cfg(target_os = "linux")]
const POLLRDHUP: libc::c_short = libc::POLLRDHUP;
#[cfg(not(target_os = "linux"))]
const POLLRDHUP: libc::c_short = 0;

#[cfg(not(target_os = "wasi"))]
const POLLPRI: libc::c_short = libc::POLLPRI;
#[cfg(target_os = "wasi")]
const POLLPRI: libc::c_short = 0;

#[cfg(not(target_os = "wasi"))]
const POLLRDBAND: libc::c_short = libc::POLLRDBAND;
#[cfg(target_os = "wasi")]
const POLLRDBAND: libc::c_short = 0;

#[cfg(not(target_os = "wasi"))]
const POLLWRBAND: libc::c_short = libc::POLLWRBAND;
#[cfg(target_os = "wasi")]
const POLLWRBAND: libc::c_short = 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Depending on review feedback, this might be requested to become a macro, but I wouldn't preemptively make this a macro unless asked.

@alexcrichton
Copy link
Copy Markdown

We'll also definitely want CI green before posting

@dicej dicej force-pushed the wasip2-using-wasi-libc branch 4 times, most recently from 9b6503b to c0aff3b Compare February 20, 2026 20:45
This adds support for WASIp2 networking using the `poll(2)`-based selector and
leaving most of the details to `wasi-libc`.

This includes a new `Waker` implementation since WASIp2 has neither
mulithreading, nor `pipe(2)`, nor `eventfd(2)`.  Eventually, `wasi-libc`'s
support for WASIp3 will have both multithreading and `pipe(2)`, so that port
will be simpler.

I've triaged each previously-disabled-on-WASI integration test into one of three
categories:

- Enabled for p2; (still) disabled for p1
- Disabled for both p1 and p2 (e.g. due to use of `thread::spawn`)
    - We should be able to enable some of these for p3 once it has multithreading
- Temporarily disabled for p2 due to bugs in `wasi-libc` and/or `wasmtime-wasi`
    - These bugs have all been fixed, but have not yet made their way to a stable release

Note that I've added a `TestWASI` job to CI to run the tests using Wasmtime.

I've taken care to ensure that the existing `wasm32-wasip1` support has not
regressed.  If desired, I could follow this up with a PR which removes p1
support entirely given its limited utility, which would reduce the amount of
`#[cfg]` clutter and maintenance burden.
@dicej dicej force-pushed the wasip2-using-wasi-libc branch 3 times, most recently from 5e5aff3 to 5fc5408 Compare February 20, 2026 21:46
@dicej dicej force-pushed the wasip2-using-wasi-libc branch from 5fc5408 to 1ea9c38 Compare February 20, 2026 21:48
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