@@ -684,7 +684,7 @@ adjust_table_max_size(uint32 init_size, uint32 max_size_flag, uint32 *max_size)
684684 }
685685}
686686
687- #if WASM_ENABLE_MULTI_MODULE != 0
687+ #if WASM_ENABLE_LIBC_WASI != 0 || WASM_ENABLE_MULTI_MODULE != 0
688688/**
689689 * Find export item of a module with export info:
690690 * module name, field name and export kind
@@ -718,11 +718,15 @@ wasm_loader_find_export(const WASMModule *module, const char *module_name,
718718 return NULL ;
719719 }
720720
721+ (void )module_name ;
722+
721723 /* since there is a validation in load_export_section(), it is for sure
722724 * export->index is valid*/
723725 return export ;
724726}
727+ #endif
725728
729+ #if WASM_ENABLE_MULTI_MODULE != 0
726730static WASMFunction *
727731wasm_loader_resolve_function (const char * module_name , const char * function_name ,
728732 const WASMType * expected_function_type ,
@@ -1240,6 +1244,8 @@ load_table_import(const uint8 **p_buf, const uint8 *buf_end,
12401244 table -> init_size = declare_init_size ;
12411245 table -> flags = declare_max_size_flag ;
12421246 table -> max_size = declare_max_size ;
1247+
1248+ (void )parent_module ;
12431249 return true;
12441250fail :
12451251 return false;
@@ -1373,6 +1379,8 @@ load_memory_import(const uint8 **p_buf, const uint8 *buf_end,
13731379 memory -> num_bytes_per_page = DEFAULT_NUM_BYTES_PER_PAGE ;
13741380
13751381 * p_buf = p ;
1382+
1383+ (void )parent_module ;
13761384 return true;
13771385fail :
13781386 return false;
@@ -1439,6 +1447,8 @@ load_global_import(const uint8 **p_buf, const uint8 *buf_end,
14391447 global -> field_name = global_name ;
14401448 global -> type = declare_type ;
14411449 global -> is_mutable = (declare_mutable == 1 );
1450+
1451+ (void )parent_module ;
14421452 return true;
14431453fail :
14441454 return false;
@@ -2381,6 +2391,7 @@ load_func_index_vec(const uint8 **p_buf, const uint8 *buf_end,
23812391 }
23822392#else
23832393 read_leb_uint32 (p , p_end , function_index );
2394+ (void )use_init_expr ;
23842395#endif
23852396
23862397 /* since we are using -1 to indicate ref.null */
@@ -2690,6 +2701,7 @@ load_code_section(const uint8 *buf, const uint8 *buf_end, const uint8 *buf_func,
26902701 }
26912702
26922703 LOG_VERBOSE ("Load code segment section success.\n" );
2704+ (void )module ;
26932705 return true;
26942706fail :
26952707 return false;
@@ -2900,6 +2912,8 @@ load_user_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
29002912
29012913 LOG_VERBOSE ("Ignore custom section [%s]." , section_name );
29022914
2915+ (void )is_load_from_file_buf ;
2916+ (void )module ;
29032917 return true;
29042918fail :
29052919 return false;
@@ -4054,24 +4068,19 @@ load(const uint8 *buf, uint32 size, WASMModule *module, char *error_buf,
40544068 return false;
40554069}
40564070
4057- #if ( WASM_ENABLE_MULTI_MODULE != 0 ) && ( WASM_ENABLE_LIBC_WASI != 0 )
4071+ #if WASM_ENABLE_LIBC_WASI != 0
40584072/**
40594073 * refer to
40604074 * https://github.com/WebAssembly/WASI/blob/main/design/application-abi.md
40614075 */
40624076static bool
4063- check_wasi_abi_compatibility (const WASMModule * module , bool main_module ,
4077+ check_wasi_abi_compatibility (const WASMModule * module ,
4078+ #if WASM_ENABLE_MULTI_MODULE != 0
4079+ bool main_module ,
4080+ #endif
40644081 char * error_buf , uint32 error_buf_size )
40654082{
40664083 /**
4067- * need to handle:
4068- * - non-wasi compatiable modules
4069- * - a fake wasi compatiable module
4070- * - a command acts as a main_module
4071- * - a command acts as a sub_module
4072- * - a reactor acts as a main_module
4073- * - a reactor acts as a sub_module
4074- *
40754084 * be careful with:
40764085 * wasi compatiable modules(command/reactor) which don't import any wasi
40774086 * APIs. Usually, a command has to import a "prox_exit" at least, but a
@@ -4087,7 +4096,19 @@ check_wasi_abi_compatibility(const WASMModule *module, bool main_module,
40874096 * - no one will define either `_start` or `_initialize` on purpose
40884097 * - `_start` should always be `void _start(void)`
40894098 * - `_initialize` should always be `void _initialize(void)`
4099+ *
4100+ */
4101+
4102+ /* clang-format off */
4103+ /**
4104+ *
4105+ * | | import_wasi_api True | | import_wasi_api False | |
4106+ * | ----------- | -------------------- | ---------------- | --------------------- | ---------------- |
4107+ * | | \_initialize() Y | \_initialize() N | \_initialize() Y | \_initialize() N |
4108+ * | \_start() Y | N | COMMANDER | N | COMMANDER |
4109+ * | \_start() N | REACTOR | N | REACTOR | OTHERS |
40904110 */
4111+ /* clang-format on */
40914112
40924113 WASMExport * initialize = NULL , * memory = NULL , * start = NULL ;
40934114
@@ -4147,13 +4168,15 @@ check_wasi_abi_compatibility(const WASMModule *module, bool main_module,
41474168 return false;
41484169 }
41494170
4171+ #if WASM_ENABLE_MULTI_MODULE != 0
41504172 /* filter out commands (with `_start`) cases */
41514173 if (start && !main_module ) {
41524174 set_error_buf (
41534175 error_buf , error_buf_size ,
41544176 "a command (with _start function) can not be a sub-module" );
41554177 return false;
41564178 }
4179+ #endif
41574180
41584181 /*
41594182 * it is ok a reactor acts as a main module,
@@ -4193,10 +4216,13 @@ wasm_loader_load(uint8 *buf, uint32 size,
41934216 goto fail ;
41944217 }
41954218
4196- #if ( WASM_ENABLE_MULTI_MODULE != 0 ) && ( WASM_ENABLE_LIBC_WASI != 0 )
4219+ #if WASM_ENABLE_LIBC_WASI != 0
41974220 /* Check the WASI application ABI */
4198- if (!check_wasi_abi_compatibility (module , main_module , error_buf ,
4199- error_buf_size )) {
4221+ if (!check_wasi_abi_compatibility (module ,
4222+ #if WASM_ENABLE_MULTI_MODULE != 0
4223+ main_module ,
4224+ #endif
4225+ error_buf , error_buf_size )) {
42004226 goto fail ;
42014227 }
42024228#endif
@@ -4971,6 +4997,7 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
49714997 }
49724998
49734999 (void )u8 ;
5000+ (void )exec_env ;
49745001 return false;
49755002fail :
49765003 return false;
@@ -5834,6 +5861,8 @@ preserve_referenced_local(WASMLoaderContext *loader_ctx, uint8 opcode,
58345861 i += 2 ;
58355862 }
58365863
5864+ (void )error_buf ;
5865+ (void )error_buf_size ;
58375866 return true;
58385867#if WASM_ENABLE_LABELS_AS_VALUES != 0
58395868#if WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0
@@ -6098,6 +6127,9 @@ wasm_loader_pop_frame_offset(WASMLoaderContext *ctx, uint8 type,
60986127 ctx -> dynamic_offset -= 2 ;
60996128 }
61006129 emit_operand (ctx , * (ctx -> frame_offset ));
6130+
6131+ (void )error_buf ;
6132+ (void )error_buf_size ;
61016133 return true;
61026134}
61036135
0 commit comments