← Winnitude! Search  ·  Reader Mode (2008 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 54 LINKS

fix: wasm32-wasip2 build fails to link the WASI signal emulation by JMLX42 ¡ Pull Request #10028 ¡ RustPython/RustPython

Repository navigation

fix: wasm32-wasip2 build fails to link the WASI signal emulation - #10028


Merged
youknowone merged 2 commits into RustPython:main from JMLX42:wasip2-emulated-signal Nov 26, 2026
Merged

fix: wasm32-wasip2 build fails to link the WASI signal emulation #10028 youknowone merged 2 commits into RustPython:main from JMLX42:wasip2-emulated-signal

Conversation

JMLX42 commented Nov 26, 2026 · edited by coderabbitai
Bot
Loading



Copy link Copy Markdown
Contributor

One of checkbox below must be checked.

  • I did not use AI to write the code of this patch.
  • This PR follows our AI policy

Summary

Follow-up to #8986 . Since that change, rustpython-host_env declares signal, raise, __SIG_IGN and __SIG_ERR on every WASI target. libwasi-emulated-signal.a, which defines them, is linked only from this repository's .cargo/config.toml, and only for wasm32-wasip1. That leaves two gaps:

  1. wasm32-wasip2 does not link. CI only runs cargo check for that target, and cargo check does not link, so CI stays green.
  2. Crates that depend on rustpython-vm get no link flag on either target, because Cargo never reads a dependency's .cargo/config.toml.

Reproduction at 9080e66 with Rust 1.100.0:

$ cargo build --locked --target wasm32-wasip2 --no-default-features \
    --features freeze-stdlib,stdlib,stdio,importlib,host_env,doc,ucd_3_2_0
  = note: rust-lld: error: ...librustpython_host_env-....rlib(...): undefined symbol: __SIG_IGN
          rust-lld: error: ...: undefined symbol: __SIG_ERR
          rust-lld: error: ...: undefined symbol: raise
          rust-lld: error: ...: undefined symbol: signal
error: could not compile `rustpython` (bin "rustpython") due to 1 previous error

Change

  • crates/host_env/build.rs emits cargo:rustc-link-search=native=<manifest dir>/vendor/<target> and cargo:rustc-link-lib=static=wasi-emulated-signal for wasm32-wasip1 and wasm32-wasip2, before its wasm32 early return. The static archive is bundled into the rlib, so dependent crates link it with no setup of their own.
  • crates/host_env/vendor/wasm32-wasip2/libwasi-emulated-signal.a comes from the same wasi-sdk-34 sysroot as the existing wasm32-wasip1 copy (lib/wasm32-wasip2/libwasi-emulated-signal.a, sha256 49b9844a3a29ea00e4adb58338bbf7ef8f2053078646e78c77ac9a2952deebf6). Its objects are position-independent; otherwise they match the wasip1 ones (same clang, target features and imports).
  • .cargo/config.toml drops the wasm32-wasip1 -L/-l pair, which the build script now covers.
  • A second commit adds a step to the wasm32-wasip2 entry of CI's cargo check matrix that runs the wasm32-wasip2 build above, so CI links that target.

Testing

With Rust 1.100.0:

  • The wasm32-wasip2 build above, which the new CI step runs, links. It failed before the change. The wasm32-wasip1 build still links, now through the build script alone.
  • extra_tests/snippets/stdlib_signal.py passes on both binaries under wasmtime 47.0.4.
  • A wasm32-wasip2 component that depends on rustpython-vm by git, with host_env, links with no linker flags of its own, and signal.raise_signal(signal.SIGINT) runs a Python handler in it.
  • On x86_64-unknown-linux-gnu: the test and Clippy commands from AGENTS.md (workspace, and crates/capi), CI's Clippy step with -Dwarnings, and cargo fmt --check all pass.

AI assistance

The investigation, the patch and this description were produced with Claude Code (claude-opus-5-5). I reviewed the diff, ran the wasm32-wasip2 and wasm32-wasip1 builds myself, and ran the signal snippet, a negative control and a SIGINT handler check on both binaries under wasmtime. Both commits carry an Assisted-by trailer.


🤖 Written by Claude Code (2.1.332) using model claude-opus-5-5

Summary by CodeRabbit

  • Bug Fixes
    • Improved signal-emulation support for builds targeting WASI Preview 1 and Preview 2.
  • Tests
    • Added a locked build check for WASI Preview 2.
  • Documentation
    • Clarified signal-emulation support across WASI targets and documented the Preview 2 archive's source, license, and checksum.
fix: wasm32-wasip2 build fails to link the WASI signal emulation 154ceb9
Follow-up to RustPython#8986.

- Problem: linking for wasm32-wasip2, or linking any crate that depends
  on rustpython-host_env for a WASI target, fails with undefined symbols
  signal, raise, __SIG_IGN and __SIG_ERR
- Cause: libwasi-emulated-signal is linked only from the workspace's
  .cargo/config.toml, only for wasm32-wasip1; Cargo never applies a
  dependency's config file, and host_env's build.rs returns early on
  wasm32. CI only runs cargo check for wasm32-wasip2, which does not link
- Fix: vendor the wasm32-wasip2 build of the library from the same
  wasi-sdk-34 sysroot, and link it from host_env's build.rs for
  wasm32-wasip1 and wasm32-wasip2. The static library is bundled into
  host_env's rlib, so dependents need no linker flags. Drop the -L/-l
  flags from .cargo/config.toml

Assisted-by: Claude Code:claude-opus-5-5

chatgpt-codex-connector
Bot
commented Nov 26, 2026



Copy link Copy Markdown
Codex Review Summary : ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-26T01:10:23.465338Z
We couldn't complete this review. Comment @codex review to try again.
154ceb9 PR opened
â„šī¸ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo . Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector
Bot
commented Nov 26, 2026



Copy link Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

coderabbitai
Bot
commented Nov 26, 2026 · edited Loading



Copy link Copy Markdown
Contributor

No actionable comments were generated in the recent review.

Walkthrough

The host environment build script now links the signal-emulation archive for wasm32-wasip1 and wasm32-wasip2. The wasm32-wasip1 Cargo configuration removes its explicit link directives. Related documentation and CI describe or check the target support.

Changes: WASI signal library linking

Layer / File(s) Summary
Target-specific signal linking
.cargo/config.toml, crates/host_env/build.rs, crates/host_env/src/signal.rs, crates/host_env/vendor/wasm32-wasip1/README.md, crates/host_env/vendor/wasm32-wasip2/README.md, .github/workflows/ci.yaml
The build script emits native link-search and static-link directives for the signal-emulation archive on both WASI targets. The wasm32-wasip1 configuration removes its explicit link directives. Documentation describes target paths, linkage, and wasm32-wasip2 archive provenance. CI adds a locked wasm32-wasip2 build with the specified feature set.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant CI as cargo_check
  participant Cargo as Cargo build
  participant BuildScript as host_env build script
  participant Linker as Native linker
  CI->>Cargo: Run locked wasm32-wasip2 build
  Cargo->>BuildScript: Execute for WASI target
  BuildScript->>Linker: Provide archive search path and static link directive
Loading

Suggested reviewers: shaharnaveh, youknowone, jiwahn

Merge Risk: Minimal ¡ up to 2afb6

This change makes WASI signal emulation link for both wasm32-wasip1 and wasm32-wasip2, including crates that depend on rustpython-host_env. No actionable merge risk was identified.

Pre-merge checks: 4

Check name Status Explanation
Title check The title names the main change: a fix so the wasm32-wasip2 build links the WASI signal emulation library. The objectives confirm that the change adds a wasip2 link path in crates/host_env/build.rs an...
Linked Issues check Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Check skipped because no linked issues were found for this pull request.
Description Check Check skipped - CodeRabbit's high-level summary is enabled.
Full details: Title check

Explanation

The title names the main change: a fix so the wasm32-wasip2 build links the WASI signal emulation library. The objectives confirm that the change adds a wasip2 link path in crates/host_env/build.rs and a wasip2 archive, and removes the wasip1-only link settings from .cargo/config.toml. The title is specific and matches the changeset, so it passes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix ¡ Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 154ceb9 and 2afb620 .

Files selected for processing: 1

  • .github/workflows/ci.yaml

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

ci: link the wasm32-wasip2 build 2afb620
The wasm32-wasip2 entry of the cargo check matrix only runs cargo check,
which does not link, so the undefined signal symbols fixed in the
previous commit passed CI. Build the rustpython binary for
wasm32-wasip2 in that entry, with the features the wasm-wasi job uses.

Assisted-by: Claude Code:claude-opus-5-5
youknowone reviewed Nov 26, 2026
View reviewed changes
Comment thread crates/host_env/vendor/wasm32-wasip2/libwasi-emulated-signal.a youknowone approved these changes Nov 26, 2026
View reviewed changes

youknowone left a comment



Copy link Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more .

ok, found no better way. Thanks!

youknowone merged commit af6db81 into RustPython : main Nov 26, 2026 28 checks passed coderabbitai
Bot
mentioned this pull request Dec 2, 2026 [WIP] Wire WASI p2 sockets and prepare preview1 descriptor adapters #9889 Draft Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment

Labels

None yet

2 participants