mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-06 06:55:07 +00:00
76d641c7ea
The WASM C API now requires the use of vector types in certain apis. Switching WAMR to use the new call signatures improves "drop in" compilation compatibility between WAMR and other implementations from a C-api embedding program's perspective. * wasm_func_callback_t type has been updated to use wasm_val_vec_t * wasm_func_callback_with_env_t type has been updated to use wasm_val_vec_t * wasm_func_call() has been updated to use wasm_val_vec_t * wasm_instance_new() has been updated to use wasm_extern_vec_t* * wasm_instance_new_with_args() has been updated to use wasm_extern_vec_t* * wasm_runtime_invoke_c_api_native() has been updated to support vector types in native callbacks without modifying the contract with the interpreter code. * All users of the modified functions (including samples/wasm-c-api/src/*.c) have been appropriately updated. |
||
---|---|---|
.. | ||
src | ||
CMakeLists.txt | ||
README.md |
WAMR supports wasm-c-api in both interpreter mode and aot mode.
Before staring, we need to download and intall WABT.
$ cd /opt
$ wget https://github.com/WebAssembly/wabt/releases/download/1.0.19/wabt-1.0.19-ubuntu.tar.gz
$ tar -xzf wabt-1.0.19-ubuntu.tar.gz
$ mv wabt-1.0.19 wabt
By default, all samples are compiled and run in "interpreter" mode.
$ mkdir build
$ cd build
$ cmake ..
$ make
$ # it will build a library with c-api supporting.
$ # Also copy *.wasm from ../src/
$ # and generate executable files
$ # now, it is ok to run samples
$ ./hello
$ ...
$ ./global
$ ...
$ ./callback
$ ...
They can be compiled and run in aot mode when some compiling flags are given.
$ mkdir build
$ cd build
$ cmake -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_AOT=1 ..
$ make
$ # it will build a library with c-api supporting.
$ # Also copy *.wasm from ../src/
$ # and transform *.wasm to *.aot
$ # and generate executable files
$ # now, it is ok to run samples
$ ./hello
$ ...
$ ./global
$ ...
$ ./callback
$ ...