Skip to content
Merged
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
10 changes: 7 additions & 3 deletions build-scripts/config_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
13 changes: 7 additions & 6 deletions core/iwasm/aot/aot_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1444,15 +1444,15 @@ 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;
}

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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions core/iwasm/common/wasm_runtime_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions core/iwasm/compilation/simd/simd_int_arith.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions core/iwasm/interpreter/wasm_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions core/shared/utils/bh_vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;

Expand All @@ -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");
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions core/shared/utils/bh_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);

/**
Expand Down
2 changes: 1 addition & 1 deletion core/shared/utils/uncommon/bh_getopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#ifndef __GNUC__

#include "bh_getopt.h"
#include <stdio.h>
#include <string.h>

char* optarg = NULL;
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion product-mini/platforms/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
69 changes: 69 additions & 0 deletions product-mini/platforms/windows/build_llvm.py
Original file line number Diff line number Diff line change
@@ -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()
2 changes: 1 addition & 1 deletion product-mini/platforms/windows/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
1 change: 1 addition & 0 deletions samples/workload/bwa/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions samples/workload/bwa/bwa.patch
Original file line number Diff line number Diff line change
@@ -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
}