Closed helje5 closed 3 years ago
I believe the default import object generates the latest WASI version:
You can use an older version of WASI with:
Version wasmer_wasi_get_version(const wasmer_module_t *module);
to get the version from the module and
wasmer_import_object_t *wasmer_wasi_generate_import_object_for_version(unsigned char version,
const wasmer_byte_array *args,
unsigned int args_len,
const wasmer_byte_array *envs,
unsigned int envs_len,
const wasmer_byte_array *preopened_files,
unsigned int preopened_files_len,
const wasmer_wasi_map_dir_entry_t *mapped_dirs,
unsigned int mapped_dirs_len);
to get the correct import object.
As an aside, we encourage you to migrate away from the deprecated C API if possible and to the standard Wasm C API wasmer_wasm.h
instead.
Could please mark deprecated API in big letters? E.g. this page mentions nothing about it being deprecated: https://github.com/wasmerio/wasmer-c-api
Presumably the solution shown here won't work either, because of issue #16 .
As per the discussion in the Slack. Wasm modules compiled w/
wasi_unstable
do not run w/ the C API. They need to be recompiled from scratch to work. This affects many if not all modules downloaded viawapm
as far as I can tell (e.g. cowsay or fortune, qjs etc).I was able to reproduce this within just this repo.
Steps I took:
.dylib
so that the linker picks up the .a (not sure it matters)test
Gives:
This is the modified sample:
It's a little disappointing since being able to run things anywhere is the stated advantage :-)