From e7a8b3e743f8821eddbfc526eec19782c51c8408 Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Sat, 20 Apr 2024 10:16:34 +0800 Subject: [PATCH] Update version number to 2.0.0 and update release notes (#3327) And enable code format check for wasm_export.h and add '\n' in os_printf in sgx platform source files. --- RELEASE_NOTES.md | 99 +++++++++++++ core/iwasm/include/wasm_export.h | 132 ++++++++---------- core/shared/platform/linux-sgx/sgx_ipfs.c | 4 +- core/shared/platform/linux-sgx/sgx_platform.c | 9 +- core/version.h | 6 +- 5 files changed, 168 insertions(+), 82 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 3fcfaf4b..0721fc63 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,102 @@ +## WAMR-2.0.0 + +### Breaking Changes +- The AOT ABI was changed after GC and memory64 features were introduced: + - Implement GC feature for interpreter, AOT and LLVM-JIT (#3125) + - Implement memory64 for classic interpreter (#3266) + - Always allocate linear memory using mmap (#3052) + - Refactor APIs and data structures as preliminary work for Memory64 (#3209) +- Remove unused argument in wasm_runtime_lookup_function (#3218) +- Separate app-manager and app-framework from WAMR (#3129) + +### New Features +- Implement GC feature for interpreter, AOT and LLVM-JIT (#3125) +- Implement memory64 for classic interpreter (#3266) +- Add wasi_ephemeral_nn module support (#3241) + +### Bug Fixes +- EH: Fix broken stack usage calculation (#3121) +- Fix loader check_wasi_abi_compatibility (#3126) +- Fix possible integer overflow in loader target block check (#3133) +- Fix locel.set in polymorphic stack (#3135) +- Fix threads opcodes' boundary check in classic-interp and fast-interp (#3136) +- fast-interp: Fix copy_stack_top_i64 overlap issue (#3146) +- Fix a ubsan complaint "applying zero offset to null pointer" (#3160) +- fast-interp: Fix GC opcode ref.as_non_null (#3156) +- Fix llvm jit push funcref/externref result type issue (#3169) +- Fix wasm loader handling opcode br_table (#3176) +- Fix ref.func opcode check when GC is enabled (#3181) +- lldb_function_to_function_dbi: Fix a null dereference (#3189) +- Fix compilation errors on MinGW (#3217) +- Fix compilation errors on esp-idf platform (#3224) +- Fix aot relocation symbols not found on windows 32-bit (#3231) +- posix_file.c: Correct the dirfd argument that passes to fstatat (#3244) +- Fix compilation errors on zephyr platform (#3255) +- Fix dynamic offset not updated in op_br for block with ret type (#3269) +- aot debug: Fix a NULL dereference (#3274) +- thread mgr: Free aux stack only when it was allocated (#3282) +- interp: Restore context from prev_frame after tail calling a native function (#3283) +- Sync simd opcode definitions spec (#3290) +- Fix posix_fadvise error handling (#3323) +- Fix windows relocation string parsing issue (#3333) + +### Enhancements +- Zero the memory mapped from os_mmap in NuttX (#3132) +- Use logger for runtime error/debug prints (#3097) +- aot_compile_op_call: Stop setting calling convention explicitly (#3140) +- aot compiler: Place precheck wrapper before the corresponding wrapped function (#3141) +- Fix null pointer access in fast-interp when configurable soft bound check is enabled (#3150) +- Clarify how to verify SGX evidence without an Intel SGX-enabled platform (#3158) +- zephyr: Use zephyr sys_cache instead of CMSIS (#3162) +- VSCode IDE enhancement and readme update (#3172) +- Add vprintf override for android and esp-idf (#3174) +- zephyr: Include math only with minimal libc (#3177) +- zephyr: Implement Alloc_With_System_Allocator (#3179) +- Use indirect call in pre-checker function to avoid relocation in XIP mode (#3142) +- Implement the remaining Windows filesystem functions (#3166) +- Fix LLVM assertion failure and update CONTRIBUTING.md (#3197) +- Allow overriding max memory on module instantiation (#3198) +- Get location info from function indexes in addr2line script (#3206) +- Demangle function names in stack trace when using addr2line script (#3211) +- Refactor APIs and data structures as preliminary work for Memory64 (#3209) +- Allow converting the zero wasm address to native (#3215) +- Small refactor on WASMModuleInstance and fix Go/Python language bindings (#3227) +- Add esp32c6 support (#3234) +- Make android platform's cmake flags configurable (#3239) +- Go binding: Change C.long to C.int64_t when call wasm_runtime_set_wasi_args_ex (#3235) +- Implement apis to set and get the name of a wasm module (#3254) +- Append '\0' to every name string in aot name section (#3249) +- Add cmake flag to control aot intrinsics (#3261) +- Add lock and ref_count for runtime init (#3263) +- nuttx: Migrate NuttX CMake build for WAMR (#3256) +- LLVM 19: Switch to debug records (#3272) +- aot debug: Process lldb_function_to_function_dbi only for C (#3278) +- Fix warnings/issues reported in Windows and by CodeQL/Coverity (#3275) +- Enhance wasm loading with LoadArgs and support module names (#3265) +- Add wamr to esp-idf components registry (#3287) +- zephyr: Add missing pthread library functions (#3291) +- Add more checks in wasm loader (#3300) +- Log warning if growing table failed (#3310) +- Enhance GC subtyping checks (#3317) +- User defined memory allocator for different purposes (#3316) +- Add a comment on WASM_STACK_GUARD_SIZE (#3332) +- Allow executing malloc/free from native in memory64 mode (#3315) +- Add functions to expose module import/export info (#3330) + +### Others +- Add ARM MacOS to the CI (#3120) +- Download jetstream src from github instead of browserbench.org (#3196) +- Update document to add wamr-rust-sdk introduction (#3204) +- Fix nightly run tsan ASLR issue (#3233) +- Add CodeQL Workflow for Code Security Analysis (#2812) +- Add issue templates (#3248) +- Fix CI error when install packages for macos-14 (#3270) +- Update document for GC, exception handling and memory64 features (#3284) +- Update release CI (#3295) +- Add native-stack-overflow sample (#3321) + +--- + ## WAMR-1.3.2 ### Breaking Changes diff --git a/core/iwasm/include/wasm_export.h b/core/iwasm/include/wasm_export.h index bc1833b8..104a9e83 100644 --- a/core/iwasm/include/wasm_export.h +++ b/core/iwasm/include/wasm_export.h @@ -32,10 +32,7 @@ extern "C" { #endif -/* clang-format off */ - -#define get_module_inst(exec_env) \ - wasm_runtime_get_module_inst(exec_env) +#define get_module_inst(exec_env) wasm_runtime_get_module_inst(exec_env) #define validate_app_addr(offset, size) \ wasm_runtime_validate_app_addr(module_inst, offset, size) @@ -52,8 +49,7 @@ extern "C" { #define module_malloc(size, p_native_addr) \ wasm_runtime_module_malloc(module_inst, size, p_native_addr) -#define module_free(offset) \ - wasm_runtime_module_free(module_inst, offset) +#define module_free(offset) wasm_runtime_module_free(module_inst, offset) #define native_raw_return_type(type, args) type *raw_ret = (type *)(args) @@ -132,10 +128,7 @@ typedef enum { Alloc_With_System_Allocator, } mem_alloc_type_t; -typedef enum { - Alloc_For_Runtime, - Alloc_For_LinearMemory -} mem_alloc_usage_t; +typedef enum { Alloc_For_Runtime, Alloc_For_LinearMemory } mem_alloc_usage_t; /* Memory allocator option */ typedef union MemAllocOption { @@ -392,8 +385,8 @@ wasm_runtime_is_xip_file(const uint8_t *buf, uint32_t size); * Callback to load a module file into a buffer in multi-module feature */ typedef bool (*module_reader)(package_type_t module_type, - const char *module_name, - uint8_t **p_buffer, uint32_t *p_size); + const char *module_name, uint8_t **p_buffer, + uint32_t *p_size); /** * Callback to release the buffer loaded by module_reader callback @@ -457,8 +450,8 @@ wasm_runtime_find_module_registered(const char *module_name); * @return return WASM module loaded, NULL if failed */ WASM_RUNTIME_API_EXTERN wasm_module_t -wasm_runtime_load(uint8_t *buf, uint32_t size, - char *error_buf, uint32_t error_buf_size); +wasm_runtime_load(uint8_t *buf, uint32_t size, char *error_buf, + uint32_t error_buf_size); /** * Load a WASM module with specified load argument. @@ -534,12 +527,12 @@ wasm_runtime_get_module_hash(wasm_module_t module); * for STDERR is used. */ WASM_RUNTIME_API_EXTERN void -wasm_runtime_set_wasi_args_ex(wasm_module_t module, - const char *dir_list[], uint32_t dir_count, - const char *map_dir_list[], uint32_t map_dir_count, - const char *env[], uint32_t env_count, - char *argv[], int argc, int64_t stdinfd, - int64_t stdoutfd, int64_t stderrfd); +wasm_runtime_set_wasi_args_ex(wasm_module_t module, const char *dir_list[], + uint32_t dir_count, const char *map_dir_list[], + uint32_t map_dir_count, const char *env[], + uint32_t env_count, char *argv[], int argc, + int64_t stdinfd, int64_t stdoutfd, + int64_t stderrfd); /** * Set WASI parameters. @@ -547,34 +540,34 @@ wasm_runtime_set_wasi_args_ex(wasm_module_t module, * Same as wasm_runtime_set_wasi_args_ex but with default stdio handles */ WASM_RUNTIME_API_EXTERN void -wasm_runtime_set_wasi_args(wasm_module_t module, - const char *dir_list[], uint32_t dir_count, - const char *map_dir_list[], uint32_t map_dir_count, - const char *env[], uint32_t env_count, - char *argv[], int argc); +wasm_runtime_set_wasi_args(wasm_module_t module, const char *dir_list[], + uint32_t dir_count, const char *map_dir_list[], + uint32_t map_dir_count, const char *env[], + uint32_t env_count, char *argv[], int argc); WASM_RUNTIME_API_EXTERN void wasm_runtime_set_wasi_addr_pool(wasm_module_t module, const char *addr_pool[], uint32_t addr_pool_size); WASM_RUNTIME_API_EXTERN void -wasm_runtime_set_wasi_ns_lookup_pool(wasm_module_t module, const char *ns_lookup_pool[], +wasm_runtime_set_wasi_ns_lookup_pool(wasm_module_t module, + const char *ns_lookup_pool[], uint32_t ns_lookup_pool_size); /** * Instantiate a WASM module. * * @param module the WASM module to instantiate - * @param default_stack_size the default stack size of the module instance when the - * exec env's operation stack isn't created by user, e.g. API + * @param default_stack_size the default stack size of the module instance when + * the exec env's operation stack isn't created by user, e.g. API * wasm_application_execute_main() and wasm_application_execute_func() * create the operation stack internally with the stack size specified * here. And API wasm_runtime_create_exec_env() creates the operation * stack with stack size specified by its parameter, the stack size * specified here is ignored. - * @param host_managed_heap_size the default heap size of the module instance, a heap will - * be created besides the app memory space. Both wasm app and native - * function can allocate memory from the heap. + * @param host_managed_heap_size the default heap size of the module instance, + * a heap will be created besides the app memory space. Both wasm app + * and native function can allocate memory from the heap. * @param error_buf buffer to output the error info if failed * @param error_buf_size the size of the error buffer * @@ -582,18 +575,20 @@ wasm_runtime_set_wasi_ns_lookup_pool(wasm_module_t module, const char *ns_lookup */ WASM_RUNTIME_API_EXTERN wasm_module_inst_t wasm_runtime_instantiate(const wasm_module_t module, - uint32_t default_stack_size, uint32_t host_managed_heap_size, - char *error_buf, uint32_t error_buf_size); + uint32_t default_stack_size, + uint32_t host_managed_heap_size, char *error_buf, + uint32_t error_buf_size); /** * Instantiate a WASM module, with specified instantiation arguments * - * Same as wasm_runtime_instantiate, but it also allows overwriting maximum memory + * Same as wasm_runtime_instantiate, but it also allows overwriting maximum + * memory */ WASM_RUNTIME_API_EXTERN wasm_module_inst_t wasm_runtime_instantiate_ex(const wasm_module_t module, - const InstantiationArgs *args, - char *error_buf, uint32_t error_buf_size); + const InstantiationArgs *args, char *error_buf, + uint32_t error_buf_size); /** * Set the running mode of a WASM module instance, override the @@ -778,7 +773,8 @@ wasm_runtime_get_exec_env_singleton(wasm_module_inst_t module_inst); * @return debug port if success, 0 otherwise. */ WASM_RUNTIME_API_EXTERN uint32_t -wasm_runtime_start_debug_instance_with_port(wasm_exec_env_t exec_env, int32_t port); +wasm_runtime_start_debug_instance_with_port(wasm_exec_env_t exec_env, + int32_t port); /** * Same as wasm_runtime_start_debug_instance_with_port(env, -1). @@ -859,8 +855,7 @@ wasm_runtime_set_module_inst(wasm_exec_env_t exec_env, * info. */ WASM_RUNTIME_API_EXTERN bool -wasm_runtime_call_wasm(wasm_exec_env_t exec_env, - wasm_function_inst_t function, +wasm_runtime_call_wasm(wasm_exec_env_t exec_env, wasm_function_inst_t function, uint32_t argc, uint32_t argv[]); /** @@ -881,9 +876,9 @@ wasm_runtime_call_wasm(wasm_exec_env_t exec_env, */ WASM_RUNTIME_API_EXTERN bool wasm_runtime_call_wasm_a(wasm_exec_env_t exec_env, - wasm_function_inst_t function, - uint32_t num_results, wasm_val_t results[], - uint32_t num_args, wasm_val_t *args); + wasm_function_inst_t function, uint32_t num_results, + wasm_val_t results[], uint32_t num_args, + wasm_val_t *args); /** * Call the given WASM function of a WASM module instance with @@ -903,9 +898,8 @@ wasm_runtime_call_wasm_a(wasm_exec_env_t exec_env, */ WASM_RUNTIME_API_EXTERN bool wasm_runtime_call_wasm_v(wasm_exec_env_t exec_env, - wasm_function_inst_t function, - uint32_t num_results, wasm_val_t results[], - uint32_t num_args, ...); + wasm_function_inst_t function, uint32_t num_results, + wasm_val_t results[], uint32_t num_args, ...); /** * Call a function reference of a given WASM runtime instance with @@ -947,8 +941,8 @@ wasm_runtime_call_indirect(wasm_exec_env_t exec_env, uint32_t element_index, * the exception info. */ WASM_RUNTIME_API_EXTERN bool -wasm_application_execute_main(wasm_module_inst_t module_inst, - int32_t argc, char *argv[]); +wasm_application_execute_main(wasm_module_inst_t module_inst, int32_t argc, + char *argv[]); /** * Find the specified function in argv[0] from a WASM module instance @@ -966,8 +960,8 @@ wasm_application_execute_main(wasm_module_inst_t module_inst, * to get the exception info. */ WASM_RUNTIME_API_EXTERN bool -wasm_application_execute_func(wasm_module_inst_t module_inst, - const char *name, int32_t argc, char *argv[]); +wasm_application_execute_func(wasm_module_inst_t module_inst, const char *name, + int32_t argc, char *argv[]); /** * Get exception info of the WASM module instance. @@ -1026,8 +1020,7 @@ wasm_runtime_terminate(wasm_module_inst_t module_inst); * @param custom_data the custom data to be set */ WASM_RUNTIME_API_EXTERN void -wasm_runtime_set_custom_data(wasm_module_inst_t module_inst, - void *custom_data); +wasm_runtime_set_custom_data(wasm_module_inst_t module_inst, void *custom_data); /** * Get the custom data within a WASM module instance. @@ -1046,8 +1039,7 @@ wasm_runtime_get_custom_data(wasm_module_inst_t module_inst); * @param enable the flag to enable/disable the memory bounds checks */ WASM_RUNTIME_API_EXTERN void -wasm_runtime_set_bounds_checks(wasm_module_inst_t module_inst, - bool enable); +wasm_runtime_set_bounds_checks(wasm_module_inst_t module_inst, bool enable); /** * Check if the memory bounds checks flag is enabled for a WASM module instance. @@ -1056,8 +1048,7 @@ wasm_runtime_set_bounds_checks(wasm_module_inst_t module_inst, * @return true if the memory bounds checks flag is enabled, false otherwise */ WASM_RUNTIME_API_EXTERN bool -wasm_runtime_is_bounds_checks_enabled( - wasm_module_inst_t module_inst); +wasm_runtime_is_bounds_checks_enabled(wasm_module_inst_t module_inst); /** * Allocate memory from the heap of WASM module instance @@ -1105,8 +1096,8 @@ wasm_runtime_module_free(wasm_module_inst_t module_inst, uint64_t ptr); * Return non-zero if success, zero if failed. */ WASM_RUNTIME_API_EXTERN uint64_t -wasm_runtime_module_dup_data(wasm_module_inst_t module_inst, - const char *src, uint64_t size); +wasm_runtime_module_dup_data(wasm_module_inst_t module_inst, const char *src, + uint64_t size); /** * Validate the app address, check whether it belongs to WASM module @@ -1285,7 +1276,8 @@ wasm_runtime_get_export_type(const wasm_module_t module, int32_t export_index, * 'I': the parameter is i64 type * 'f': the parameter is f32 type * 'F': the parameter is f64 type - * 'r': the parameter is externref type, it should be a uintptr_t in host + * 'r': the parameter is externref type, it should be a uintptr_t + * in host * '*': the parameter is a pointer (i32 in WASM), and runtime will * auto check its boundary before calling the native function. * If it is followed by '~', the checked length of the pointer @@ -1319,7 +1311,6 @@ wasm_runtime_register_natives_raw(const char *module_name, NativeSymbol *native_symbols, uint32_t n_native_symbols); - /** * Undo wasm_runtime_register_natives or wasm_runtime_register_natives_raw * @@ -1396,7 +1387,7 @@ wasm_runtime_sum_wasm_exec_time(wasm_module_inst_t module_inst); /** * Return execution time in ms of a given wasm funciton with -* func_name. If the function is not found, return 0. + * func_name. If the function is not found, return 0. * * @param module_inst the WASM module instance to profile * @param func_name could be an export name or a name in the @@ -1475,8 +1466,8 @@ wasm_runtime_join_thread(wasm_thread_t tid, void **retval); * @return true if success, false otherwise */ WASM_RUNTIME_API_EXTERN bool -wasm_externref_obj2ref(wasm_module_inst_t module_inst, - void *extern_obj, uint32_t *p_externref_idx); +wasm_externref_obj2ref(wasm_module_inst_t module_inst, void *extern_obj, + uint32_t *p_externref_idx); /** * Delete external object registered by `wasm_externref_obj2ref`. @@ -1603,7 +1594,6 @@ WASM_RUNTIME_API_EXTERN const uint8_t * wasm_runtime_get_custom_section(wasm_module_t const module_comm, const char *name, uint32_t *len); - /** * Get WAMR semantic version */ @@ -1619,8 +1609,8 @@ wasm_runtime_is_import_func_linked(const char *module_name, const char *func_name); /** - * Check whether an import global `(import (global ...))` - * is linked or not with runtime registered natvie globals + * Check whether an import global `(import + * (global ...))` is linked or not with runtime registered natvie globals */ WASM_RUNTIME_API_EXTERN bool wasm_runtime_is_import_global_linked(const char *module_name, @@ -1634,8 +1624,7 @@ typedef enum { typedef void (*enlarge_memory_error_callback_t)( uint32_t inc_page_count, uint64_t current_memory_size, uint32_t memory_index, enlarge_memory_error_reason_t failure_reason, - wasm_module_inst_t instance, wasm_exec_env_t exec_env, - void* user_data); + wasm_module_inst_t instance, wasm_exec_env_t exec_env, void *user_data); /** * Setup callback invoked when memory.grow fails @@ -1697,8 +1686,8 @@ wasm_runtime_set_enlarge_mem_error_callback( */ WASM_RUNTIME_API_EXTERN void * -wasm_runtime_create_context_key( - void (*dtor)(wasm_module_inst_t inst, void *ctx)); +wasm_runtime_create_context_key(void (*dtor)(wasm_module_inst_t inst, + void *ctx)); WASM_RUNTIME_API_EXTERN void wasm_runtime_destroy_context_key(void *key); @@ -1759,17 +1748,14 @@ wasm_runtime_begin_blocking_op(wasm_exec_env_t exec_env); WASM_RUNTIME_API_EXTERN void wasm_runtime_end_blocking_op(wasm_exec_env_t exec_env); - WASM_RUNTIME_API_EXTERN bool wasm_runtime_set_module_name(wasm_module_t module, const char *name, char *error_buf, uint32_t error_buf_size); /* return the most recently set module name or "" if never set before */ -WASM_RUNTIME_API_EXTERN const char* +WASM_RUNTIME_API_EXTERN const char * wasm_runtime_get_module_name(wasm_module_t module); -/* clang-format on */ - #ifdef __cplusplus } #endif diff --git a/core/shared/platform/linux-sgx/sgx_ipfs.c b/core/shared/platform/linux-sgx/sgx_ipfs.c index 32268898..4f4bbef9 100644 --- a/core/shared/platform/linux-sgx/sgx_ipfs.c +++ b/core/shared/platform/linux-sgx/sgx_ipfs.c @@ -350,7 +350,7 @@ ipfs_fopen(int fd, int flags) errno = __WASI_ECANCELED; sgx_fclose(sgx_file); os_printf("An error occurred while inserting the IPFS file pointer in " - "the map."); + "the map.\n"); return NULL; } @@ -529,4 +529,4 @@ ipfs_ftruncate(int fd, off_t len) return 0; } -#endif /* end of WASM_ENABLE_SGX_IPFS */ \ No newline at end of file +#endif /* end of WASM_ENABLE_SGX_IPFS */ diff --git a/core/shared/platform/linux-sgx/sgx_platform.c b/core/shared/platform/linux-sgx/sgx_platform.c index 3a4a1924..d97883a8 100644 --- a/core/shared/platform/linux-sgx/sgx_platform.c +++ b/core/shared/platform/linux-sgx/sgx_platform.c @@ -154,8 +154,8 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file) ret = sgx_alloc_rsrv_mem(aligned_size); if (ret == NULL) { - os_printf("os_mmap(size=%u, aligned size=%lu, prot=0x%x) failed.", size, - aligned_size, prot); + os_printf("os_mmap(size=%u, aligned size=%lu, prot=0x%x) failed.\n", + size, aligned_size, prot); return NULL; } @@ -168,7 +168,7 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file) st = sgx_tprotect_rsrv_mem(ret, aligned_size, mprot); if (st != SGX_SUCCESS) { - os_printf("os_mmap(size=%u, prot=0x%x) failed to set protect.", size, + os_printf("os_mmap(size=%u, prot=0x%x) failed to set protect.\n", size, prot); sgx_free_rsrv_mem(ret, aligned_size); return NULL; @@ -205,7 +205,8 @@ os_mprotect(void *addr, size_t size, int prot) mprot |= SGX_PROT_EXEC; st = sgx_tprotect_rsrv_mem(addr, aligned_size, mprot); if (st != SGX_SUCCESS) - os_printf("os_mprotect(addr=0x%" PRIx64 ", size=%u, prot=0x%x) failed.", + os_printf("os_mprotect(addr=0x%" PRIx64 + ", size=%u, prot=0x%x) failed.\n", (uintptr_t)addr, size, prot); return (st == SGX_SUCCESS ? 0 : -1); diff --git a/core/version.h b/core/version.h index 8f9f757a..de3f56ab 100644 --- a/core/version.h +++ b/core/version.h @@ -5,7 +5,7 @@ #ifndef _WAMR_VERSION_H_ #define _WAMR_VERSION_H_ -#define WAMR_VERSION_MAJOR 1 -#define WAMR_VERSION_MINOR 3 -#define WAMR_VERSION_PATCH 2 +#define WAMR_VERSION_MAJOR 2 +#define WAMR_VERSION_MINOR 0 +#define WAMR_VERSION_PATCH 0 #endif