crun icon indicating copy to clipboard operation
crun copied to clipboard

Running WASIp2 Components with crun+wasmtime supported?

Open t4chib4ne opened this issue 4 months ago • 4 comments

Hi,

I am currently having trouble running a WASIp2 component via crun with WASM support via wasmtime. The setup in use is basically a copy&paste of docs/wasm-wasi-example.md.

Upon running the image with podman the following error is printed:

WARNING: image platform (wasi/wasm) does not match the expected platform (linux/amd64)
[libcrun:wasmtime]: failed to compile module: failed to parse WebAssembly module

Caused by:
    expected a WebAssembly module but was given a WebAssembly component

I am not that proficient in C but it seems like the wasmtime handler only invokes functions compatible with WASIp1. Is WASIp2 with wasmtime supported by crun? Or could my instillation of libwasmtime.so be faulty?

Output of crun -V:

crun version 1.23.1
commit: d20b23dba05e822b93b82f2f34fd5dada433e0c2
rundir: /run/user/1000/crun
spec: 1.0.0
+SELINUX +APPARMOR +CAP +SECCOMP +EBPF +WASM:wasmtime +YAJL

Thanks for your help!

t4chib4ne avatar Sep 05 '25 20:09 t4chib4ne

@flouthoc PTAL

giuseppe avatar Sep 06 '25 21:09 giuseppe

Sorry that I wasn't patient enough to wait for flouthocs comment but I dug around a little in the wasmtime c-api and was able to get a basic WASM component running: https://github.com/t4chib4ne/crun/tree/wasip2

Maybe this could aid in creating a more proper implementation =)

t4chib4ne avatar Sep 09 '25 20:09 t4chib4ne

would it make sense to open a PR for crun and get that merged?

giuseppe avatar Sep 10 '25 08:09 giuseppe

Hm ... I guess it would make sense. I will do some cleanup and try implement missing features most notably argv is currently not passed to the component.

t4chib4ne avatar Sep 10 '25 18:09 t4chib4ne