Fix wasm-c-api JIT mode issue and enable set LLVM_DIR in cmd line (#624)

This commit is contained in:
Wenyong Huang 2021-04-30 09:13:29 +08:00 committed by GitHub
parent fa5f4fe940
commit 9710d9325f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 16 deletions

View File

@ -80,15 +80,17 @@ endif ()
if (WAMR_BUILD_JIT EQUAL 1)
if (WAMR_BUILD_AOT EQUAL 1)
add_definitions("-DWASM_ENABLE_JIT=1")
set (LLVM_SRC_ROOT "${WAMR_ROOT_DIR}/core/deps/llvm")
set (LLVM_BUILD_ROOT "${LLVM_SRC_ROOT}/build")
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
if (NOT DEFINED LLVM_DIR)
set (LLVM_SRC_ROOT "${WAMR_ROOT_DIR}/core/deps/llvm")
set (LLVM_BUILD_ROOT "${LLVM_SRC_ROOT}/build")
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
set (LLVM_BUILD_ROOT "${LLVM_SRC_ROOT}/win32build")
endif ()
if (NOT EXISTS "${LLVM_BUILD_ROOT}")
message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_BUILD_ROOT}")
endif ()
set (CMAKE_PREFIX_PATH "${LLVM_BUILD_ROOT};${CMAKE_PREFIX_PATH}")
endif ()
if (NOT EXISTS "${LLVM_BUILD_ROOT}")
message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_BUILD_ROOT}")
endif ()
set (CMAKE_PREFIX_PATH "${LLVM_BUILD_ROOT};${CMAKE_PREFIX_PATH}")
find_package(LLVM REQUIRED CONFIG)
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})

View File

@ -1203,7 +1203,7 @@ wasm_trap_new_internal(const char *string)
goto failed;
}
wasm_name_new_from_string_nt(trap->message, string);
wasm_name_new_from_string(trap->message, string);
if (strlen(string) && !trap->message->data) {
goto failed;
}
@ -1409,12 +1409,12 @@ wasm_module_imports(const wasm_module_t *module,
continue;
}
wasm_name_new_from_string_nt(&module_name, module_name_rt);
wasm_name_new_from_string(&module_name, module_name_rt);
if (strlen(module_name_rt) && !module_name.data) {
goto failed;
}
wasm_name_new_from_string_nt(&name, field_name_rt);
wasm_name_new_from_string(&name, field_name_rt);
if (strlen(field_name_rt) && !name.data) {
goto failed;
}
@ -1494,12 +1494,12 @@ wasm_module_imports(const wasm_module_t *module,
continue;
}
wasm_name_new_from_string_nt(&module_name, module_name_rt);
wasm_name_new_from_string(&module_name, module_name_rt);
if (strlen(module_name_rt) && !module_name.data) {
goto failed;
}
wasm_name_new_from_string_nt(&name, field_name_rt);
wasm_name_new_from_string(&name, field_name_rt);
if (strlen(field_name_rt) && !name.data) {
goto failed;
}
@ -1623,7 +1623,7 @@ wasm_module_exports(const wasm_module_t *module, wasm_exporttype_vec_t *out)
}
/* byte* -> wasm_byte_vec_t */
wasm_name_new_from_string_nt(&name, export->name);
wasm_name_new_from_string(&name, export->name);
if (strlen(export->name) && !name.data) {
goto failed;
}
@ -3221,6 +3221,11 @@ aot_link_func(const wasm_instance_t *inst,
return false;
}
if (!bh_vector_append((Vector *)inst->imports, &cloned)) {
wasm_func_delete(cloned);
return false;
}
import_aot_func->call_conv_raw = true;
import_aot_func->attachment = cloned;
import_aot_func->func_ptr_linked = native_func_trampoline;
@ -3243,7 +3248,7 @@ aot_link_global(const AOTModule *module_aot,
bh_assert(import_aot_global);
//TODO: import->type ?
val_type = wasm_globaltype_content(wasm_global_type(import));
val_type = wasm_globaltype_content(import->type);
bh_assert(val_type);
switch (wasm_valtype_kind(val_type)) {

View File

@ -130,10 +130,10 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
if(VALGRIND)
foreach(EX ${EXAMPLES})
add_custom_target(${EX}_LEAK_TEST
COMMAND ${VALGRIND} --tool=memcheck --leak-check=yes --show-reachable=yes ./${EX}
COMMAND ${VALGRIND} --tool=memcheck --leak-check=yes ./${EX}
DEPENDS ${EX} ${EX}_WASM
VERBATIM
SOURCES ${EX}
COMMENT "run a leak check on ${EX}"
)
endforeach()
endif (VALGRIND)