crowforkotlin
09/03/2026, 3:18 AMcrowforkotlin
09/03/2026, 3:20 AMcrowforkotlin
09/03/2026, 3:24 AMcrowforkotlin
09/03/2026, 3:33 AMJim Teichgräber
09/03/2026, 9:36 AMFirst, in a Kotlin/Wasm project, simply using @WasmImport or @WasmExport causes the generated Wasm binary size to bloat from a few KB to around 100–200 KB.I can't reproduce that. Both with 2.4.0, and 2.4.20-RC3, I get about 60 Bytes of size difference between
fun imexported(){
println("imexported")
}
and
@WasmExport
fun imexported(){
println("imexported")
}
The rest of the module is a few misc. tiny functions and a main. Also note that by the nature of WASI preview 1, any program that uses at least a println (or anything else that needs interaction with the environment) will already @WasmImport some WASI preview 1 functions implicitly.
(see attached pictures)
A size degradation from a few KB to hundred would definitely warrant an issue in our tracker, so if you can reproduce this failure and report it, that would be hugely appreciated :).
I can't really help with the Wasmtime/Cranelift issues. However, personally, I don't think that implementing a Wasm interpreter is in the scope of the Kotlin/Wasm project. There are many runtimes out there, and while we may not explicitly support all of them, any that support the Wasm extensions we need, should be able to run our modules (with WASI preview 2 / component model support, this will unfortunately narrow down as not as many runtimes support the CM).
For running on Android, Chasm may also be a good fit (cc @Igor Yakovlev who has experimented with running K/Wasm programs inside Chasm iirc).
A thought on the side: if Winch doesn't support certain features required by Kotlin/Wasm, then in my view the easiest approach, that still allows taking advantage of the rest of the Wasmtime infrastructure, would appear to be extending Winch with support for those features. Other than that, I can only recommend contacting the Wasmtime maintainers and discussing these JIT compilation issues with them.crowforkotlin
09/03/2026, 10:08 AM