Refine some error msg, comment and document (#921)

This commit is contained in:
Wenyong Huang 2021-12-29 12:13:30 +08:00 committed by GitHub
parent 50b6474f54
commit 90cccda68e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 16 deletions

View File

@ -92,9 +92,9 @@ wasm_application_execute_main(WASMModuleInstanceCommon *module_inst, int32 argc,
bool ret, is_import_func = true; bool ret, is_import_func = true;
#if WASM_ENABLE_LIBC_WASI != 0 #if WASM_ENABLE_LIBC_WASI != 0
/* In wasi mode, we should call function named "_start" /* In wasi mode, we should call the function named "_start"
which initializes the wasi envrionment and then calls which initializes the wasi envrionment and then calls
the actual main function. Directly call main function the actual main function. Directly calling main function
may cause exception thrown. */ may cause exception thrown. */
if ((func = wasm_runtime_lookup_wasi_start_function(module_inst))) { if ((func = wasm_runtime_lookup_wasi_start_function(module_inst))) {
return wasm_runtime_create_exec_env_and_call_wasm(module_inst, func, 0, return wasm_runtime_create_exec_env_and_call_wasm(module_inst, func, 0,

View File

@ -3458,7 +3458,7 @@ fail:
} }
#if (WASM_ENABLE_MULTI_MODULE != 0) && (WASM_ENABLE_LIBC_WASI != 0) #if (WASM_ENABLE_MULTI_MODULE != 0) && (WASM_ENABLE_LIBC_WASI != 0)
/* /**
* refer to * refer to
* https://github.com/WebAssembly/WASI/blob/main/design/application-abi.md * https://github.com/WebAssembly/WASI/blob/main/design/application-abi.md
*/ */
@ -3466,7 +3466,7 @@ static bool
check_wasi_abi_compatibility(const WASMModule *module, bool main_module, check_wasi_abi_compatibility(const WASMModule *module, bool main_module,
char *error_buf, uint32 error_buf_size) char *error_buf, uint32 error_buf_size)
{ {
/* /**
* need to handle: * need to handle:
* - non-wasi compatiable modules * - non-wasi compatiable modules
* - a fake wasi compatiable module * - a fake wasi compatiable module
@ -3477,7 +3477,7 @@ check_wasi_abi_compatibility(const WASMModule *module, bool main_module,
* *
* be careful with: * be careful with:
* wasi compatiable modules(command/reactor) which don't import any wasi * wasi compatiable modules(command/reactor) which don't import any wasi
* APIs. usually, a command has to import a "prox_exit" at least. but a * APIs. Usually, a command has to import a "prox_exit" at least, but a
* reactor can depend on nothing. At the same time, each has its own entry * reactor can depend on nothing. At the same time, each has its own entry
* point. * point.
* *
@ -3503,7 +3503,7 @@ check_wasi_abi_compatibility(const WASMModule *module, bool main_module,
->func_type; ->func_type;
if (func_type->param_count || func_type->result_count) { if (func_type->param_count || func_type->result_count) {
set_error_buf(error_buf, error_buf_size, set_error_buf(error_buf, error_buf_size,
"The builtin _start() is with a wrong signature"); "the signature of builtin _start function is wrong");
return false; return false;
} }
} }
@ -3518,7 +3518,7 @@ check_wasi_abi_compatibility(const WASMModule *module, bool main_module,
if (func_type->param_count || func_type->result_count) { if (func_type->param_count || func_type->result_count) {
set_error_buf( set_error_buf(
error_buf, error_buf_size, error_buf, error_buf_size,
"The builtin _initiazlie() is with a wrong signature"); "the signature of builtin _initialize function is wrong");
return false; return false;
} }
} }
@ -3532,7 +3532,7 @@ check_wasi_abi_compatibility(const WASMModule *module, bool main_module,
if (module->import_wasi_api && !start && !initialize) { if (module->import_wasi_api && !start && !initialize) {
set_error_buf( set_error_buf(
error_buf, error_buf_size, error_buf, error_buf_size,
"A module with WASI apis should be either a command or a reactor"); "a module with WASI apis must be either a command or a reactor");
return false; return false;
} }
@ -3545,14 +3545,16 @@ check_wasi_abi_compatibility(const WASMModule *module, bool main_module,
if (start && initialize) { if (start && initialize) {
set_error_buf( set_error_buf(
error_buf, error_buf_size, error_buf, error_buf_size,
"Neither a command nor a reactor can have both at the same time"); "neither a command nor a reactor can both have _start function "
"and _initialize function at the same time");
return false; return false;
} }
/* filter out commands (with `_start`) cases */ /* filter out commands (with `_start`) cases */
if (start && !main_module) { if (start && !main_module) {
set_error_buf(error_buf, error_buf_size, set_error_buf(
"A command(with _start) can not be a sud-module"); error_buf, error_buf_size,
"a command (with _start function) can not be a sub-module");
return false; return false;
} }
@ -3564,9 +3566,8 @@ check_wasi_abi_compatibility(const WASMModule *module, bool main_module,
memory = wasm_loader_find_export(module, "", "memory", EXPORT_KIND_MEMORY, memory = wasm_loader_find_export(module, "", "memory", EXPORT_KIND_MEMORY,
error_buf, error_buf_size); error_buf, error_buf_size);
if (!memory) { if (!memory) {
set_error_buf( set_error_buf(error_buf, error_buf_size,
error_buf, error_buf_size, "a module with WASI apis must export memory by default");
"A module with WASI apis should export memory by default");
return false; return false;
} }
@ -3596,7 +3597,7 @@ wasm_loader_load(const uint8 *buf, uint32 size,
} }
#if (WASM_ENABLE_MULTI_MODULE != 0) && (WASM_ENABLE_LIBC_WASI != 0) #if (WASM_ENABLE_MULTI_MODULE != 0) && (WASM_ENABLE_LIBC_WASI != 0)
/* do a check about WASI Application ABI */ /* Check the WASI application ABI */
if (!check_wasi_abi_compatibility(module, main_module, error_buf, if (!check_wasi_abi_compatibility(module, main_module, error_buf,
error_buf_size)) { error_buf_size)) {
goto fail; goto fail;

View File

@ -306,7 +306,7 @@ WAMR provides some features which can be easily configured by passing options to
Zephyr Zephyr
------------------------- -------------------------
You need to prepare Zephyr first as described here https://docs.zephyrproject.org/latest/getting_started/index.html#get-zephyr-and-install-python-dependencies). You need to prepare Zephyr first as described here https://docs.zephyrproject.org/latest/getting_started/index.html#get-zephyr-and-install-python-dependencies.
After that you need to point the `ZEPHYR_BASE` variable to e.g. `~/zephyrproject/zephyr`. Also, it is important that you have `west` available for subsequent actions. After that you need to point the `ZEPHYR_BASE` variable to e.g. `~/zephyrproject/zephyr`. Also, it is important that you have `west` available for subsequent actions.

View File

@ -1,3 +1,6 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
FROM ubuntu:20.04 FROM ubuntu:20.04
ARG DOCKER_UID=1000 ARG DOCKER_UID=1000