mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-03-11 16:35:33 +00:00
Fix some compilation warnings and enable Windows JIT (#586)
This commit is contained in:
parent
a4e4d4198f
commit
02d27e13ee
|
@ -79,10 +79,14 @@ 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")
|
||||
if (NOT EXISTS "${LLVM_SRC_ROOT}/build")
|
||||
message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/build")
|
||||
set (LLVM_BUILD_ROOT "${LLVM_SRC_ROOT}/build")
|
||||
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
|
||||
set (LLVM_BUILD_ROOT "${LLVM_SRC_ROOT}/win32build")
|
||||
endif ()
|
||||
set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/build;${CMAKE_PREFIX_PATH}")
|
||||
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})
|
||||
|
|
|
@ -574,7 +574,7 @@ load_table_init_data_list(const uint8 **p_buf, const uint8 *buf_end,
|
|||
data_list[i]->offset.init_expr_type = (uint8)init_expr_type;
|
||||
data_list[i]->offset.u.i64 = (int64)init_expr_value;
|
||||
data_list[i]->func_index_count = func_index_count;
|
||||
read_byte_array(buf, buf_end, data_list[i]->func_indexes, size1);
|
||||
read_byte_array(buf, buf_end, data_list[i]->func_indexes, (uint32)size1);
|
||||
}
|
||||
|
||||
*p_buf = buf;
|
||||
|
@ -1444,7 +1444,7 @@ do_text_relocation(AOTModule *module,
|
|||
bh_memcpy_s(xmm_buf, sizeof(xmm_buf),
|
||||
symbol + strlen(XMM_PLT_PREFIX) + 16, 16);
|
||||
if (!str2uint64(xmm_buf, (uint64*)symbol_addr)) {
|
||||
set_error_buf_v(error_buf, error_buf,
|
||||
set_error_buf_v(error_buf, error_buf_size,
|
||||
"resolve symbol %s failed", symbol);
|
||||
goto check_symbol_fail;
|
||||
}
|
||||
|
@ -1452,7 +1452,7 @@ do_text_relocation(AOTModule *module,
|
|||
bh_memcpy_s(xmm_buf, sizeof(xmm_buf),
|
||||
symbol + strlen(XMM_PLT_PREFIX), 16);
|
||||
if (!str2uint64(xmm_buf, (uint64*)((uint8*)symbol_addr + 8))) {
|
||||
set_error_buf_v(error_buf, error_buf,
|
||||
set_error_buf_v(error_buf, error_buf_size,
|
||||
"resolve symbol %s failed", symbol);
|
||||
goto check_symbol_fail;
|
||||
}
|
||||
|
@ -1468,7 +1468,7 @@ do_text_relocation(AOTModule *module,
|
|||
bh_memcpy_s(real_buf, sizeof(real_buf),
|
||||
symbol + strlen(REAL_PLT_PREFIX), 16);
|
||||
if (!str2uint64(real_buf, (uint64*)symbol_addr)) {
|
||||
set_error_buf_v(error_buf, error_buf,
|
||||
set_error_buf_v(error_buf, error_buf_size,
|
||||
"resolve symbol %s failed", symbol);
|
||||
goto check_symbol_fail;
|
||||
}
|
||||
|
@ -1484,7 +1484,7 @@ do_text_relocation(AOTModule *module,
|
|||
bh_memcpy_s(float_buf, sizeof(float_buf),
|
||||
symbol + strlen(REAL_PLT_PREFIX), 8);
|
||||
if (!str2uint32(float_buf, (uint32*)symbol_addr)) {
|
||||
set_error_buf_v(error_buf, error_buf,
|
||||
set_error_buf_v(error_buf, error_buf_size,
|
||||
"resolve symbol %s failed", symbol);
|
||||
goto check_symbol_fail;
|
||||
}
|
||||
|
@ -2306,7 +2306,8 @@ aot_load_from_comp_data(AOTCompData *comp_data, AOTCompContext *comp_ctx,
|
|||
goto fail1;
|
||||
}
|
||||
|
||||
bh_memcpy_s(module->memories, size, comp_data->memories, size);
|
||||
bh_memcpy_s(module->memories, (uint32)size,
|
||||
comp_data->memories, (uint32)size);
|
||||
}
|
||||
|
||||
module->mem_init_data_list = comp_data->mem_init_data_list;
|
||||
|
|
|
@ -777,7 +777,7 @@ wasm_runtime_deinstantiate_internal(WASMModuleInstanceCommon *module_inst,
|
|||
void
|
||||
wasm_runtime_deinstantiate(WASMModuleInstanceCommon *module_inst)
|
||||
{
|
||||
return wasm_runtime_deinstantiate_internal(module_inst, false);
|
||||
wasm_runtime_deinstantiate_internal(module_inst, false);
|
||||
}
|
||||
|
||||
WASMExecEnv *
|
||||
|
@ -1962,7 +1962,7 @@ wasm_runtime_init_wasi(WASMModuleInstanceCommon *module_inst,
|
|||
|
||||
fail:
|
||||
if (envp)
|
||||
wasm_runtime_free(envp);
|
||||
wasm_runtime_free((void*)envp);
|
||||
|
||||
if (init_options.preopens)
|
||||
wasm_runtime_free(init_options.preopens);
|
||||
|
|
|
@ -83,7 +83,7 @@ aot_compile_simd_i8x16_arith(AOTCompContext *comp_ctx,
|
|||
|
||||
return simd_v128_integer_arith(comp_ctx, func_ctx, arith_op, lhs, rhs);
|
||||
fail:
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -105,7 +105,7 @@ aot_compile_simd_i16x8_arith(AOTCompContext *comp_ctx,
|
|||
|
||||
return simd_v128_integer_arith(comp_ctx, func_ctx, arith_op, lhs, rhs);
|
||||
fail:
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -127,7 +127,7 @@ aot_compile_simd_i32x4_arith(AOTCompContext *comp_ctx,
|
|||
|
||||
return simd_v128_integer_arith(comp_ctx, func_ctx, arith_op, lhs, rhs);
|
||||
fail:
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -1909,8 +1909,8 @@ wasm_enlarge_memory(WASMModuleInstance *module, uint32 inc_page_count)
|
|||
return false;
|
||||
|
||||
memory_data = memory->memory_data;
|
||||
heap_size = memory->heap_data_end - memory->heap_data;
|
||||
total_size_old = memory->memory_data_end - memory_data;
|
||||
heap_size = (uint32)(memory->heap_data_end - memory->heap_data);
|
||||
total_size_old = (uint32)(memory->memory_data_end - memory_data);
|
||||
total_page_count = inc_page_count + memory->cur_page_count;
|
||||
total_size = memory->num_bytes_per_page * (uint64)total_page_count;
|
||||
heap_data_old = memory->heap_data;
|
||||
|
|
|
@ -647,7 +647,7 @@ static uint32
|
|||
strcpy_wrapper(wasm_exec_env_t exec_env, char *dst, const char *src)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
uint32 len = strlen(src) + 1;
|
||||
uint32 len = (uint32)strlen(src) + 1;
|
||||
|
||||
/* src has been checked by runtime */
|
||||
if (!validate_native_addr(dst, len))
|
||||
|
@ -712,7 +712,7 @@ free_wrapper(wasm_exec_env_t exec_env, void *ptr)
|
|||
if (!validate_native_addr(ptr, sizeof(uint32)))
|
||||
return;
|
||||
|
||||
return module_free(addr_native_to_app(ptr));
|
||||
module_free(addr_native_to_app(ptr));
|
||||
}
|
||||
|
||||
static int32
|
||||
|
|
|
@ -6,12 +6,14 @@
|
|||
#include "bh_vector.h"
|
||||
|
||||
static uint8*
|
||||
alloc_vector_data(uint32 length, uint32 size_elem)
|
||||
alloc_vector_data(size_t length, size_t size_elem)
|
||||
{
|
||||
uint64 total_size = ((uint64)size_elem) * length;
|
||||
uint8 *data;
|
||||
|
||||
if (total_size > UINT32_MAX) {
|
||||
if (length > UINT32_MAX
|
||||
|| size_elem > UINT32_MAX
|
||||
|| total_size > UINT32_MAX) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -23,7 +25,7 @@ alloc_vector_data(uint32 length, uint32 size_elem)
|
|||
}
|
||||
|
||||
static bool
|
||||
extend_vector(Vector *vector, uint32 length)
|
||||
extend_vector(Vector *vector, size_t length)
|
||||
{
|
||||
uint8 *data;
|
||||
|
||||
|
@ -45,7 +47,7 @@ extend_vector(Vector *vector, uint32 length)
|
|||
}
|
||||
|
||||
bool
|
||||
bh_vector_init(Vector *vector, uint32 init_length, uint32 size_elem)
|
||||
bh_vector_init(Vector *vector, size_t init_length, size_t size_elem)
|
||||
{
|
||||
if (!vector) {
|
||||
LOG_ERROR("Init vector failed: vector is NULL.\n");
|
||||
|
@ -104,7 +106,7 @@ bool bh_vector_get(const Vector *vector, uint32 index, void *elem_buf)
|
|||
|
||||
bool bh_vector_insert(Vector *vector, uint32 index, const void *elem_buf)
|
||||
{
|
||||
uint32 i;
|
||||
size_t i;
|
||||
uint8 *p;
|
||||
|
||||
if (!vector || !elem_buf) {
|
||||
|
@ -182,7 +184,7 @@ bh_vector_remove(Vector *vector, uint32 index, void *old_elem_buf)
|
|||
return true;
|
||||
}
|
||||
|
||||
uint32
|
||||
size_t
|
||||
bh_vector_size(const Vector *vector)
|
||||
{
|
||||
return vector ? vector->num_elems : 0;
|
||||
|
|
|
@ -35,7 +35,7 @@ typedef struct Vector {
|
|||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool
|
||||
bh_vector_init(Vector *vector, uint32 init_length, uint32 size_elem);
|
||||
bh_vector_init(Vector *vector, size_t init_length, size_t size_elem);
|
||||
|
||||
/**
|
||||
* Set element of vector
|
||||
|
@ -104,7 +104,7 @@ bh_vector_remove(Vector *vector, uint32 index, void *old_elem_buf);
|
|||
*
|
||||
* @return return the size of the vector
|
||||
*/
|
||||
uint32
|
||||
size_t
|
||||
bh_vector_size(const Vector *vector);
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#ifndef __GNUC__
|
||||
|
||||
#include "bh_getopt.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
char* optarg = NULL;
|
||||
|
@ -14,7 +15,6 @@ int optind = 1;
|
|||
int getopt(int argc, char *const argv[], const char *optstring)
|
||||
{
|
||||
static int sp = 1;
|
||||
int c;
|
||||
int opt;
|
||||
char *p;
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ endif ()
|
|||
|
||||
if (NOT DEFINED WAMR_BUILD_FAST_INTERP)
|
||||
# Enable fast interpreter
|
||||
set (WAMR_BUILD_FAST_INTERP 1)
|
||||
set (WAMR_BUILD_FAST_INTERP 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_MULTI_MODULE)
|
||||
|
|
69
product-mini/platforms/windows/build_llvm.py
Normal file
69
product-mini/platforms/windows/build_llvm.py
Normal file
|
@ -0,0 +1,69 @@
|
|||
#
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
#
|
||||
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
def clone_llvm():
|
||||
llvm_dir = Path("llvm")
|
||||
if(llvm_dir.exists() == False):
|
||||
print("Clone llvm to core/deps/ ..")
|
||||
for line in os.popen("git clone --branch release/11.x https://github.com/llvm/llvm-project.git llvm"):
|
||||
print(line)
|
||||
else:
|
||||
print("llvm source codes already existed")
|
||||
return llvm_dir
|
||||
|
||||
def main():
|
||||
current_os = sys.platform
|
||||
print("current OS is ", current_os)
|
||||
|
||||
current_dir = Path.cwd()
|
||||
deps_dir = current_dir.joinpath( "../../../core/deps")
|
||||
|
||||
os.chdir(deps_dir)
|
||||
llvm_dir = clone_llvm()
|
||||
os.chdir(llvm_dir)
|
||||
|
||||
build_dir_name = "win32build"
|
||||
llvm_file = "LLVM.sln"
|
||||
|
||||
Path(build_dir_name).mkdir(exist_ok = True)
|
||||
build_dir = Path(build_dir_name)
|
||||
os.chdir(build_dir)
|
||||
|
||||
if ( not Path(llvm_file).exists()):
|
||||
core_number = os.cpu_count()
|
||||
print("Build llvm with", core_number, " cores")
|
||||
cmd = 'cmake ../llvm \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
||||
-DCMAKE_BUILD_TYPE:STRING="Release" \
|
||||
-DLLVM_TARGETS_TO_BUILD:STRING="X86;ARM;AArch64;Mips" \
|
||||
-DLLVM_INCLUDE_GO_TESTS=OFF \
|
||||
-DLLVM_INCLUDE_TOOLS=OFF \
|
||||
-DLLVM_INCLUDE_UTILS=OFF \
|
||||
-DLLVM_ENABLE_TERMINFO=OFF \
|
||||
-DLLVM_BUILD_LLVM_DYLIB:BOOL=OFF \
|
||||
-DLLVM_OPTIMIZED_TABLEGEN:BOOL=ON \
|
||||
-DLLVM_ENABLE_ZLIB:BOOL=OFF \
|
||||
-DLLVM_INCLUDE_DOCS:BOOL=OFF \
|
||||
-DLLVM_INCLUDE_EXAMPLES:BOOL=OFF \
|
||||
-DLLVM_INCLUDE_TESTS:BOOL=OFF \
|
||||
-DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF \
|
||||
-DLLVM_APPEND_VC_REV:BOOL=OFF'
|
||||
print(cmd)
|
||||
for line in os.popen(cmd):
|
||||
print(line)
|
||||
else:
|
||||
print("llvm has already been Cmaked")
|
||||
|
||||
print("Please open LLVM.sln in {} to build *Release* version".format(build_dir.absolute()))
|
||||
|
||||
os.chdir(current_dir)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -118,7 +118,7 @@ app_instance_repl(wasm_module_inst_t module_inst)
|
|||
size_t n;
|
||||
|
||||
while ((printf("webassembly> "),
|
||||
cmd = fgets(buffer, sizeof(buffer), stdin)) != -1) {
|
||||
cmd = fgets(buffer, sizeof(buffer), stdin)) != NULL) {
|
||||
bh_assert(cmd);
|
||||
n = strlen(cmd);
|
||||
if (cmd[n - 1] == '\n') {
|
||||
|
|
|
@ -117,6 +117,7 @@ ExternalProject_Add(bwa
|
|||
UPDATE_COMMAND git clean -fd && git checkout -- *
|
||||
&& ${CMAKE_COMMAND} -E echo "Copying pre-installed CMakeLists.txt"
|
||||
&& ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.bwa_wasm.txt CMakeLists.txt
|
||||
&& git apply ../bwa.patch
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND}
|
||||
-DWASI_SDK_PREFIX=${WASI_SDK_HOME}/wasi-sdk
|
||||
-DCMAKE_TOOLCHAIN_FILE=${WASI_SDK_HOME}/wasi-sdk/share/cmake/wasi-sdk.cmake
|
||||
|
|
13
samples/workload/bwa/bwa.patch
Normal file
13
samples/workload/bwa/bwa.patch
Normal file
|
@ -0,0 +1,13 @@
|
|||
diff --git a/utils.c b/utils.c
|
||||
index 9ceb1be..323299f 100644
|
||||
--- a/utils.c
|
||||
+++ b/utils.c
|
||||
@@ -301,6 +301,7 @@ long peakrss(void)
|
||||
#ifdef __linux__
|
||||
return r.ru_maxrss * 1024;
|
||||
#else
|
||||
- return r.ru_maxrss;
|
||||
+ /*return r.ru_maxrss;*/
|
||||
+ return 0;
|
||||
#endif
|
||||
}
|
Loading…
Reference in New Issue
Block a user