Repository navigation
fix: wasm32-wasip2 build fails to link the WASI signal emulation - #10028
Conversation
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
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
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
There was a problem hiding this comment.
is this needed to be manually downloaded? is there any other option?
youknowone
left a comment
There was a problem hiding this comment.
ok, found no better way. Thanks!
One of checkbox below must be checked.
Summary
Follow-up to #8986. Since that change,
rustpython-host_envdeclaressignal,raise,__SIG_IGNand__SIG_ERRon every WASI target.libwasi-emulated-signal.a, which defines them, is linked only from this repository's.cargo/config.toml, and only forwasm32-wasip1. That leaves two gaps:wasm32-wasip2does not link. CI only runscargo checkfor that target, andcargo checkdoes not link, so CI stays green.rustpython-vmget no link flag on either target, because Cargo never reads a dependency's.cargo/config.toml.Reproduction at 9080e66 with Rust 1.100.0:
Change
crates/host_env/build.rsemitscargo:rustc-link-search=native=<manifest dir>/vendor/<target>andcargo:rustc-link-lib=static=wasi-emulated-signalforwasm32-wasip1andwasm32-wasip2, before itswasm32early 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.acomes from the same wasi-sdk-34 sysroot as the existingwasm32-wasip1copy (lib/wasm32-wasip2/libwasi-emulated-signal.a, sha25649b9844a3a29ea00e4adb58338bbf7ef8f2053078646e78c77ac9a2952deebf6). Its objects are position-independent; otherwise they match the wasip1 ones (same clang, target features and imports)..cargo/config.tomldrops thewasm32-wasip1-L/-lpair, which the build script now covers.wasm32-wasip2entry of CI'scargo checkmatrix that runs thewasm32-wasip2build above, so CI links that target.Testing
With Rust 1.100.0:
wasm32-wasip2build above, which the new CI step runs, links. It failed before the change. Thewasm32-wasip1build still links, now through the build script alone.extra_tests/snippets/stdlib_signal.pypasses on both binaries under wasmtime 47.0.4.wasm32-wasip2component that depends onrustpython-vmby git, withhost_env, links with no linker flags of its own, andsignal.raise_signal(signal.SIGINT)runs a Python handler in it.x86_64-unknown-linux-gnu: the test and Clippy commands fromAGENTS.md(workspace, andcrates/capi), CI's Clippy step with-Dwarnings, andcargo fmt --checkall 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-wasip2andwasm32-wasip1builds myself, and ran the signal snippet, a negative control and a SIGINT handler check on both binaries under wasmtime. Both commits carry anAssisted-bytrailer.🤖 Written by Claude Code (2.1.332) using model claude-opus-5-5
Summary by CodeRabbit