WebAssembly target which uses 64-bit memories, relying on the memory64 WebAssembly proposal.
- Alex Crichton, https://github.com/alexcrichton
This target is cross-compiled. The target supports
std in the same manner as
wasm32-unknown-unknown target which is to say that it comes with the
standard library but many I/O functions such as
simply return error. Additionally I/O operations like
println! don't actually
do anything and the prints aren't routed anywhere. This is the same as the
wasm32-unknown-unknown target. This target comes by default with an allocator,
currently dlmalloc which is ported to rust.
The difference of this target with
wasm32-unknown-unknown is that it's
compiled for 64-bit memories instead of 32-bit memories. This means that
is 8-bytes large as well as pointers. The tradeoff, though, is that the maximum
memory size is now the full 64-bit address space instead of the 4GB as limited
by the 32-bit address space for
This target is not a stable target. The memory64 WebAssembly proposal is stil
in-progress and not standardized. This means that there are not many engines
which implement the
memory64 feature and if they do they're likely behind a
flag, for example:
- Nodejs -
- Wasmtime -
Also note that at this time the
wasm64-unknown-unknown target assumes the
presence of other merged wasm proposals such as (with their LLVM feature flags):
- Bulk memory -
- Mutable imported globals -
- Sign-extending operations -
- Non-trapping fp-to-int operations -
wasm64-unknown-unknown target intends to match the default Clang targets
"C" ABI, which is likely to be the same as Clang's
Note: due to the relatively early-days nature of this target when working with this target you may encounter LLVM bugs. If an assertion hit or a bug is found it's recommended to open an issue either with rust-lang/rust or ideally with LLVM itself.
This target does not support
panic=unwind at this time.
You can build Rust with support for the target by adding it to the
config.toml, and the target also requires
lld to be built to work.
[build] target = ["wasm64-unknown-unknown"] [rust] lld = true
Rust does not yet ship pre-compiled artifacts for this target. To compile for
this target, you will either need to build Rust with the target enabled (see
"Building the target" above), or build your own copy of
std by using
build-std or similar.
Note that the following
cfg directives are set for
cfg(target_arch = "wasm64")
cfg(target_family = "wasm")
Currently testing is not well supported for
wasm64-unknown-unknown and the
Rust project doesn't run any tests for this target. Testing support sort of
works but without
println! it's not the most exciting tests to run.
Compiling Rust code with C code for
wasm64-unknown-unknown is theoretically
possible, but there are no known toolchains to do this at this time. At the time
of this writing there is no known "libc" for wasm that works with
wasm64-unknown-unknown, which means that mixing C & Rust with this target
effectively cannot be done.