Skip to content

Fix wasip2 build#6935

Merged
youknowone merged 2 commits intoRustPython:mainfrom
youknowone:wasip2
Feb 1, 2026
Merged

Fix wasip2 build#6935
youknowone merged 2 commits intoRustPython:mainfrom
youknowone:wasip2

Conversation

@youknowone
Copy link
Member

@youknowone youknowone commented Feb 1, 2026

Fix #6891
Fix #5704

Summary by CodeRabbit

  • Chores
    • Updated CI workflow to include compilation verification for the wasm32-wasip2 target.
    • Removed conditional feature gating from crate-level attributes.
    • Refactored platform-specific FFI implementations and path handling for WASI environments.
    • Updated standard library module exports for WASI platform compatibility.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 1, 2026

📝 Walkthrough

Walkthrough

The pull request migrates RustPython away from the unstable wasip2 feature flag by providing custom stable implementations of wasip2-specific APIs. It removes feature gates, adds a new WASI p2-specific ffi module with OsStrExt and OsStringExt traits, updates API imports and usage, and extends CI to verify compilation for the wasm32-wasip2 target.

Changes

Cohort / File(s) Summary
Feature gate removal
src/lib.rs, crates/stdlib/src/lib.rs, crates/common/src/lib.rs
Removes crate-level #![cfg_attr(...wasip2)] and #![feature(wasip2)] attributes, eliminating reliance on the unstable wasip2 feature flag.
WASI p2 stable ffi implementation
crates/common/src/os.rs
Introduces a new pub mod ffi under cfg(all(target_os = "wasi", target_env = "p2")) with custom trait definitions: OsStrExt (as_bytes, from_bytes) and OsStringExt (from_vec, into_vec). Includes trait implementations for std::ffi types and a sealed module, leveraging UTF-8 guarantees for WASI p2 compatibility.
API import and usage updates
crates/stdlib/src/select.rs, src/settings.rs
Updates RawFd re-export path from std::os::wasi::io::RawFd to std::os::fd::RawFd. Changes split_paths implementation to use as_encoded_bytes() and from_encoded_bytes_unchecked() instead of unstable OsStrExt trait methods.
CI enhancement
.github/workflows/ci.yaml
Adds rust-toolchain installation and cargo check step for the wasm32-wasip2 target to verify compilation on WASI p2 builds.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • PR #5985: Converts string-based APIs to byte-oriented operations (as_bytes, as_encoded_bytes), employing similar patterns for handling encoded bytes across the codebase.

Poem

🐰 No longer trapped by unstable gates so tight,
WASI p2 shines with implementations bright,
Custom traits bloom, where bytes dance free,
Stable foundations for all to see! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title "Fix wasip2 build" directly corresponds to the main objective of addressing wasm32-wasip2 compilation failures referenced in issues #6891 and #5704.
Linked Issues check ✅ Passed The PR addresses both linked issues by providing stable WASI p2 FFI implementations, adjusting platform imports, removing conditional wasip2 features, and updating the split_paths implementation to work with wasip2 without relying on unstable features.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing wasip2 target compilation: CI workflow updates, WASI p2 FFI module implementations, feature flag removal, and import path adjustments align with the stated objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 1, 2026

Code has been automatically formatted

The code in this PR has been formatted using:

  • cargo fmt --all
    Please pull the latest changes before pushing again:
git pull origin wasip2

@youknowone youknowone marked this pull request as ready for review February 1, 2026 16:14
@youknowone youknowone merged commit 5e732c5 into RustPython:main Feb 1, 2026
13 checks passed
@youknowone youknowone deleted the wasip2 branch February 1, 2026 16:26
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.

Broken build of RustPython on wasip2 Can not build RustPython to wasm32-wasip2

1 participant