To produce a memory64 binary, you must target wasm64-unknown-unknown. Since this is a tier-3 target, you must provide a nightly toolchain and build std from source.
Option 1: Cargo Config (Recommended)
In .cargo/config.toml:
[build]
target = "wasm64-unknown-unknown"
[unstable]
build-std = ["std", "panic_abort"]
Option 2: Extra Cargo Arguments
Pass the target and build-std flags directly to cargo via wasm-pack:
wasm-pack build -- --target wasm64-unknown-unknown -Z build-std=std,panic_abort
Option 3: Environment Variable
CARGO_BUILD_TARGET=wasm64-unknown-unknown wasm-pack build
When wasm-pack detects a wasm64-* triple, it automatically verifies the nightly toolchain and passes --enable-memory64 to wasm-opt.
# .cargo/config.toml
[build]
target = "wasm64-unknown-unknown"
[unstable]
build-std = ["std", "panic_abort"]