diff --git a/bazel/external/wamr.BUILD b/bazel/external/wamr.BUILD index 8c2955d57..0d2d5ff4b 100644 --- a/bazel/external/wamr.BUILD +++ b/bazel/external/wamr.BUILD @@ -12,11 +12,22 @@ filegroup( cmake( name = "wamr_lib", generate_args = [ + # disable WASI "-DWAMR_BUILD_LIBC_WASI=0", - "-DWAMR_BUILD_MULTI_MODULE=0", + "-DWAMR_BUILD_LIBC_BUILTIN=0", + # MVP + "-DWAMR_BUILD_BULK_MEMORY=1", + "-DWAMR_BUILD_REF_TYPES=1", + "-DWAMR_BUILD_SIMD=1", "-DWAMR_BUILD_TAIL_CALL=1", - "-DWAMR_DISABLE_HW_BOUND_CHECK=0", - "-DWAMR_DISABLE_STACK_HW_BOUND_CHECK=1", + # name section + "-DWAMR_BUILD_CUSTOM_NAME_SECTION=1", + "-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1", + # trap information + "-DWAMR_BUILD_DUMP_CALL_STACK=1", + # others + "-DWAMR_BUILD_MULTI_MODULE=0", + "-DWAMR_BUILD_WASM_CACHE=0", "-GNinja", ] + select({ "@proxy_wasm_cpp_host//bazel:engine_wamr_jit": [ diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 57d12a2d3..e395d6135 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -159,10 +159,10 @@ def proxy_wasm_cpp_host_repositories(): http_archive, name = "com_github_bytecodealliance_wasm_micro_runtime", build_file = "@proxy_wasm_cpp_host//bazel/external:wamr.BUILD", - # WAMR-1.2.1 - sha256 = "7548d4bbea8dbb9b005e83bd571f93a12fb3f0b5e87a8b0130f004dd92df4b0b", - strip_prefix = "wasm-micro-runtime-WAMR-1.2.1", - url = "https://github.com/bytecodealliance/wasm-micro-runtime/archive/refs/tags/WAMR-1.2.1.zip", + # WAMR-1.3.1 + sha256 = "4e34db792332f385fd479e1265d5eaa56705d7cf7ff3fd7734f536466aa29355", + strip_prefix = "wasm-micro-runtime-WAMR-1.3.1", + url = "https://github.com/bytecodealliance/wasm-micro-runtime/archive/refs/tags/WAMR-1.3.1.zip", ) native.bind( diff --git a/src/wamr/types.h b/src/wamr/types.h index 7252c5c3d..ba5595cfb 100644 --- a/src/wamr/types.h +++ b/src/wamr/types.h @@ -18,6 +18,7 @@ namespace proxy_wasm::wamr { using WasmEnginePtr = common::CSmartPtr; +using WasmConfigPtr = common::CSmartPtr; using WasmFuncPtr = common::CSmartPtr; using WasmStorePtr = common::CSmartPtr; using WasmModulePtr = common::CSmartPtr; diff --git a/src/wamr/wamr.cc b/src/wamr/wamr.cc index ea3d140e7..262fc9b91 100644 --- a/src/wamr/wamr.cc +++ b/src/wamr/wamr.cc @@ -47,7 +47,10 @@ struct HostFuncData { using HostFuncDataPtr = std::unique_ptr; wasm_engine_t *engine() { - static const auto engine = WasmEnginePtr(wasm_engine_new()); + static auto engine_config = WasmConfigPtr(wasm_config_new()); + // it is able to use wasm_config_set_xxx() to adjust wamr runtime features + // like: wasm_config_set_linux_perf_opt(engine_config.get(), true); + static const auto engine = WasmEnginePtr(wasm_engine_new_with_config(engine_config.get())); return engine.get(); } @@ -130,6 +133,7 @@ bool Wamr::load(std::string_view bytecode, std::string_view /*precompiled*/, .num_elems = bytecode.size(), .size_of_elem = sizeof(byte_t), .lock = nullptr}; + module_ = wasm_module_new(store_.get(), &binary); if (module_ == nullptr) { return false;