Skip to content

Add wasm64-unknown-unknown target support#1553

Open
audreyt wants to merge 1 commit intodrager:masterfrom
audreyt:main
Open

Add wasm64-unknown-unknown target support#1553
audreyt wants to merge 1 commit intodrager:masterfrom
audreyt:main

Conversation

@audreyt
Copy link

@audreyt audreyt commented Feb 26, 2026

Summary

Extend wasm-pack to support wasm64-unknown-unknown targets alongside existing wasm32 support, enabling wasm-pack build and wasm-pack test to work with WebAssembly memory64 modules.

Closes #1464.

Motivation

The WebAssembly memory64 proposal has reached standardization phase, and Rust nightly ships a wasm64-unknown-unknown target. The underlying toolchain now has wasm-bindgen#5004 implements for memory64 codegen support, and downstream getrandom has a corresponding PR at getrandom#819. wasm-pack is the last piece: its build and test pipelines hardcode wasm32-unknown-unknown as the target triple, so wasm-pack build --target wasm64-unknown-unknown silently ignores the user's intent.

Changes

5 files changed (+49 −29) — all mechanical plumbing to thread the target triple through instead of hardcoding it:

  • src/build/mod.rs — Parameterize cargo_build_wasm() and cargo_build_wasm_tests() to accept a target_triple argument instead of hardcoding wasm32-unknown-unknown via CARGO_BUILD_TARGET
  • src/command/build.rs — Pass self.target_triple through to cargo_build_wasm(); add --enable-memory64 to wasm-opt args when the target starts with wasm64
  • src/command/test.rs — Extract --target from extra_options (defaulting to wasm32-unknown-unknown); construct CARGO_TARGET_<TRIPLE>_RUNNER env var dynamically instead of hardcoding CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER; thread target_triple through to all test steps (node, Chrome, Firefox, Safari) and webdriver_env()
  • src/test/mod.rs — Parameterize cargo_test_wasm() to accept target_triple and pass it to cargo test --target
  • src/manifest/mod.rs — Generalize the cdylib error message from "wasm32-unknown-unknown" to "WebAssembly"

Usage

# Build
wasm-pack build --target web -- --target wasm64-unknown-unknown

# Test
wasm-pack test --node -- --target wasm64-unknown-unknown

The -- --target wasm64-unknown-unknown is passed through as a Cargo extra option. When omitted, behavior is unchanged (wasm32-unknown-unknown).

Testing

  • Verified wasm-pack build with wasm32 targets is unchanged (no regressions)
  • Validated end-to-end with a real-world project (web-rwkv) compiled to wasm64-unknown-unknown — a 1.7B parameter LLM inference engine that requires >4 GB memory

- Parameterize target triple in cargo_build_wasm() and cargo_build_wasm_tests()
- Extract --target from extra_options in build and test commands
- Add --enable-memory64 to wasm-opt args for wasm64 targets
- Construct CARGO_TARGET_*_RUNNER env var dynamically from target triple
- Pass target triple through to cargo_test_wasm()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

wasm64-unknown-unknown support

1 participant