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

add wasm32-wasip2 support #1836

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

add wasm32-wasip2 support #1836

wants to merge 2 commits into from

Commits on Oct 9, 2024

  1. add wasm32-wasip2 support

    This implementation currently uses a mix of POSIX-style APIs (provided by
    `wasi-libc` via the `libc` crate) and WASIp2-native APIs (provided by the `wasi`
    crate).
    
    Alternatively, we could implement `Selector` using only POSIX APIs,
    e.g. `poll(2)`.  However, that would add an extra layer of abstraction to
    support and debug, as well as make it impossible to support polling
    `wasi:io/poll/pollable` objects which cannot be represented as POSIX file
    descriptors (e.g. timer events, DNS queries, HTTP requests, etc.).
    
    Another approach would be to use _only_ the WASIp2 APIs and bypass `wasi-libc`
    entirely.  However, that would break interoperability with both Rust `std` and
    e.g. C libraries which expect to work with file descriptors.
    
    Since `wasi-libc` does not yet provide a public API for converting between file
    descriptors and WASIp2 resource handles, we currently use a non-public API (see
    the `netc` module below) to do so.  Once
    WebAssembly/wasi-libc#542 is addressed, we'll be able
    to switch to a public API.
    
    I've tested this end-to-end using https://github.com/dicej/wasi-sockets-tests,
    which includes smoke tests for `mio`, `tokio`, `tokio-postgres`, etc.
    
    Signed-off-by: Joel Dice <[email protected]>
    dicej committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    229e04b View commit details
    Browse the repository at this point in the history

Commits on Oct 10, 2024

  1. add WASIp2 TODO comments

    // TODO tokio-rs#1: Add a public, WASIp2-only API for registering
    // `wasi::io::poll::Pollable`s directly (i.e. those which do not correspond to
    // any `wasi-libc` file descriptor, such as `wasi:http` requests).
    //
    // TODO tokio-rs#2: Add support for binding, listening, and accepting.  This would
    // involve adding cases for `TCP_SOCKET_STATE_UNBOUND`,
    // `TCP_SOCKET_STATE_BOUND`, and `TCP_SOCKET_STATE_LISTENING` to the `match`
    // statements in `Selector::select`.
    //
    // TODO tokio-rs#3: Add support for UDP sockets.  This would involve adding cases for
    // the `UDP_SOCKET_STATE_*` tags to the `match` statements in
    // `Selector::select`.
    
    Signed-off-by: Joel Dice <[email protected]>
    dicej committed Oct 10, 2024
    Configuration menu
    Copy the full SHA
    fae1ac4 View commit details
    Browse the repository at this point in the history