Skip to content

fix(wasm): declare audit host import module to fix WASM link - #38

Merged
mostafa merged 2 commits into
mainfrom
fix/wasm-audit-import
Jun 16, 2026
Merged

mostafa merged 2 commits into
mainfrom
fix/wasm-audit-import

Conversation

@mostafa

@mostafa mostafa commented Jun 10, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #37. The Build WASM job's "Rebuild core.wasm" step fails at link with rust-lld: error: undefined symbol: ressrf_host_audit_event, reddening every PR's CI.

The ressrf_host_audit_event audit host import was declared as a bare extern "C" block with no explicit wasm_import_module. Older wasm-ld leniently treated it as an allowed env import, but the newer toolchain tightened undefined-symbol handling and now errors on it. Same Rust code that linked green on 6-08 fails on a Go-only diff two days later, confirming toolchain drift rather than a code regression.

This applies candidate fix (a) from the issue, the explicit extern import declaration, instead of pinning the toolchain:

  • Add #[link(wasm_import_module = "env")] to the extern "C" block so the symbol is emitted as a real WebAssembly import that wasm-ld resolves as a host import.
  • The env module matches both host runtimes already in the tree: wazero's NewHostModuleBuilder("env") on the Go side and the env import object on the Node side.
  • Regenerate the committed core.wasm artifacts (go/ressrf/core.wasm, node/core.wasm).

Test plan

  • Reproduced the original link failure locally on rustc 1.96.0
  • WASM build links cleanly; emitted module contains (import "env" "ressrf_host_audit_event" ...) and it survives wasm-opt -Oz
  • Go tests pass (209) including the audit callback round-trip through wazero
  • Node tests pass (206) including the audit callback through the env import object
  • cargo fmt --all -- --check, cargo clippy -p ressrf-wasm --all-targets --all-features -- -D warnings, and a RUSTFLAGS=-Dwarnings WASM build are all clean

mostafa and others added 2 commits June 10, 2026 18:09
The `ressrf_host_audit_event` host import was declared as a bare
`extern "C"` block with no explicit `wasm_import_module`. Older
`wasm-ld` leniently treated it as an `env` import, but the newer
toolchain tightened undefined-symbol handling and fails the link with
`undefined symbol: ressrf_host_audit_event`, reddening every PR.

Add `#[link(wasm_import_module = "env")]` so the symbol is emitted as a
real WebAssembly import. The `env` module matches both host runtimes:
wazero's `NewHostModuleBuilder("env")` on the Go side and the `env`
import object on the Node side.

Regenerate the committed `core.wasm` artifacts.

Fixes #37
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ mostafa
❌ github-actions[bot]
You have signed the CLA already but the status is still pending? Let us recheck it.

@mostafa
mostafa requested a review from gonzaloserrano June 10, 2026 16:16
@mostafa
mostafa merged commit f38e672 into main Jun 16, 2026
1 check was pending
@mostafa
mostafa deleted the fix/wasm-audit-import branch June 16, 2026 09:08
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.

Build WASM: rust-lld "undefined symbol: ressrf_host_audit_event" (toolchain drift, every PR red)

3 participants