Skip to content

[WIP] Move wasip2 impl to sys/p2#128

Draft
yoshuawuyts wants to merge 7 commits intomainfrom
p2-sys
Draft

[WIP] Move wasip2 impl to sys/p2#128
yoshuawuyts wants to merge 7 commits intomainfrom
p2-sys

Conversation

@yoshuawuyts
Copy link
Copy Markdown
Member

@yoshuawuyts yoshuawuyts commented Apr 8, 2026

Following up on #127, this PR migrates the core structure of the repo to something more similar to the polling crate. It does this by creating separate impls-per-target under sys/, with a single cfg-if switching on them in the sys/mod.rs:

cfg_if::cfg_if! {
    if #[cfg(all(target_os = "wasi", target_env = "p2"))] {
        mod p2;
        use p2 as backend;
    } else {
        compile_error!("unsupported target: wstd only compiles on `wasm32-wasip2`");
    }
}

pub use backend::*;

This general approach should result in fewer inline cfgs and a better general separation of concerns. But it's somewhat unavoidable that we'll end up with different code paths for p2 and p3 since the underlying async model is different. Something will need to abstract over those differences, and typically that job lands on runtimes. Unless of course we don't want to support p3 in wstd, but if that's the case we should probably talk that over sync sometime.

I'm putting this up as a draft because I generated this with an agent and haven't yet gone over this in detail. The changes are mostly mechanical though, so I don't expect much to be off. I prefer to review changes like these via the github interface, which is why I'm submitting this as-is. But like: please don't feel obliged to review this right now!

@yoshuawuyts
Copy link
Copy Markdown
Member Author

Yep, I'm already noticing some comments and the like have been lost in the transition. This is going to need more work.

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.

1 participant