From 046f5f221295be93ee124b7f0fdd047861c1f15c Mon Sep 17 00:00:00 2001 From: Daniel Ludwig Date: Sat, 17 Sep 2022 15:16:38 +0200 Subject: [PATCH] Fix Windows/MSVC build issues (#1498) Fix two issues of building WAMR on Windows: - The build_llvm.py script calls itself, spawning instances faster than they expire, which makes Python3 eat up the entire RAM in a pretty short time. - The MSVC compiler doesn't support preprocessor statements inside macro expressions. Two places inside bh_assert() were found. --- core/iwasm/aot/aot_runtime.c | 10 +++++++--- core/iwasm/interpreter/wasm_runtime.c | 22 +++++++++++++--------- wamr-compiler/build_llvm.py | 2 +- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index e915bbd38..ddafd9184 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -244,14 +244,18 @@ table_instantiate(AOTModuleInstance *module_inst, AOTModule *module, tbl_inst = aot_get_table_inst(module_inst, table_seg->table_index); bh_assert(tbl_inst); +#if WASM_ENABLE_REF_TYPES != 0 bh_assert( table_seg->offset.init_expr_type == INIT_EXPR_TYPE_I32_CONST || table_seg->offset.init_expr_type == INIT_EXPR_TYPE_GET_GLOBAL -#if WASM_ENABLE_REF_TYPES != 0 || table_seg->offset.init_expr_type == INIT_EXPR_TYPE_FUNCREF_CONST - || table_seg->offset.init_expr_type == INIT_EXPR_TYPE_REFNULL_CONST + || table_seg->offset.init_expr_type + == INIT_EXPR_TYPE_REFNULL_CONST); +#else + bh_assert(table_seg->offset.init_expr_type == INIT_EXPR_TYPE_I32_CONST + || table_seg->offset.init_expr_type + == INIT_EXPR_TYPE_GET_GLOBAL); #endif - ); /* Resolve table data base offset */ if (table_seg->offset.init_expr_type == INIT_EXPR_TYPE_GET_GLOBAL) { diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 065ef1139..f76cccdab 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -1587,17 +1587,21 @@ wasm_instantiate(WASMModule *module, bool is_sub_inst, uint32 stack_size, #endif /* init vec(funcidx) or vec(expr) */ - bh_assert( - table_seg->base_offset.init_expr_type == INIT_EXPR_TYPE_I32_CONST - || table_seg->base_offset.init_expr_type - == INIT_EXPR_TYPE_GET_GLOBAL #if WASM_ENABLE_REF_TYPES != 0 - || table_seg->base_offset.init_expr_type - == INIT_EXPR_TYPE_FUNCREF_CONST - || table_seg->base_offset.init_expr_type - == INIT_EXPR_TYPE_REFNULL_CONST + bh_assert(table_seg->base_offset.init_expr_type + == INIT_EXPR_TYPE_I32_CONST + || table_seg->base_offset.init_expr_type + == INIT_EXPR_TYPE_GET_GLOBAL + || table_seg->base_offset.init_expr_type + == INIT_EXPR_TYPE_FUNCREF_CONST + || table_seg->base_offset.init_expr_type + == INIT_EXPR_TYPE_REFNULL_CONST); +#else + bh_assert(table_seg->base_offset.init_expr_type + == INIT_EXPR_TYPE_I32_CONST + || table_seg->base_offset.init_expr_type + == INIT_EXPR_TYPE_GET_GLOBAL); #endif - ); if (table_seg->base_offset.init_expr_type == INIT_EXPR_TYPE_GET_GLOBAL) { diff --git a/wamr-compiler/build_llvm.py b/wamr-compiler/build_llvm.py index dd181b81a..6597f61a8 100644 --- a/wamr-compiler/build_llvm.py +++ b/wamr-compiler/build_llvm.py @@ -11,4 +11,4 @@ import sys script = ( pathlib.Path(__file__).parent.joinpath("../build-scripts/build_llvm.py").resolve() ) -subprocess.check_call([sys.executable, script.name]) +subprocess.check_call([sys.executable, script])