Skip to content

Commit b4ea10b

Browse files
committed
allow enable both LIBC_WASI and LIBC_BUILTIN
1 parent 8c2c0cf commit b4ea10b

File tree

8 files changed

+17
-24
lines changed

8 files changed

+17
-24
lines changed

core/iwasm/common/wasm_application.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,15 @@ wasm_application_execute_main(WASMModuleInstanceCommon *module_inst, int32 argc,
100100
return wasm_runtime_create_exec_env_and_call_wasm(module_inst, func, 0,
101101
NULL);
102102
}
103-
else {
104-
wasm_runtime_set_exception(
105-
module_inst, "lookup _start function failed, may run with \'-f\'");
106-
return false;
107-
}
108103
#endif /* end of WASM_ENABLE_LIBC_WASI */
109104

110105
if (!(func = wasm_runtime_lookup_function(module_inst, "main", NULL))
111106
&& !(func = wasm_runtime_lookup_function(module_inst,
112107
"__main_argc_argv", NULL))
113108
&& !(func = wasm_runtime_lookup_function(module_inst, "_main", NULL))) {
114-
wasm_runtime_set_exception(module_inst, "lookup main function failed");
109+
wasm_runtime_set_exception(
110+
module_inst,
111+
"lookup the entry point symbol(like _start, _main, _main) failed");
115112
return false;
116113
}
117114

@@ -244,9 +241,9 @@ resolve_function(WASMModuleInstanceCommon *module_inst, const char *name,
244241
{
245242
WASMFunctionInstanceCommon *target_func = NULL;
246243
WASMModuleInstanceCommon *target_inst = NULL;
247-
char *function_name = NULL;
248244

249245
#if WASM_ENABLE_MULTI_MODULE != 0
246+
char *function_name = NULL;
250247
char *orig_name = NULL;
251248
char *sub_module_name = NULL;
252249
uint32 length = (uint32)(strlen(name) + 1);
@@ -276,7 +273,7 @@ resolve_function(WASMModuleInstanceCommon *module_inst, const char *name,
276273
target_inst = module_inst;
277274
}
278275
#else
279-
function_name = name;
276+
const char *function_name = name;
280277
target_inst = module_inst;
281278
#endif
282279

core/iwasm/common/wasm_runtime_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ wasm_runtime_deinstantiate(WASMModuleInstanceCommon *module_inst);
447447

448448
/* See wasm_export.h for description */
449449
WASM_RUNTIME_API_EXTERN WASMFunctionInstanceCommon *
450-
wasm_runtime_lookup_function(WASMModuleInstanceCommon *module_inst,
450+
wasm_runtime_lookup_function(WASMModuleInstanceCommon *const module_inst,
451451
const char *name, const char *signature);
452452

453453
/* Internal API */

core/iwasm/interpreter/wasm_loader.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3472,6 +3472,9 @@ check_wasi_abi_compatibility(const WASMModule *module, bool main_module,
34723472
* if a module doesn't depends on any library, it imports nothing.
34733473
* and its `is_wasi_module` flag is false. but still export below entries.
34743474
*/
3475+
if (!module->is_wasi_module) {
3476+
return true;
3477+
}
34753478

34763479
if (main_module) {
34773480
start = wasm_loader_find_export(module, "", "_start", EXPORT_KIND_FUNC,

core/iwasm/interpreter/wasm_runtime.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,19 +1038,14 @@ sub_module_instantiate(WASMModule *module, WASMModuleInstance *module_inst,
10381038
* reactor instances may assume that _initialize will be called by
10391039
* the environment at most once, and that none of their other
10401040
* exports are accessed before that call.
1041+
*
1042+
* let the loader decide how to act if there is no _initialize
1043+
* in a reactor
10411044
*/
10421045
WASMFunctionInstance *initialize =
10431046
wasm_lookup_function(sub_module_inst, "_initialize", NULL);
1044-
/* a strong restricttion that a reactor must export a _initialize
1045-
* function */
1046-
if (!initialize) {
1047-
set_error_buf(error_buf, error_buf_size,
1048-
"The reactors(sub-modules) must export a "
1049-
"_initialize function");
1050-
goto failed;
1051-
}
1052-
1053-
if (!wasm_create_exec_env_and_call_function(
1047+
if (initialize
1048+
&& !wasm_create_exec_env_and_call_function(
10541049
sub_module_inst, initialize, 0, NULL, false)) {
10551050
set_error_buf(error_buf, error_buf_size,
10561051
"Call _initialize failed ");

product-mini/platforms/linux-sgx/enclave-sample/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ Enclave_Include_Paths := -IEnclave -I$(WAMR_ROOT)/core/iwasm/include \
102102
Enclave_C_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $(Enclave_Include_Paths)
103103
ifeq ($(SPEC_TEST), 1)
104104
Enclave_C_Flags += -DWASM_ENABLE_SPEC_TEST=1
105-
Enclave_C_Flags += -DSGX_DISABLE_WASI
106105
else
107106
Enclave_C_Flags += -DWASM_ENABLE_SPEC_TEST=0
108107
endif

samples/multi-module/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ endif ()
4040
set(WAMR_BUILD_INTERP 1)
4141
set(WAMR_BUILD_AOT 0)
4242
set(WAMR_BUILD_JIT 0)
43-
set(WAMR_BUILD_LIBC_BUILTIN 0)
43+
set(WAMR_BUILD_LIBC_BUILTIN 1)
4444
set(WAMR_BUILD_LIBC_WASI 1)
4545
set(WAMR_BUILD_MULTI_MODULE 1)
4646

samples/multi-module/wasm-apps/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function(COMPILE_WITH_CLANG SOURCE_FILE COMMAND)
5252
get_filename_component(FILE_NAME ${SOURCE_FILE} NAME_WLE)
5353

5454
set(WASM_MODULE ${FILE_NAME}.wasm)
55-
55+
5656
set(MAIN_TARGET_NAME MODULE_${FILE_NAME})
5757

5858
add_executable(${MAIN_TARGET_NAME} ${SOURCE_FILE})
@@ -64,7 +64,7 @@ function(COMPILE_WITH_CLANG SOURCE_FILE COMMAND)
6464
message(STATUS "Generating ${WASM_MODULE} as REACTOR...")
6565
target_link_options(${MAIN_TARGET_NAME} PRIVATE -mexec-model=reactor)
6666
endif()
67-
67+
6868
if(EXISTS ${WASM2WAT})
6969
message(STATUS "Dumping ${WASM_MODULE}...")
7070
set(WASM_WAT ${FILE_NAME}.wat)

tests/wamr-test-suites/test_wamr.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,6 @@ function trigger()
527527
local EXTRA_COMPILE_FLAGS=""
528528
# default enabled features
529529
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_BULK_MEMORY=1"
530-
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_LIBC_WASI=0"
531530

532531
if [[ ${ENABLE_MULTI_MODULE} == 1 ]];then
533532
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_MULTI_MODULE=1"

0 commit comments

Comments
 (0)