From 90cccda68e9df0a424b1a60a547555619539d4ae Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Wed, 29 Dec 2021 12:13:30 +0800 Subject: [PATCH] Refine some error msg, comment and document (#921) --- core/iwasm/common/wasm_application.c | 4 +-- core/iwasm/interpreter/wasm_loader.c | 27 ++++++++++--------- doc/build_wamr.md | 2 +- .../platforms/zephyr/simple/Dockerfile | 3 +++ 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/core/iwasm/common/wasm_application.c b/core/iwasm/common/wasm_application.c index 4cc8543b9..3555c9aab 100644 --- a/core/iwasm/common/wasm_application.c +++ b/core/iwasm/common/wasm_application.c @@ -92,9 +92,9 @@ wasm_application_execute_main(WASMModuleInstanceCommon *module_inst, int32 argc, bool ret, is_import_func = true; #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 - the actual main function. Directly call main function + the actual main function. Directly calling main function may cause exception thrown. */ if ((func = wasm_runtime_lookup_wasi_start_function(module_inst))) { return wasm_runtime_create_exec_env_and_call_wasm(module_inst, func, 0, diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index d0d3707b3..83f28a711 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -3458,7 +3458,7 @@ fail: } #if (WASM_ENABLE_MULTI_MODULE != 0) && (WASM_ENABLE_LIBC_WASI != 0) -/* +/** * refer to * 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, char *error_buf, uint32 error_buf_size) { - /* + /** * need to handle: * - non-wasi compatiable modules * - a fake wasi compatiable module @@ -3477,7 +3477,7 @@ check_wasi_abi_compatibility(const WASMModule *module, bool main_module, * * be careful with: * 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 * point. * @@ -3503,7 +3503,7 @@ check_wasi_abi_compatibility(const WASMModule *module, bool main_module, ->func_type; if (func_type->param_count || func_type->result_count) { 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; } } @@ -3518,7 +3518,7 @@ check_wasi_abi_compatibility(const WASMModule *module, bool main_module, if (func_type->param_count || func_type->result_count) { set_error_buf( error_buf, error_buf_size, - "The builtin _initiazlie() is with a wrong signature"); + "the signature of builtin _initialize function is wrong"); return false; } } @@ -3532,7 +3532,7 @@ check_wasi_abi_compatibility(const WASMModule *module, bool main_module, if (module->import_wasi_api && !start && !initialize) { set_error_buf( 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; } @@ -3545,14 +3545,16 @@ check_wasi_abi_compatibility(const WASMModule *module, bool main_module, if (start && initialize) { set_error_buf( 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; } /* filter out commands (with `_start`) cases */ if (start && !main_module) { - set_error_buf(error_buf, error_buf_size, - "A command(with _start) can not be a sud-module"); + set_error_buf( + error_buf, error_buf_size, + "a command (with _start function) can not be a sub-module"); 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, error_buf, error_buf_size); if (!memory) { - set_error_buf( - error_buf, error_buf_size, - "A module with WASI apis should export memory by default"); + set_error_buf(error_buf, error_buf_size, + "a module with WASI apis must export memory by default"); 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) - /* do a check about WASI Application ABI */ + /* Check the WASI application ABI */ if (!check_wasi_abi_compatibility(module, main_module, error_buf, error_buf_size)) { goto fail; diff --git a/doc/build_wamr.md b/doc/build_wamr.md index 9a1dd5efd..3ec5e327e 100644 --- a/doc/build_wamr.md +++ b/doc/build_wamr.md @@ -306,7 +306,7 @@ WAMR provides some features which can be easily configured by passing options to 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. diff --git a/product-mini/platforms/zephyr/simple/Dockerfile b/product-mini/platforms/zephyr/simple/Dockerfile index 3111a1f0a..3d8b51617 100644 --- a/product-mini/platforms/zephyr/simple/Dockerfile +++ b/product-mini/platforms/zephyr/simple/Dockerfile @@ -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 ARG DOCKER_UID=1000