MASM (Microsoft Macro Assembler) needs to be enabled to successfully
compile .asm files on Windows. Without enabling this language
automatically in runtime_lib.cmake, Windows cmake projects using WAMR
get hard-to-diagnose linker errors about missing symbols as the assembly
file is not compiled at all.
Add nightly (UTC time) checks with asan and ubsan, and also put gcc-4.8 build
to nightly run since we don't need to run it with every PR.
Co-authored-by: Maksim Litskevich <makslit@amazon.co.uk>
Upgrade the version of related toolkits:
- upgrade llvm to 15.0
- upgrade wasi-sdk to 19.0
- upgrade emsdk to 3.1.28
- upgrade wabt to 1.0.31
- upgrade binaryen to 111
And upgrade the CI scripts, sample workload build scripts, Dockerfiles, and documents.
Use sha256 to hash binary file content. If the incoming wasm binary is
cached before, wasm_module_new() simply returns the existed one.
Use -DWAMR_BUILD_WASM_CACHE=0/1 to control the feature.
OpenSSL 1.1.1 is required if the feature is enabled.
Fix build error in sample ref-types and wasm-c-api caused by the
version of wat2wasm: refine makefile to auto detect the wat2wasm
version and add the compile flag accordingly.
Allow to have multiple stores in an engine and multiple instances
in a store. Letting a wasm_function_t pass its wasm_store_t to make
it more efficient.
Refactor the layout of interpreter and AOT module instance:
- Unify the interp/AOT module instance, use the same WASMModuleInstance/
WASMMemoryInstance/WASMTableInstance data structures for both interpreter
and AOT
- Make the offset of most fields the same in module instance for both interpreter
and AOT, append memory instance structure, global data and table instances to
the end of module instance for interpreter mode (like AOT mode)
- For extra fields in WASM module instance, use WASMModuleInstanceExtra to
create a field `e` for interpreter
- Change the LLVM JIT module instance creating process, LLVM JIT uses the WASM
module and module instance same as interpreter/Fast-JIT mode. So that Fast JIT
and LLVM JIT can access the same data structures, and make it possible to
implement the Multi-tier JIT (tier-up from Fast JIT to LLVM JIT) in the future
- Unify some APIs: merge some APIs for module instance and memory instance's
related operations (only implement one copy)
Note that the AOT ABI is same, the AOT file format, AOT relocation types, how AOT
code accesses the AOT module instance and so on are kept unchanged.
Refer to:
https://github.com/bytecodealliance/wasm-micro-runtime/issues/1384
Upgrade `cmake_minimum_required` from `(VERSION 2.8)` to `(VERSION 2.9)` to
yield the warning:
"Compatibility with CMake < 2.8.12 will be removed from a future version of CMake"
Add "-Wno-unused" for CMAKE_CXX_FLAGS to yield the compilation warnings
when build LLVM JIT.
Fix the link error when code coverage is enabled.
When WAMR_BUILD_TARGET isn't set, choosing right target is decided
by checking `CMAKE_SIZEOF_VOID_P` variable. However, choosing `X86_32`
target is not doing specifically checking size of void pointer. It is kind
a fallback target for others.
This patch explicitly checks the size of void pointer before setting the target
to `X86_32` to fix the issue.
Re-implement socket api send/recv in an atomic-like way, fix the return value
check in posix.c.
And fix wasm-c-api sample callback_chain calling malloc issue.
wasm_c_api.c: add more checks, fix LOG_WARNING invalid specifier
aot_emit_aot_file: fix strncpy max size length to copy
posix.c: fix potential socket not close issue
wasm-c-api samples: add return value checks for fseek/ftell
cJSON.c: remove dead code
Currently when calling wasm_runtime_call_wasm() to invoke wasm function
with externref type argument from runtime embedder, developer needs to
use wasm_externref_obj2ref() to convert externref obj into an internal ref
index firstly, which is not convenient to developer.
To align with GC feature in which all the references passed to
wasm_runtime_call_wasm() can be object pointers directly, we change the
interface of wasm_runtime_call_wasm() to allow to pass object pointer
directly for the externref argument, and refactor the related codes, update
the related samples and the document.
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.
Allow empty import array (but not NULL) for wasm-c-api wasm_instance_new,
which makes the code more robust, especially in use cases where imports
might be constructed dynamically.
And add a test case in samples/wasm-c-api/src/empty_imports.c to test it.
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.
Fix compile errors of workloads due to emsdk version upgrade,
enable BUILD_TARGET auto set for some samples,
and call wasm_runtime_init_thread_env() for in thread routine which
was created by pthread_create but not runtime in spawn-thread sample.
Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
And enable to cache compiled AOT file buffer for wasm-c-api JIT mode
Avoid checks that rely on undefined C behavior
Fix issues of wasm-c-api sample trap and callback_chain
Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
And enable to copy back the return value of wasm main function when calling wasm_application_execute_main, add license headers in wasm-c-api samples, fix several issues reported by klocwork.
Implement more wasm-c-api APIs to support Envoy integration:
- sync up with latest c-api definition
- change CMakeLists to export necessary headers and install the static library of iwasm
- enable to export tables and memories
- support memorytype and tabletype APIs
- update wasm-c-api sampels
- enable to export importtype APIs
And refine bazel scripts for sample XNNPACK workload, add license headers for sample simple.
Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
In some platforms, allocating memory with size 0 may return NULL but not an empty memory block, which causes runtime load, instantiate or execute wasm/aot file failed. We add checks to try to avoid allocating memory in runtime if the size is 0. And in wasm_runtime_malloc/free, output warning if allocate memory with size 0 and free memory with NULL ptr.
Also fix some coding style issues, fix handle riscv32 ilp32d issue, and fix several wasm-c-api issues.
Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
* Add Windows support for C-API and Runtime API libraries and examples.
Signed-off-by: Wu Zhongmin <vwzm@live.com>
Signed-off-by: Xiaokang Qin <xiaokang.qxk@antgroup.com>
* Address the review comments
Signed-off-by: Xiaokang Qin <xiaokang.qxk@antgroup.com>
* Rewrite the the bh_getopt to make it avaliable for more kinds of options
Signed-off-by: Wu Zhongmin <vwzm@live.com>
Signed-off-by: Xiaokang Qin <xiaokang.qxk@antgroup.com>
* Add the license header
Signed-off-by: Xiaokang Qin <xiaokang.qxk@antgroup.com>
Co-authored-by: Zhongmin Wu <vwzm@live.com>
Fix the build issues on mac for basic/multi-module/multi-thread/
simple/spawn-thread/wasm-c-api under samples.
And all these samples could be run as expected.
Signed-off-by: Xiaokang Qin <xiaokang.qxk@antgroup.com>