Skip to content

Conversation

@ricochet
Copy link

Rework of #532 by @nickrum, addressing review feedback from @Darksonn
and @Thomasdezeeuw:

  • Reuses sys/unix.rs instead of creating sys/wasi.rs (per @Thomasdezeeuw's
    code review feedback)
  • MaybeUninitSlice stays unconditional since libc::iovec is available on WASI,
    eliminating 11+ scattered cfg gates (per @Darksonn's concern)
  • Internal cfg changes concentrated in the sys module

Opt-in cfg patterns use all(target_os = "wasi", not(target_env = "p1"))
to match how the libc crate gates WASI p2 socket support. Opt-out
patterns use bare target_os = "wasi" for features unavailable on any
WASI version.

WASI tests run in CI with wasmtime (27/27 pass). Tests for unsupported
socket options are gated out with references to the relevant WASI spec
issues (SO_BROADCAST, SO_LINGER, IPV6_V6ONLY).

export CARGO_TARGET_WASM32_WASIP2_RUNNER="wasmtime --wasi inherit-network"
# Doc-tests are excluded because the SockRef example spawns threads, which
# WASI does not yet support.
cargo test --target wasm32-wasip2 --lib --tests

Closes #268

Based-on: #532
Co-authored-by: Nicola Krumschmidt [email protected]

Rework of rust-lang#532 by @nickrum, addressing review feedback from @Darksonn
and @Thomasdezeeuw:

- Reuses sys/unix.rs instead of creating sys/wasi.rs (per @Thomasdezeeuw's
  code review feedback)
- MaybeUninitSlice stays unconditional since libc::iovec is available on WASI,
  eliminating 11+ scattered cfg gates (per @Darksonn's concern)
- Internal cfg changes concentrated in the sys module

Opt-in cfg patterns use `all(target_os = "wasi", not(target_env = "p1"))`
to match how the libc crate gates WASI p2 socket support. Opt-out
patterns use bare `target_os = "wasi"` for features unavailable on any
WASI version.

WASI tests run in CI with wasmtime (27/27 pass). Tests for unsupported
socket options are gated out with references to the relevant WASI spec
issues (SO_BROADCAST, SO_LINGER, IPV6_V6ONLY).

```bash
export CARGO_TARGET_WASM32_WASIP2_RUNNER="wasmtime --wasi inherit-network"
cargo test --target wasm32-wasip2 --lib --tests
```

Closes rust-lang#268

Based-on: rust-lang#532
Co-authored-by: Nicola Krumschmidt <[email protected]>
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.

Support wasm (in some form)

1 participant