Commit Graph

1513 Commits

Author SHA1 Message Date
liang.he
5377e18623
iwasm: Print help when meeting unknown cmd options (#2824) 2023-11-27 11:16:54 +08:00
Marcin Kolny
5f7079f0f5
Return error when shutdown() fails (#2801)
Fix issue reported in #2787.
2023-11-24 21:03:59 +08:00
Wenyong Huang
1ba4acd1c7
Fix wamr-test-suites script for macos (#2819)
Update the wabt release binary name for macos and fix a syntax error:

```bash
./test_wamr.sh: line 356: syntax error near unexpected token `;'
./test_wamr.sh: line 356: `                    ;&'
```
2023-11-24 16:21:05 +08:00
Daniel Mangum
2a3c93f502
Fix typos in zephyr platform struct descriptions (#2818)
Fixes typos in zephyr platform struct descriptions.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
2023-11-24 08:47:38 +08:00
Huang Qi
cb44e56b4e
Fix Zifencei extension issue in RISC-V (#2807)
Refer to:
https://github.com/bytecodealliance/wasm-micro-runtime/pull/2805
2023-11-23 10:23:33 +08:00
Daniel Mangum
2175910bac
Update Zephyr support to v3.5.0 and make instructions generic to boards (#2805)
Includes a number of updates to the Zephyr example, including removing a fair
amount of stale configuration. This is part of moving towards supporting WAMR
as a Zephyr module as described in #2782. Some functionality is removed as
part of this diff (e.g. AOT XTENSA support), but it had become stale while not
being actively maintained. It is anticipated that it (and AOT support for other
platforms) will be added back, along with CI support for ensuring they do not
become stale again.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
2023-11-23 09:56:04 +08:00
Jämes Ménétrey
f9e8b9535e
Attestation: Free JSON from the Wasm module heap (#2803)
The JSON evidence is allocated on the module instance heap, but no API
was given to dispose of this memory buffer. The sample mentions using
the function free, which behaves differently depending on the
execution context.

This fix provides a new function called librats_dispose_evidence_json,
enabling freeing the JSON evidence directly from the Wasm app.
2023-11-22 10:48:14 +08:00
Wenyong Huang
4d5eb346fc
Change is_shared_memory type from bool to uint8 (#2800)
Change WASMMemoryInstance's field is_shared_memory's type from bool
to uint8 whose size is fixed, so as to make WASMMemoryInstance's size
and layout fixed and not break AOT ABI.

See discussion in https://github.com/bytecodealliance/wasm-micro-runtime/pull/2682.
2023-11-22 10:38:08 +08:00
Huang Qi
0b29904f26
Fix configurable bounds checks typo (#2809) 2023-11-21 17:32:45 +08:00
Huang Qi
9ad42290d8
Fix formatting in wasm_dump_perf_profiling (#2799)
Changes %d to %PRIu32.
2023-11-20 18:06:35 +08:00
Wenyong Huang
103cb89593
aot compiler: Fix handle next reachable if block (#2793)
The popped reachable block may be if block whose else branch hasn't been
translated, and should push the params for the else block if there are.

And use LLVMDisposeMessage to free memory allocated in is_win_platform.
2023-11-20 17:14:10 +08:00
TianlongLiang
a57e70016a
Fix memory.init opcode issue in fast-interp (#2798)
Fix fast interpreter didn't throw OOB exception correctly in some scenarios.
Reported in #2797.
2023-11-20 16:25:43 +08:00
Huang Qi
aebe30426f
Fix formatting in aot_dump_perf_profiling (#2796)
Changes %d to %PRIu32.
2023-11-20 12:11:02 +08:00
Huang Qi
73cd1969f4
Add support for custom sections in nuttx (#2795) 2023-11-20 11:37:51 +08:00
Wenyong Huang
d4184968c0
Fix build error of libsodium benchmark (#2792) 2023-11-20 10:45:02 +08:00
Huang Qi
e8c8f7fca6
Fix return type in wasm_loader_get_custom_section (#2794)
Should return NULL instead of false.
2023-11-20 10:36:15 +08:00
Daniel Mangum
0bb157b88a
Fix comment in WAMR_MEM_DUAL_BUS_MIRROR (#2791)
Fixes a small typo in the WAMR_MEM_DUAL_BUS_MIRROR description.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
2023-11-20 10:25:00 +08:00
Daniel Mangum
657fd7bb42
Fix broken links in app-mgr README.md (#2786)
Fixes a few relative path broken links in app-mgr README.md.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
2023-11-20 10:04:45 +08:00
Huang Qi
748e745088
Disable FPU in NuttX spec test (#2781)
Fix spec test failure on NuttX with #2780, see:
https://github.com/bytecodealliance/wasm-micro-runtime/actions/runs/6910450452
2023-11-18 09:09:30 +08:00
Huang Qi
be05af79fb
Refine atomic operation flags in bh_atomic.h (#2780) 2023-11-18 08:59:58 +08:00
YAMAMOTO Takashi
562a5dd1b6
Fix data/elem drop (#2747)
Currently, `data.drop` instruction is implemented by directly modifying the
underlying module. It breaks use cases where you have multiple instances
sharing a single loaded module. `elem.drop` has the same problem too.

This PR  fixes the issue by keeping track of which data/elem segments have
been dropped by using bitmaps for each module instances separately, and
add a sample to demonstrate the issue and make the CI run it.

Also add a missing check of dropped elements to the fast-jit `table.init`.

Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2735
Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2772
2023-11-18 08:50:16 +08:00
TianlongLiang
08c0ec74c4
More precise help info of enabled targets for wamrc (#2783)
Instead of printing all support targets of wamrc, print only the targets
that are included in the LLVM library with which wamrc was compiled.
2023-11-17 19:05:00 +08:00
zoraaver
b39fd516d3
Use next generation crypto API on Windows (#2769)
CryptGenRandom is deprecated by Microsoft and may be removed in future
releases. They recommend to use the next generation API instead. See
https://learn.microsoft.com/en-us/windows/win32/seccng/cng-portal for
more details. Also, refactor the random functions to return error codes
rather than aborting the program if they fail.
2023-11-17 18:40:29 +08:00
YAMAMOTO Takashi
2d0d4a0be9
Remove unused JitBitmap (#2775)
Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2754
2023-11-16 18:48:06 +08:00
Wenyong Huang
a3349cc8c1
Fix compilation errors on zephyr platform (#2777)
Add dummy korp_rwlock struct and fix os_dir_stream definition on
platform zephyr/riot/rt-thread/alios to fix the compilation errors.
2023-11-16 18:39:41 +08:00
TianlongLiang
503d94ace2
Enable more LLVM backends for the release wamrc binary (#2778)
As mentioned in https://github.com/bytecodealliance/wasm-micro-runtime/issues/2504,
the current release `wamrc` only has X86 target enabled. This PR enables
more targets for release `wamrc`, including AArch64, ARM, Mips and RISCV.
2023-11-16 18:32:28 +08:00
Huang Qi
b92906464e
Fix printing ref.extern addresses in wasm_application.c (#2774) 2023-11-16 15:10:58 +08:00
Wenyong Huang
dd0556a729
aot compiler: Disable musttail for thumb (#2771)
Error is reported when executing `wamrc --target=thumb -o <aot_file> <wasm_file>`:
```
LLVM ERROR: failed to perform tail call elimination on a call site marked musttail
Aborted (core dumped)
```
2023-11-16 11:05:23 +08:00
Wenyong Huang
9a32e0672c
Fix aot compiler issue reported by Coverity (#2770)
Set `abi` to "gnu" for the bare-metal target when `abi` is NULL,
or the below `bh_assert` and `bh_memcpy` may deference a NULL
pointer. Error is reported when running wamrc compiled with
`cmake .. -DCMAKE_BUILD_TYPE=Debug`:
```
core/iwasm/compilation/aot_llvm.c:2584:13: runtime error:
  null pointer passed as argument 1, which is declared to never be null
```
2023-11-16 10:54:39 +08:00
Huang Qi
24aa1cb408
Extend os_mmap to support map file from fd (#2763)
Add an extra argument `os_file_handle file` for `os_mmap` to support
mapping file from a file fd, and remove `os_get_invalid_handle` from
`posix_file.c` and `win_file.c`, instead, add it in the `platform_internal.h`
files to remove the dependency on libc-wasi.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-11-16 08:28:54 +08:00
Wenyong Huang
0b8a904193
Fix fast-jit callnative translation (#2765)
Lock i32 registers before and after preparing the function arguments
to prevent they are overwritten.
2023-11-15 18:30:51 +08:00
Wenyong Huang
40d33d806b
Add compilation flag to enable/disable heap corruption check (#2766)
Heap corruption check in ems memory allocator is enabled by default
to improve the security, but it may impact the performance a lot, this
PR adds cmake variable and compiler flag to enable/disable it.
2023-11-15 17:20:50 +08:00
Daniel Mangum
fc03bc073e
Fix log messages in Zephyr example (#2761)
Fixes typo of function in log messages in Zephyr example.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
2023-11-14 09:27:57 +08:00
Huang Qi
56bfae774c
Update RISC-V compilers in Nuttx compilation CI and spec test CI (#2756)
Update RISC-V compilers in Nuttx compilation CI and spec test CI
to test workflows.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-11-14 09:21:58 +08:00
zoraaver
8c27676718
Return uint32 from WASI functions (#2749)
Returning uint16 from WASI functions is technically correct. However,
the smallest integer type in WASM is int32 and since we don't guarantee
that the upper 16 bits of the result are zero'ed, it can result in
tricky bugs if the language SDK being used in the WASM app does not cast
back immediately to uint16. To prevent this, we directly return uint32
instead, so that the result is well-defined as a 32-bit number.
2023-11-13 20:07:32 +08:00
Huang Qi
e4353b4e1f
Add eabihf ABI support and set vendor-sys of bare-metal targets (#2745)
Set the vendor-sys of bare-metal targets to "-unknown-none-",
and currently only add "thumbxxx" to the bare-metal target list.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2023-11-13 18:01:15 +08:00
Haiyue Wang
625c95816d
Fix switch-case fallthrough compilation warning (#2753)
The commit fa5e9d72b0 ("Abstract POSIX filesystem functions") introduces
the build warning:

./core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c: In function ‘fd_object_release’:
./core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c:545:20: warning: this statement may fall through [-Wimplicit-fallthrough=]
  545 |                 if (os_is_dir_stream_valid(&fo->directory.handle)) {
      |                    ^
./core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c:549:13: note: here
  549 |             default:
      |             ^~~~~~~

Refer to the commit fb4afc7ca4 ("Apply clang-format for core/iwasm compilation and libraries"),
add one line "// Fallthrough." to make compiler happy.

Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
2023-11-13 15:01:13 +08:00
Daniel Mangum
cf0da9a8c7
docs: Fix typo in export native APIs doc (#2750)
Fixes a small typo of conversion for native API documentation.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
2023-11-12 08:42:36 +08:00
Wenyong Huang
71340b79a6
Merge pull request #2740 from bytecodealliance/dev/wasi-libc-windows
The implementation is already in a stage where it's possible to compile WAMR
with wasi libc enabled and run wasi modules without errors.
2023-11-10 16:58:31 +08:00
Daniel Mangum
314ecba388
Fix CMSIS import with Zephyr 3.4+ (#2744)
Fixes the import path for CMSIS in Zephyr versions > 3.4.

See https://github.com/zephyrproject-rtos/zephyr/pull/59855 for more
information.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
2023-11-10 11:43:48 +08:00
Enrico Loparco
68b317c686
Remove TSAN suppression for execute_post_instantiate_functions (#2741)
The problem has been fixed: #2680.
2023-11-10 08:25:01 +08:00
YAMAMOTO Takashi
24c4d256b3
Grab cluster->lock when modifying exec_env->module_inst (#2685)
Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2680

And when switching back to the original module_inst, propagate exception if any.

cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/2512
2023-11-09 18:56:02 +08:00
Wenyong Huang
20f1a8c86c Merge branch main into dev/wasi-libc-windows 2023-11-09 10:13:59 +08:00
Daniel Mangum
797e534cec
Fix typo in Zephyr simple example (#2738)
Fixes small typo of elapsed in Zephyr simple example.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
2023-11-09 09:09:31 +08:00
Wenyong Huang
7f8292ffd1
Add more buffer boundary checks in wasm loader (#2734)
And fix exception not printed in `iwasm --repl` mode and resize the memory
data size to UINT32_MAX if the initial page number is 65536.
2023-11-09 08:42:05 +08:00
zoraaver
fa2839a805
Fix default vprintf on UWP (#2730)
`platform_common.h` already has a declaration for BH_VPRINTF so we can
get rid of the one in `platform_internal.h`. Also add some explicit
casts to avoid MSVC compiler warnings.
2023-11-08 20:28:34 +08:00
zoraaver
3c9cd40aa6
Provide default vprintf on UWP (#2725)
UWP apps do not have a console attached so any output to stdout/stderr
is lost. Therefore, provide a default BH_VPRINTF in that case for debug
builds which redirects output to the debugger.
2023-11-07 20:37:43 +08:00
zoraaver
77b6bce679
Move WASI types into separate header (#2724)
To allow anything to depend on WASI types, including platform-specific
data structures, move the WASI libc filesystem/clock interface into
`platform_api_extension.h`, which leaves just WASI types in
`platform_wasi.h`. And `platform_wasi.h` has been renamed to
`platform_wasi_types.h` to reflect that it only defines types now and no
function declarations. Finally, these changes allow us to remove the
`windows_fdflags` type which was essentially a duplicate of
`__wasi_fdflags_t`.
2023-11-07 09:39:15 +08:00
zoraaver
13875f43c6
Enable WASI tests on Windows CI (#2699)
Most of the WASI filesystem tests require at least creating/deleting a
file to test filesystem functionality so some additional filesystem APIs
have been implemented on Windows so we can test what has been
implemented so far. For those WASI functions which haven't been
implemented, we skip the tests. These will be implemented in a future PR
after which we can remove the relevant filters.

Additionally, in order to run the WASI socket and thread tests, we need
to install the wasi-sdk in CI and build the test source code prior to
running the tests.
2023-11-06 19:24:06 +08:00
Wenyong Huang
cc23c7ee7d
Use user defined malloc/free functions for user defined memory allocator (#2717)
Reported in #2617.
2023-11-03 15:23:31 +08:00