This repository has been archived on 2023-11-05. You can view files and clone it, but cannot push or open issues or pull requests.
wasm-micro-runtime/samples/wasm-c-api
liang.he 1dccf39d16
Enable ref types and bulk memory by default for wamrc (#838)
Enable ref types feature and bulk memory feature by default for wamrc
and provide "--disable-ref-types", "--disable-bulk-memory"  to disable
them.
And remove the ref_type_flag option in wasm_loader.c which is used to
control whether to enable ref types or not when ENABLE_REF_TYPES
macro is enabled in wamrc. As the wasm binary format with ref types
is compatible with the binary format before, we can remove the option.
Also update the spec test scripts.
2021-11-18 17:42:49 +08:00
..
src Allow empty import array for wasm-c-api wasm_instance_new (#782) 2021-10-12 16:06:38 +08:00
CMakeLists.txt Enable ref types and bulk memory by default for wamrc (#838) 2021-11-18 17:42:49 +08:00
README.md Enable multi-module support for wasm-c-api (#426) 2020-10-16 17:43:57 +08:00

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
$ ...