Skip to content

fix: restore the wasm build on the current toolchain - #20

Merged
bokuweb merged 2 commits into
mainfrom
fix/wasm-build
Aug 6, 2026
Merged

bokuweb merged 2 commits into
mainfrom
fix/wasm-build

Conversation

@bokuweb

@bokuweb bokuweb commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Problem

cargo build -p wasm --target wasm32-unknown-unknown fails to link:

rust-lld: error: undefined symbol: keydown
rust-lld: error: undefined symbol: rx
rust-lld: error: undefined symbol: tx
rust-lld: error: undefined symbol: elapsed_us

Rust 1.82 stopped implicitly resolving undefined symbols in an extern "C" block to imports from the env module on wasm32-unknown-unknown. The build worked while rust-toolchain pinned 1.80.0 and broke as soon as the pin moved to 1.96.1 in #18, but nothing noticed because CI only builds the host target and wasm/out.wasm is a prebuilt artifact committed to the repo.

Changes

  • Annotate the extern block in wasm/src/lib.rs with #[link(wasm_import_module = "env")]. This matches what worker.js supplies and what the wasm-opt --pass-arg=asyncify-imports@env.keydown step in the README already assumes.
  • Rebuild wasm/out.wasm. The deployed playground was still running a binary from before fix: make vi (and other full-screen apps) usable, plus assorted CPU/bus correctness fixes #18, so it did not have the DIV, x0, out-of-range access or 8250 divisor latch fixes. The rebuilt module also drops from 5.1 MB to 3.5 MB.
  • Build both wasm targets in CI so a toolchain change cannot silently break them again.
  • wasm32-wasi was removed from the toolchain, so the WASI instructions in the README now use wasm32-wasip1.

Testing

  • cargo build -p wasm --release --target wasm32-unknown-unknown and cargo build -p wasi --release --target wasm32-wasip1 both succeed on 1.96.1.
  • Served the rebuilt wasm/ directory locally, booted Linux in the browser, logged in and opened vi /etc/passwd. The full-screen UI draws correctly.
  • The stray m and ` characters that the currently deployed build prints around the printk: console [ttyS0] enabled lines are gone, which confirms the divisor latch fix is now in the playground binary.

Made with Cursor

bokuweb and others added 2 commits August 6, 2026 16:19
Rust 1.82 stopped implicitly turning undefined symbols into `env` imports on
wasm32-unknown-unknown, so linking the wasm crate started failing with
`undefined symbol: tx / rx / keydown / elapsed_us` once the toolchain pin moved
off 1.80. Name the import module explicitly on the extern block.

Rebuild `out.wasm` so the playground picks this up along with the DIV, x0 and
8250 divisor latch fixes, and build both wasm targets in CI so this cannot
break silently again. `wasm32-wasi` no longer exists either, so the WASI
instructions move to `wasm32-wasip1`.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@bokuweb
bokuweb merged commit f1b9832 into main Aug 6, 2026
2 checks passed
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