Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions bazel/external/wamr.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
8 changes: 4 additions & 4 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions src/wamr/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
namespace proxy_wasm::wamr {

using WasmEnginePtr = common::CSmartPtr<wasm_engine_t, wasm_engine_delete>;
using WasmConfigPtr = common::CSmartPtr<wasm_config_t, wasm_config_delete>;
using WasmFuncPtr = common::CSmartPtr<wasm_func_t, wasm_func_delete>;
using WasmStorePtr = common::CSmartPtr<wasm_store_t, wasm_store_delete>;
using WasmModulePtr = common::CSmartPtr<wasm_module_t, wasm_module_delete>;
Expand Down
6 changes: 5 additions & 1 deletion src/wamr/wamr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ struct HostFuncData {
using HostFuncDataPtr = std::unique_ptr<HostFuncData>;

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();
}

Expand Down Expand Up @@ -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;
Expand Down