Ver Fonte

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.
Daniel Ludwig há 3 anos atrás
pai
commit
046f5f2212

+ 7 - 3
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) {

+ 13 - 9
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) {

+ 1 - 1
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])