Hello,
I have a project where I integrated both WASMTime and now working on adding WAMR as well. I need both for ... reasons :grinning:.
That being said, it seems that WAMR has a similar but not identical API with WASMTIME.
More specifically, adding import functions to WAMR is not really supported in the same way. I can create a wasm_func_t
from the imports of a module that's bound to my native function, but then it's unclear how to link this to a WAMR module.
Is wasm_register_natives
the only way we can register imports after instantiation?
I tried adding the fucntions as externs to: wasm_instance_new
, but this is expecting that the module imports list is identical with the imports
parameter. For a module that's using WASI as well as custom methods this is impossible :grinning:
For reference, I will add some information here about linking in WAMR as it is different than in other VMs:
1) WAMR allows missing imports in a wasm module (this is actually a nice feature).
2) wasm_runtime_register_natives_raw
or without the raw
is the way to add functions that are searched at link time. Be sure to call this before module initialization. This method doesn't need wasm_extern_t*
so that's nice.
WAMR supports two kinds of linkage. The WASM-C-API way and a WAMR private runtime linking. It is better not to use them mixed.
WAMR renames the header of WASM-C-API as wasm_c_api.h. What WARM did in Envoy is a reference for that: Wamr::link.
If we called the WASM-C-API linkage manually, WARM private runtime linking is automatic. WARM will search all imports in the user-provided search path with module names and imported item names. There is an example here.
Thank you, i ended up getting what. i want from it eventually. The thing that confused me is that this wasm_c_api
and wasm_export.h
look so close to what wasmtime has, that it has confused me. :grinning:
Last updated: Dec 23 2024 at 12:05 UTC