Skip to content

feat: P3 async components compile — wit-bindgen crate replaces stubs#423

Open
avrabe wants to merge 4 commits intomainfrom
feat/p3-build-flags
Open

feat: P3 async components compile — wit-bindgen crate replaces stubs#423
avrabe wants to merge 4 commits intomainfrom
feat/p3-build-flags

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Mar 27, 2026

Summary

P3 async WASM components now fully compile. Two major changes:

1. Replace hand-rolled runtime stubs with wit-bindgen crate

The bindings library now depends on @crates//:wit-bindgen instead of our ~80 LOC hand-rolled wit_bindgen::rt module. This:

  • Eliminates stubs that needed manual updates when wit-bindgen CLI changed
  • Provides async_support module (futures, tasks, waitable sets)
  • Removes CLI version compatibility check
  • Works for both P2 and P3

2. P3 async compilation pipeline works end-to-end

  • wasi_version = "p3" → passes --async all to wit-bindgen
  • Generated traits have async fn methods
  • wit-bindgen crate provides the async runtime
  • P3 test component with async fn greet() compiles and passes

Test plan

  • //test/p3:p2_build_test passes (P2 with crate runtime)
  • //test/p3:p3_build_test passes (P3 async — first time ever!)
  • //examples/basic:hello_component passes (no regression)
  • CI passes

🤖 Generated with Claude Code

avrabe and others added 2 commits March 27, 2026 18:55
When wasi_version = "p3", rust_wasm_component_bindgen now passes
--async to wit-bindgen, generating async-aware bindings. This is the
first behavioral difference between P2 and P3 builds.

Add get_p3_config() to wasm_component_utils.bzl for P3 build flags.

The P3 build currently fails at compile time because the generated
async code references wit_bindgen::rt::async_support, which requires
the full wit-bindgen crate runtime instead of our minimal runtime stub.
The P3 test is tagged manual until the async runtime is integrated.

Next step: integrate wit-bindgen crate as a Rust dependency for P3
components, replacing the hand-rolled runtime wrapper.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Switch from minimal embedded runtime wrapper to the actual wit-bindgen
crate for Rust bindings. This eliminates ~80 LOC of stubs, provides
async_support for P3, and removes CLI version compatibility checks.

P3 async components now fully compile:
- wit-bindgen gets --async flag, crate provides async_support runtime
- P3 test uses async fn greet() and passes
- Bump wit-bindgen crate 0.52.0 → 0.54.0 with async feature

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@avrabe avrabe changed the title feat: pass --async to wit-bindgen for P3 components feat: P3 async components compile — wit-bindgen crate replaces stubs Mar 28, 2026
avrabe and others added 2 commits March 28, 2026 07:19
The export! macro must be public for both guest and native-guest modes
since we now use the wit-bindgen crate runtime for all builds. Without
this, host builds fail with 'macro export is private'.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
WASM (guest) builds use wit-bindgen crate runtime (supports async).
Host (native-guest) builds keep embedded runtime stub (avoids linker
issues with WASM-specific exports on native targets).

Fixes Direct Integration Test failure where ld.gold couldn't parse
version scripts from wit-bindgen crate exports on host builds.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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