Commit Graph

1639 Commits

Author SHA1 Message Date
Gavin Hayes
bf9fb2e680
cosmopolitan: Update compiler and update platform_internal.h (#3079)
This fixes the cosmopolitan platform.
- Switch `build_cosmocc.sh` and platform documentation to
  explicitly use the x86_64 cosmocc compiler as multi-arch
  cosmocc won't work here. Older version `cosmocc` just did
  a x86_64 build.
- Add missing items from `platform_internal.h` to fix build.
2024-01-24 16:04:48 +08:00
Bruce Mitchener
d815bbc3db
README.md: Fix typo tunning to tuning (#3078) 2024-01-24 15:35:45 +08:00
Bruce Mitchener
61fe78c9ff
Fix download link for wasi-sdk (#3077)
The wasi-sdk repo moved from CraneStation to the WebAssembly org
on GitHub.
2024-01-24 13:42:45 +08:00
Enrico Loparco
3fcd79867d
Forward log and log level to custom bh_log callback (#3070)
Follow-up on #2907. The log level is needed in the host embedder to
better integrate with the embedder's logger.

Allow the developer to customize his bh_log callback with
`cmake -DWAMR_BH_LOG=<log_callback>`,
and update sample/basic to show the usage.
2024-01-24 13:05:07 +08:00
Marcin Kolny
1505e61704
Remove a lot of "unused parameter" warnings (#3075)
They might shadow some of the real issues, so better to keep the number
of warnings as low as possible.
2024-01-24 11:21:13 +08:00
YAMAMOTO Takashi
f56154ed80
thread-mgr: Fix locking problems around aux stack allocation (#3073)
Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/3069
2024-01-24 09:46:53 +08:00
Wenyong Huang
0eb788d711
build_wamr.md: Update the document (#3074)
Add description for `WAMR_BUILD_LINUX_PERF`, `WAMR_BUILD_QUICK_AOT_ENTRY`
and `WAMR_BUILD_MODULE_INST_CONTEXT`.
And add some reference links.
2024-01-24 09:45:57 +08:00
Wenyong Huang
9f64340529
Fix some issues reported by CodeQL (#3064)
Refer to https://github.com/bytecodealliance/wasm-micro-runtime/pull/2812
and https://github.com/bytecodealliance/wasm-micro-runtime/security/code-scanning?query=pr%3A2812+is%3Aopen
2024-01-23 21:38:30 +08:00
YAMAMOTO Takashi
ab97d543e0
wasm_cluster_destroy_spawned_exec_env: Avoid "invalid exec env" trap (#3068)
Possible alternatives:

* Make wasm_cluster_destroy_spawned_exec_env take two exec_env.
  One for wasm execution and another to specify the target to destroy.

* Make execute functions to switch exec_env as briefly discussed in
  https://github.com/bytecodealliance/wasm-micro-runtime/pull/2047
2024-01-23 15:20:01 +08:00
YAMAMOTO Takashi
b44aa654b8
aot_reloc_x86_64.c: Suggest to try --size-level=0 as well (#3067)
cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/3035
2024-01-23 13:00:19 +08:00
Wenyong Huang
c8b59588a7
Enhance setting write gs base with cmake variable (#3066)
In linux x86-64, developer can use cmake variable to configure whether
to enable writing linear memory base address to x86 GS register or not:
- `cmake -DWAMR_DISABLE_WRITE_GS_BASE=1`: disabled it
- `cmake -DWAMR_DISABLE_WRITE_GS_BASE=0`: enabled it
- `cmake` without `-DWAMR_DISABLE_WRITE_GS_BASE=1/0`:
        auto-detected by the compiler
2024-01-23 12:21:20 +08:00
Wenyong Huang
7f035d4206
perf_tune.md: Add refine the calling processes between host and wasm (#3065) 2024-01-23 12:20:28 +08:00
YAMAMOTO Takashi
4bafa40052
nuttx: If STACK_GUARD_SIZE is not set, leave it to config.h (#2927)
cf. https://github.com/apache/nuttx-apps/pull/2241
2024-01-23 11:52:25 +08:00
Marcin Kolny
627debcefb
Add flag to control Winsocket initialization (#3060)
When WAMR is embedded to other application, the lifecycle of the socket
might conflict with other usecases. E.g. if WAMR is deinitialized before any
other use of sockets, the application goes into the invalid state. The new
flag allows host application to take control over the socket initialization.
2024-01-22 07:33:26 +08:00
Xu Jun
1977ad23ef
fast-interp: Fix dynamic offset error issue in else branch (#3058)
Reported in https://github.com/bytecodealliance/wasm-micro-runtime/issues/3026.
2024-01-19 19:58:12 +08:00
YAMAMOTO Takashi
bc35602004
Fix aot large model (--size-level=0) with LLVM 18 (#3057)
The recent versions LLVM uses ".ltext" section for X86 large model.

cf. d8a04398f9

This fixes https://github.com/bytecodealliance/wasm-micro-runtime/issues/3034
2024-01-19 19:43:41 +08:00
Wenyong Huang
ec6d9cb6be
Check arguments before calling bh_hash_map_find (#3055)
Check whether the arguments are NULL before calling bh_hash_map_find,
or lots of "HashMap find elem failed: map or key is NULL" warnings may
be dumped. Reported in #3053.
2024-01-19 19:29:21 +08:00
YAMAMOTO Takashi
17b0111577
wasm_runtime_begin_blocking_op: A comment about usage expectation (#3056) 2024-01-19 18:31:21 +08:00
Wenyong Huang
a7545df5d0
classic-interp: Handle SIMD opcode when JIT is enabled (#3046)
Though SIMD isn't supported by interpreter, when JIT is enabled,
developer may run `iwasm --interp <wasm_file>` to trigger the SIMD
opcode in interpreter, which isn't handled before this PR.
2024-01-19 12:31:18 +08:00
Huang Qi
54ef0e4de7
Bump NuttX version to 12.4.x in CI (#3047) 2024-01-19 11:24:48 +08:00
YAMAMOTO Takashi
8b37048823
Do not inherit WASM_SUSPEND_FLAG_BLOCKING from the parent thread (#3051)
It seems that some users want to wrap rather large chunk of code
with wasm_runtime_begin_blocking_op/wasm_runtime_end_blocking_op.

If the wrapped code happens to have a call to
e.g. wasm_runtime_spawn_exec_env, WASM_SUSPEND_FLAG_BLOCKING is
inherited to the child exec_env and it may cause unexpected behaviors.
2024-01-19 09:55:01 +08:00
Wenyong Huang
9bcf6b4dd3
Enable quick aot entry when hw bound check is disabled (#3044)
- Enable quick aot entry when hw bound check is disabled
- Remove unnecessary ret_type argument in the quick aot entries
- Declare detailed prototype of aot function to call in each quick aot entry
2024-01-19 08:55:35 +08:00
YAMAMOTO Takashi
fde98331ff
examples/terminate: Use wasm_runtime_spawn_exec_env as well (#3049) 2024-01-18 20:44:09 +08:00
YAMAMOTO Takashi
b97370e3a8
samples/terminate: Add a sample to demonstrate wasm_runtime_terminate (#3043)
This is basically a modified copy of the "shared-module" example.
2024-01-18 15:01:03 +08:00
YAMAMOTO Takashi
d13a54f860
Revert "Enable MAP_32BIT for macOS (#2992)" (#3032)
Revert "Do not use pagezero size option if osx version >= 13 (#3025)"
and  "Enable MAP_32BIT for macOS (#2992)".

Discussion: https://github.com/bytecodealliance/wasm-micro-runtime/issues/3009
2024-01-18 09:22:09 +08:00
tkernelcn
a9807058a6
Set CONFIG_HAS_CAP_ENTER to support posix file api for freertos (#3041)
Since there is no so rich api in freertos like embedded system, simply set
CONFIG_HAS_CAP_ENTER to 1 to support posix file api for freertos.
Test file api in wasm app pass.
2024-01-17 21:20:35 +08:00
Huang Qi
64e82ca102
Disable WASM_ENABLE_SHARED_MEMORY_MMAP by default (#3042)
Fix compilation warning.
2024-01-17 19:29:31 +08:00
Huang Qi
dcaaed0160
nuttx: Add option to enable quick aot entry (#3040) 2024-01-17 16:26:53 +08:00
Wenyong Huang
6fb376cbe3
Disable quick aot entry for interp and fast-jit (#3039)
Quick aot/jit entry is only for aot and llvm jit now, no need to enable it
for interpreter and fast-jit when aot and llvm jit are disabled.
2024-01-17 16:17:08 +08:00
Xavier Del Campo
ade97ac3e1
wamr-compiler: Fix non-x86{_64} host builds (#3037)
The build system assumed sizeof (void *) == 8 as a host system
running on a x86_64 architecture, x86 otherwise. However, this
assumption is invalid for most other architectures out there, such as
aarch64 or armv7l.

This PR refers to the CMAKE_HOST_SYSTEM_PROCESSOR variable
which, according to the documentation, typically refers to the output
from "uname -m" for Unix-like systems.
2024-01-17 15:56:04 +08:00
liang.he
5c8b8a17a6
Enhancements on wasm function execution time statistic (#2985)
Enhance the statistic of wasm function execution time, or the performance
profiling feature:
- Add os_time_thread_cputime_us() to get the cputime of a thread,
  and use it to calculate the execution time of a wasm function
- Support the statistic of the children execution time of a function,
  and dump it in wasm_runtime_dump_perf_profiling
- Expose two APIs:
  wasm_runtime_sum_wasm_exec_time
  wasm_runtime_get_wasm_func_exec_time

And rename os_time_get_boot_microsecond to os_time_get_boot_us.
2024-01-17 09:51:54 +08:00
Enrico Loparco
25ccc9f2d5
Avoid unused thread_id warning and recompile multi-module sample (#3033)
- Unused variable warning (when building in release mode):
```bash
wasm-micro-runtime/samples/wasi-threads/wasm-apps/no_pthread.c:44:9:
warning: variable 'thread_id' set but not used [-Wunused-but-set-variable]
    int thread_id;
```
- When using the multi-module example and changing the files in `wasm-apps`,
  they don't get recompiled when the sample is rebuilt. Adding `BUILD_ALWAYS`
  as it's done in other samples.
2024-01-17 08:06:02 +08:00
Maks Litskevich
7b6d0a5d45
Don't redefine D_INO if already defined (#3036) 2024-01-16 22:28:06 +08:00
Marcin Kolny
ffa131b5ac
Allow using mmap for shared memory if hw bound check is disabled (#3029)
For shared memory, the max memory size must be defined in advanced. Re-allocation
for growing memory can't be used as it might change the base address, therefore when
OS_ENABLE_HW_BOUND_CHECK is enabled the memory is mmaped, and if the flag is
disabled, the memory is allocated. This change introduces a flag that allows users to use
mmap for reserving memory address space even if the OS_ENABLE_HW_BOUND_CHECK
is disabled.
2024-01-16 22:15:55 +08:00
Wenyong Huang
b3aaf2abc0
Check passive mode in fast-jit table.init (#3031)
Reported in https://github.com/bytecodealliance/wasm-micro-runtime/issues/3021.
2024-01-16 21:55:10 +08:00
Enrico Loparco
bb053e3a2d
Do not use pagezero size option if osx version >= 13 (#3025)
Reported in https://github.com/bytecodealliance/wasm-micro-runtime/issues/3009.
2024-01-16 12:14:43 +08:00
Wenyong Huang
705bf807b2
Remove deprecated tests in language-bindings python (#3018)
After PR #2922, the caller of wasm-c-api wasm_func_call should ensure
the params and results are correctly created, runtime doesn't check
their format again.
2024-01-16 10:15:56 +08:00
Enrico Loparco
c9fd44e8b8
Build samples in debug mode (#3019)
Follow-up on #3008. Compiling samples in Debug mode allows us to
take advantage of asserts and would have prevented the fix in #3008.
2024-01-16 09:36:05 +08:00
YAMAMOTO Takashi
685d55d2e7
nuttx: Use larger alignment for os_mmap and comment why (#3017)
Other platforms with malloc-based os_mmap might need similar changes
too, depending on their target cpu arch.
2024-01-16 09:17:58 +08:00
Huang Qi
915adc433d
Rename rwlock_init to avoid conflict (#3016)
This symbol is too simple to cause conflict with others, such as the RW
spinlock in Linux kernel and NuttX, so rename it to avoid the conflict.
2024-01-16 08:53:18 +08:00
Wenyong Huang
884c1abc11
Fix nightly-run CI failure (#3014)
Not know how to make `__attribute__((no_sanitize_address))` take effect
on gcc in Ubuntu-20.04, just disable quick AOT entry for wasm-c-api
sample in nightly-run CI.
2024-01-16 08:44:35 +08:00
Enrico Loparco
54bc9f2053
Increase default app thread stack size (#3010) 2024-01-15 19:05:23 +08:00
Enrico Loparco
892a94fd05
fix(wasm-c-api): Do not clone stack frames if there's no trap (#3008)
When running the wasi-threads no_pthread sample, the assert was failing
on `src->num_elems != 0` in debug mode, it is because that the exception
is `proc_exit`, there is no trap (the execution didn't fail, no stack frames):
https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/samples/wasi-threads/wasm-apps/no_pthread.c
2024-01-15 18:18:37 +08:00
YAMAMOTO Takashi
837b9904f5
aot debug: Try to use a bit more appropriate file names (#3000)
When the original wasm contains multiple compilation units, the current
logic uses the first one for everything. This commit tries to use a bit more
appropriate ones.
2024-01-15 15:02:12 +08:00
Wenyong Huang
23d2e0627c
Clear compilation warning and dead code (#3002) 2024-01-13 08:56:39 +08:00
Maks Litskevich
63012f0222
Fix build errors when initializing wasm_val_t values with macros (#3007)
Errors were reported when initializing wasm_val_t values with WASM_I32_VAL like macros.
```
 error: missing initializer for member ‘wasm_val_t::__paddings’ [-Werror=missing-field-initializers]
   64 |     wasm_val_t res = {WASM_INIT_VAL};
```
And rename DEPRECATED to WASM_API_DEPRECATED to avoid using defines with generic names.
2024-01-13 08:35:49 +08:00
YAMAMOTO Takashi
08442458b1
aot debug: Update DW_AT_producer (#3001)
Currently we are using "ant compiler", which is a bit historical.
This commit changes it to use "WAMR AoT compiler" instead.
2024-01-12 13:43:18 +08:00
Wenyong Huang
17e3bf255c
Update version number to 1.3.1 and update release notes (#2999) 2024-01-12 11:31:01 +08:00
Wenyong Huang
3198018214
Fix linux-sgx build error when libc-wasi is disabled (#2997)
Compilation error was reported when `cmake -DWAMR_BUILD_LIBC_WASI=0`
on linux-sgx platform:
```
core/shared/platform/linux-sgx/sgx_socket.c:8:10:
fatal error: libc_errno.h: No such file or directory
    8 | #include "libc_errno.h"
      |          ^~~~~~~~~~~~~~
```
After fixing, both `cmake -DWAMR_BUILD_LIBC_WASI=1` and
`WAMR_BUILD_LIBC_WASI=0` work good.
2024-01-11 14:26:39 +08:00
liang.he
9121db5671
Fix a bug when emit the custom name section to aot file (#2987)
The content in custom name section is changed after loaded since the strings
are adjusted with '\0' appended, the emitted AOT file then cannot be loaded.
The PR disables changing the content for AOT compiler to resolve it.

And disable emitting custom name section for `wamrc --enable-dump-call-stack`,
instead, use `wamrc --emit-custom-sections=name` to emit it.
2024-01-11 13:14:54 +08:00