diff --git a/bazel/external/wamr.BUILD b/bazel/external/wamr.BUILD index 9ef6850e9..8c2955d57 100644 --- a/bazel/external/wamr.BUILD +++ b/bazel/external/wamr.BUILD @@ -20,7 +20,7 @@ cmake( "-GNinja", ] + select({ "@proxy_wasm_cpp_host//bazel:engine_wamr_jit": [ - "-DLLVM_DIR=$EXT_BUILD_DEPS/copy_llvm_13_0_1/llvm/lib/cmake/llvm", + "-DLLVM_DIR=$EXT_BUILD_DEPS/copy_llvm-15_0_7/llvm/lib/cmake/llvm", "-DWAMR_BUILD_AOT=1", "-DWAMR_BUILD_FAST_INTERP=0", "-DWAMR_BUILD_INTERP=0", @@ -42,7 +42,7 @@ cmake( }), out_static_libs = ["libvmlib.a"], deps = select({ - "@proxy_wasm_cpp_host//bazel:engine_wamr_jit": ["@llvm-13_0_1//:llvm_13_0_1_lib"], + "@proxy_wasm_cpp_host//bazel:engine_wamr_jit": ["@llvm-15_0_7//:llvm_wamr_lib"], "//conditions:default": [], }), ) diff --git a/bazel/external/wamr_llvm.BUILD b/bazel/external/wamr_llvm.BUILD index 0efdbc9b6..789e5a442 100644 --- a/bazel/external/wamr_llvm.BUILD +++ b/bazel/external/wamr_llvm.BUILD @@ -10,7 +10,7 @@ filegroup( ) cmake( - name = "llvm_13_0_1_lib", + name = "llvm_wamr_lib", cache_entries = { # Disable both: BUILD and INCLUDE, since some of the INCLUDE # targets build code instead of only generating build files. @@ -20,20 +20,16 @@ cmake( "LLVM_INCLUDE_DOCS": "off", "LLVM_BUILD_EXAMPLES": "off", "LLVM_INCLUDE_EXAMPLES": "off", - "LLVM_BUILD_RUNTIME": "off", - "LLVM_BUILD_RUNTIMES": "off", - "LLVM_INCLUDE_RUNTIMES": "off", "LLVM_BUILD_TESTS": "off", "LLVM_INCLUDE_TESTS": "off", "LLVM_BUILD_TOOLS": "off", "LLVM_INCLUDE_TOOLS": "off", - "LLVM_BUILD_UTILS": "off", - "LLVM_INCLUDE_UTILS": "off", "LLVM_ENABLE_IDE": "off", "LLVM_ENABLE_LIBEDIT": "off", "LLVM_ENABLE_LIBXML2": "off", "LLVM_ENABLE_TERMINFO": "off", "LLVM_ENABLE_ZLIB": "off", + "LLVM_ENABLE_ZSTD": "off", "LLVM_TARGETS_TO_BUILD": "X86", "CMAKE_CXX_FLAGS": "-Wno-unused-command-line-argument", }, @@ -133,4 +129,5 @@ cmake( "libLLVMSupport.a", "libLLVMDemangle.a", ], + working_directory = "llvm", ) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 764e4a38b..a49f01aad 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-2022-12-16 - sha256 = "976b928f420040a77e793051e4d742208adf157370b9ad0f5535e126adb31eb0", - strip_prefix = "wasm-micro-runtime-WAMR-1.1.2", - url = "https://github.com/bytecodealliance/wasm-micro-runtime/archive/WAMR-1.1.2.tar.gz", + # 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", ) native.bind( @@ -172,11 +172,11 @@ def proxy_wasm_cpp_host_repositories(): maybe( http_archive, - name = "llvm-13_0_1", + name = "llvm-15_0_7", build_file = "@proxy_wasm_cpp_host//bazel/external:wamr_llvm.BUILD", - sha256 = "ec6b80d82c384acad2dc192903a6cf2cdbaffb889b84bfb98da9d71e630fc834", - strip_prefix = "llvm-13.0.1.src", - url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.1/llvm-13.0.1.src.tar.xz", + sha256 = "8b5fcb24b4128cf04df1b0b9410ce8b1a729cb3c544e6da885d234280dedeac6", + strip_prefix = "llvm-project-15.0.7.src", + url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/llvm-project-15.0.7.src.tar.xz", ) # WasmEdge with dependencies. diff --git a/src/wamr/wamr.cc b/src/wamr/wamr.cc index e894df8f6..ea3d140e7 100644 --- a/src/wamr/wamr.cc +++ b/src/wamr/wamr.cc @@ -261,9 +261,15 @@ bool Wamr::link(std::string_view /*debug_name*/) { const wasm_name_t *name_ptr = wasm_importtype_name(import_types.get()->data[i]); const wasm_externtype_t *extern_type = wasm_importtype_type(import_types.get()->data[i]); - std::string_view module_name(module_name_ptr->data, module_name_ptr->size); - std::string_view name(name_ptr->data, name_ptr->size); - assert(name_ptr->size > 0); + if (std::strlen(name_ptr->data) == 0) { + fail(FailState::UnableToInitializeCode, std::string("The name field of import_types[") + + std::to_string(i) + std::string("] is empty")); + return false; + } + + std::string_view module_name(module_name_ptr->data); + std::string_view name(name_ptr->data); + switch (wasm_externtype_kind(extern_type)) { case WASM_EXTERN_FUNC: { auto it = host_functions_.find(std::string(module_name) + "." + std::string(name)); @@ -354,8 +360,7 @@ bool Wamr::link(std::string_view /*debug_name*/) { case WASM_EXTERN_FUNC: { WasmFuncPtr func = wasm_func_copy(wasm_extern_as_func(actual_extern)); const wasm_name_t *name_ptr = wasm_exporttype_name(export_types.get()->data[i]); - module_functions_.insert_or_assign(std::string(name_ptr->data, name_ptr->size), - std::move(func)); + module_functions_.insert_or_assign(std::string(name_ptr->data), std::move(func)); } break; case WASM_EXTERN_GLOBAL: { // TODO(mathetake): add support when/if needed.