I'm currently trying to run wasmtime in a no_std environment with limited memory on RISC-V. To achieve that, I compile wasm binaries the following way:
wasmtime compile \
--target riscv64gc-unknown-none-elf \
-C collector=null \
-W threads=n \
-W component-model=n \
-W gc=n \
-W memory64=n \
my-app.wasm
I only have one memory section in my-app.wasm with the following layout: (memory (;0;) 17 20).
I then run my application like this:
let mut config = Config::new();
config.memory_reservation(4_294_967_296);
config.memory_guard_size(33554432);
config.signals_based_traps(true);
config.memory_init_cow(true);
config.wasm_memory64(false);
let engine = match Engine::new(&config) {
// ...
match Module::deserialize(&engine, file_buffer) {
// ...
As soon as my cwasm binary has a memory section, the linker seems to try to allocate 4GB of memory, which will not work on my machine - and which shouldn't be necessary.
However, if I set config.memory_reservation to anything other than 4GB, I get an error while building the module: Module was compiled with a memory reservation of '4294967296' but '33554432' is expected for the host
I don't see any way to compile the module with a different memory reservation, -W max-memory-size=<value> doesn't seem to have an impact either.
Is there a solution to this problem?
Last updated: Dec 06 2025 at 06:05 UTC