Commit Graph

279 Commits

Author SHA1 Message Date
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
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
Wenyong Huang
3570a94a08
Fix issues reported by Coverity (#2681)
Fix multi-module issues and gui sample issues reported by Coverity.
And refine the build script of go language-binding sample.
2023-10-31 10:48:51 +08:00
Alfred E. Neumayer
9b8fe049b3
core/iwasm: Support mapped file system access on non-libuv WASI (#2628)
This patch enables mapping host directories to guest directories by parsing
the `map_dir_list` argument in API `wasm_runtime_init_wasi` for libc-wasi. It
follows the format `<guest-path>::<host-path>`.

It also adds argument `--map-dir=<guest::host>` argument for `iwasm`
common line tool, and allows to add multiple mappings:
```bash
iwasm --map-dir=<guest-path1::host-path1> --map-dir=<guest-path2::host-path2> ...
```
2023-10-27 12:48:10 +08:00
zoraaver
e7a62d2099
Refactor clock functions to use WASI types (#2666)
Refactoring the clock functions to use WASI types so we can simplify the
code and remove some unnecessary boilerplate. See
https://github.com/bytecodealliance/wasm-micro-runtime/pull/2637#discussion_r1362202879
for details.
2023-10-25 18:06:04 +08:00
fadumina1
a874bf0ff8
Implement wasi clock_time/clock_res get (#2637)
Add os_clock_res_get and os_clock_time_get in platform_api_extension.h,
and implement them in posix like platforms and windows platform.
2023-10-22 21:11:29 +08:00
zoraaver
fa5e9d72b0
Abstract POSIX filesystem functions (#2585)
To allow non-POSIX platforms such as Windows to support WASI libc
filesystem functionality, create a set of wrapper functions which provide a
platform-agnostic interface to interact with the host filesystem. For now,
the Windows implementation is stubbed but this will be implemented
properly in a future PR. There are no functional changes in this change,
just a reorganization of code to move any direct POSIX references out of
posix.c in the libc implementation into posix_file.c under the shared
POSIX sources.

See https://github.com/bytecodealliance/wasm-micro-runtime/issues/2495 for a
more detailed overview of the plan to port the WASI libc filesystem to Windows.
2023-10-19 19:19:39 +08:00
zoraaver
5fd530610a
Enable MASM automatically in runtime_lib.cmake (#2634)
MASM (Microsoft Macro Assembler) needs to be enabled to successfully
compile .asm files on Windows. Without enabling this language
automatically in runtime_lib.cmake, Windows cmake projects using WAMR
get hard-to-diagnose linker errors about missing symbols as the assembly
file is not compiled at all.
2023-10-12 20:42:25 +08:00
Wenyong Huang
e222955f31 Merge branch main into dev/wasi-libc-windows 2023-10-09 09:24:00 +08:00
Wenyong Huang
7c22bde8dc
CI: Enable testing AOT multi-module feature (#2621)
And refine some code pieces.
2023-10-08 08:36:49 +08:00
Gavin Hayes
d8ee771e28
Add Cosmopolitan Libc Platform (#2598)
This PR adds the Cosmopolitan Libc platform enabling compatibility with multiple
x86_64 operating systems with the same binary. The platform is similar to the
Linux platform, but for now only x86_64 with interpreter modes are supported.

The only major change to the core is `posix.c/convert_errno()` was rewritten to use
a switch statement. With Cosmopolitan errno values depend on the currently
running operating system, and so they are non-constant and cannot be used in array
designators. However, the `cosmocc` compiler allows non-constant case labels in
switch statements, enabling the new version.

And updated wamr-test-suites script to add `-j <platform>` option. The spec tests
can be ran via `CC=cosmocc ./test_wamr.sh -j cosmopolitan -t classic-interp`
or `CC=cosmocc ./test_wamr.sh -j cosmopolitan -t fast-interp`.
2023-10-04 21:55:37 +08:00
Enrico Loparco
00539620e9
Improve stack trace dump and fix coding guideline CI (#2599)
Avoid the stack traces getting mixed up together when multi-threading is enabled
by using exception_lock/unlock in dumping the call stacks.

And remove duplicated call stack dump in wasm_application.c.

Also update coding guideline CI to fix the clang-format-12 not found issue.
2023-09-29 10:52:54 +08:00
dongsheng28849455
79b27c1934
Support muti-module for AOT mode (#2482)
Support muti-module for AOT mode, currently only implement the
multi-module's function import feature for AOT, the memory/table/
global import are not implemented yet.

And update wamr-test-suites scripts, multi-module sample and some
CIs accordingly.
2023-09-28 08:56:11 +08:00
ZHU Hao
47daaeecc7
Fix compiling error for RT-Thread (#2569)
struct dfs_fd has been deprecated
2023-09-21 13:33:03 +08:00
YAMAMOTO Takashi
444b159963
Implement async termination of blocking thread (#2516)
Send a signal whose handler is no-op to a blocking thread to wake up
the blocking syscall with either EINTR equivalent or partial success.

Unlike the approach taken in the `dev/interrupt_block_insn` branch (that is,
signal + longjmp similarly to `OS_ENABLE_HW_BOUND_CHECK`), this PR
does not use longjmp because:
* longjmp from signal handler doesn't work on nuttx
  refer to https://github.com/apache/nuttx/issues/10326
* the singal+longjmp approach may be too difficult for average programmers
  who might implement host functions to deal with

See also https://github.com/bytecodealliance/wasm-micro-runtime/issues/1910
2023-09-20 18:11:52 +08:00
YAMAMOTO Takashi
9c34fc3514
Fix build with ancient GCC (4.8) (#2553)
Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2552
2023-09-15 16:24:12 +08:00
YAMAMOTO Takashi
a6fda9b7ab
Add an API to terminate instance (#2538)
Add API wasm_runtime_terminate to terminate a module instance
by setting "terminated by user" exception to the module instance.

And update the product-mini of posix platforms.

Note: this doesn't work for some situations like blocking system calls.
2023-09-13 17:09:31 +08:00
YAMAMOTO Takashi
6c846acc59
Implement module instance context APIs (#2436)
Introduce module instance context APIs which can set one or more contexts created
by the embedder for a wasm module instance:
```C
    wasm_runtime_create_context_key
    wasm_runtime_destroy_context_key
    wasm_runtime_set_context
    wasm_runtime_set_context_spread
    wasm_runtime_get_context
```

And make libc-wasi use it and set wasi context as the first context bound to the wasm
module instance.

Also add samples.

Refer to https://github.com/bytecodealliance/wasm-micro-runtime/issues/2460.
2023-09-07 14:54:11 +08:00
YAMAMOTO Takashi
9e3904337e
Revert "Return error when exception was raised after main thread finishes" (#2524)
This reverts commit 71d43f3ca1.
2023-09-04 18:01:09 +08:00
Wenyong Huang
b7a9da1620 Merge branch main into dev/wasi-libc-windows 2023-08-23 17:05:19 +08:00
Marcin Kolny
aefb265b0d
Move commn iwasm code related to WASI to a shared file (#2477) 2023-08-18 10:37:41 +08:00
Wenyong Huang
e2f8721ec9
Fix issues reported by Coverity and clear windows warnings (#2467) 2023-08-17 10:54:02 +08:00
Jämes Ménétrey
365cdfeb71
Upgrade SGX-RA integration for 0.1.2 and Ubuntu 20.04 (#2454) 2023-08-15 10:12:43 +08:00
YAMAMOTO Takashi
5780effc07
iwasm: Fix native lib cleanup after error occurs (#2443)
- If something failed after calling init_native_lib, call deinit_native_lib to clean up.
- Restructure the relevant code for better maintainability.
2023-08-14 14:05:59 +08:00
YAMAMOTO Takashi
a550f4d9f7
iwasm: call native lib init/deinit if exists (#2439) 2023-08-10 09:26:52 +08:00
Marcin Kolny
ea763009b7
Enable running spec tests on Windows (#2423)
Update wamr-test-suites scripts to enable running spec tests on Windows.
We don't enable those tests in CI yet as not all of them are passing.
2023-08-09 09:40:59 +08:00
Wenyong Huang
a07d8160f9
Merge pull request #2426 from bytecodealliance/main
Merge branch main into dev/wasi-libc-windows
2023-08-06 08:50:21 +08:00
Wenyong Huang
8fc621a1b2
Add runtime inited checks in Enclave command handlings to improve security (#2416)
Call ecall commands arbitrarily from host when enclave's runtime isn't initialized
may cause unexpected behavior, for example, load/instantiate wasm module.
Add runtime inited status checks in enclave to improve the security.

Also fix `wait_map` issue mentioned in
https://github.com/bytecodealliance/wasm-micro-runtime/issues/2252#issuecomment-1634940219
2023-08-04 14:32:04 +08:00
dongheng
ada7e3fe88
ESP-IDF platform supports to load AOT to PSRAM and run it (#2385) 2023-07-27 10:17:21 +08:00
dongsheng28849455
fbe072c0d3
Bring up WAMR on esp32-s3 device (#2348)
esp32-s3's instruction memory and data memory can be accessed through mutual mirroring way,
so we define a new feature named as WASM_MEM_DUAL_BUS_MIRROR.
2023-07-21 07:54:13 +08:00
Marcin Kolny
662e38e9b0
[Partial] Build wasi-libc for Windows (#2338)
Build wasi-libc library on Windows since libuv may be not supported. This PR is a first step
to make it working, but there's still a number of changes to get it fully working.
2023-07-13 21:02:29 +08:00
Bananymous
81f0371f63
Fix typo in zephyr's Dockerfile.old (#2354)
Dockerfile had command 'pip install --no-cache-doir' which caused
the image build to fail. Fix this to correctly say '--no-cache-dir'.
2023-07-11 14:41:12 +08:00
YAMAMOTO Takashi
7448a994ed
iwasm: Disable app heap by default if wasi is enabled (#2346)
It's rare to require app heap with wasi and sometimes harmful in some cases:
https://github.com/bytecodealliance/wasm-micro-runtime/issues/2275
2023-07-07 16:09:15 +08:00
YAMAMOTO Takashi
a300b627d5
nuttx: Add a kconfig for wasi-threads (#2343)
nuttx apps counterpart: https://github.com/apache/nuttx-apps/pull/1823
2023-07-07 15:12:00 +08:00
TianlongLiang
e495276646
Add docker file to fix Zephy ESP32 linking issue (#2314)
- Provide a Dockerfile.old to fix issue of ESP32 custom linker scripts not working
  properly with the newer version of Zephyr, as reported in #2263
- Provide a Dockerfile with newer Zephyr for other boards
- Update the corresponding document
2023-07-06 10:11:39 +08:00
Huang Qi
18092f86cc
Make memory access boundary check behavior configurable (#2289)
Allow to use `cmake -DWAMR_CONFIGURABLE_BOUNDS_CHECKS=1` to
build iwasm, and then run `iwasm --disable-bounds-checks` to disable the
memory access boundary checks.

And add two APIs:
`wasm_runtime_set_bounds_checks` and `wasm_runtime_is_bounds_checks_enabled`
2023-07-04 16:21:30 +08:00
YAMAMOTO Takashi
5c13bbbde7
product-mini/platforms/linux: Mark vmlib POSITION_INDEPENDENT_CODE (#2323)
This fixes armhf build:
https://github.com/bytecodealliance/wasm-micro-runtime/issues/2315

Note: This is not the only place which seems to have the same problem.
For example, many of examples sharing the similar structure probably
have the same problem. This commit leaves them for now.
2023-06-29 14:57:27 +08:00
tonibofarull
ac9e789951
wasi-nn: Simplify cmake and headers' location (#2308)
Major changes:
- Public headers inside `wasi-nn/include`
- Put cmake files in `cmake` folder
- Make linux iwasm link with `${WASI_NN_LIBS}` so iwasm can enable wasi-nn
2023-06-26 09:29:05 +08:00
TianlongLiang
2f01cb7b7a
Enable static PGO for Linux SGX (#2270)
Enable static PGO for Linux SGX and update the related benchmarks
test scripts and documents.
2023-06-09 14:13:43 +08:00
YAMAMOTO Takashi
6e3c3fe9ec
Fix build error with LLVM 16 (#2259) 2023-06-06 13:45:18 +08:00
Wenyong Huang
8d88471c46
Implement AOT static PGO (#2243)
LLVM PGO (Profile-Guided Optimization) allows the compiler to better optimize code
for how it actually runs. This PR implements the AOT static PGO, and is tested on
Linux x86-64 and x86-32. The basic steps are:

1. Use `wamrc --enable-llvm-pgo -o <aot_file_of_pgo> <wasm_file>`
   to generate an instrumented aot file.
2. Compile iwasm with `cmake -DWAMR_BUILD_STATIC_PGO=1` and run
      `iwasm --gen-prof-file=<raw_profile_file> <aot_file_of_pgo>`
    to generate the raw profile file.
3. Run `llvm-profdata merge -output=<profile_file> <raw_profile_file>`
    to merge the raw profile file into the profile file.
4. Run `wamrc --use-prof-file=<profile_file> -o <aot_file> <wasm_file>`
    to generate the optimized aot file.
5. Run the optimized aot_file: `iwasm <aot_file>`.

The test scripts are also added for each benchmark, run `test_pgo.sh` under
each benchmark's folder to test the AOT static pgo.
2023-06-05 09:17:39 +08:00
Wenyong Huang
76be848ec3
Implement the segue optimization for LLVM AOT/JIT (#2230)
Segue is an optimization technology which uses x86 segment register to store
the WebAssembly linear memory base address, so as to remove most of the cost
of SFI (Software-based Fault Isolation) base addition and free up a general
purpose register, by this way it may:
- Improve the performance of JIT/AOT
- Reduce the footprint of JIT/AOT, the JIT/AOT code generated is smaller
- Reduce the compilation time of JIT/AOT

This PR uses the x86-64 GS segment register to apply the optimization, currently
it supports linux and linux-sgx platforms on x86-64 target. By default it is disabled,
developer can use the option below to enable it for wamrc and iwasm(with LLVM
JIT enabled):
```bash
wamrc --enable-segue=[<flags>] -o output_file wasm_file
iwasm --enable-segue=[<flags>] wasm_file [args...]
```
`flags` can be:
    i32.load, i64.load, f32.load, f64.load, v128.load,
    i32.store, i64.store, f32.store, f64.store, v128.store
Use comma to separate them, e.g. `--enable-segue=i32.load,i64.store`,
and `--enable-segue` means all flags are added.

Acknowledgement:
Many thanks to Intel Labs, UC San Diego and UT Austin teams for introducing this
technology and the great support and guidance!

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
Co-authored-by: Vahldiek-oberwagner, Anjo Lucas <anjo.lucas.vahldiek-oberwagner@intel.com>
2023-05-26 10:13:33 +08:00
Zzzabiyaka
27239723a9
Add asan and ubsan to WAMR CI (#2161)
Add nightly (UTC time) checks with asan and ubsan, and also put gcc-4.8 build
to nightly run since we don't need to run it with every PR.

Co-authored-by: Maksim Litskevich <makslit@amazon.co.uk>
2023-05-26 09:45:37 +08:00
Wenyong Huang
1e5f206464
Fix compile warnings on windows platform (#2208) 2023-05-15 13:48:48 +08:00
Enrico Loparco
71d43f3ca1
Return error when exception was raised after main thread finishes (#2169)
Currently, if a thread is spawned and raises an exception after the main thread
has finished, iwasm returns with success instead of returning 1 (i.e. error).

Since wasm_runtime_get_wasi_exit_code waits for all threads to finish and only
returns the wasi exit code, this PR performs the exception check again and
returns error if an exception was raised.
2023-05-05 09:20:05 +08:00
Marcin Kolny
9adc6948d8
Enable CI build for gcc 4.8 on linux (#2106)
In #1928 we added support for GCC 4.8 but we don't continuously test if it's
working. This PR added a GitHub actions job to test compilation on GCC 4.8
for interpreters and Fast JIT (LLVM JIT/AOT might be added in the future).

The compilation is done using ubuntu 14.04 image as that's the simplest way
to get GCC 4.8 compiler. The job only compiles the code but does not run any
tests.
2023-04-06 10:10:07 +08:00
liang.he
d0fb2716b6
Fix several issues in CI binary releasing (#2064) 2023-03-26 12:19:45 +08:00
Huang Qi
ea50bd2aca
Support dump call stack on exception and dump call stack on nuttx (#2042) 2023-03-22 18:11:53 +08:00
Wenyong Huang
9b9ae0cfac
Update cmake files and wamr-test-suites to support collect code coverage (#1992)
Support collecting code coverage with wamr-test-suites script by using
lcov and genhtml tools, eg.:
  cd tests/wamr-test-suites
  ./test_wamr.sh -s spec -b -P -C

The default code coverage and html files are generated at:
  tests/wamr-test-suites/workspace/wamr.lcov
  tests/wamr-test-suites/workspace/wamr-lcov.zip

And update wamr-test-suites scripts to support testing GC spec cases to
avoid frequent synchronization conflicts between branch main and dev/gc.
2023-02-28 17:38:18 +08:00
Wenyong Huang
e170c355a2 Merge branch main into dev/wasi_threads 2023-02-17 08:46:12 +08:00
YAMAMOTO Takashi
ee1871d3f8
Enable iwasm --max-threads option for wasi-threads as well (#1939) 2023-02-07 13:46:41 +08:00
Wenyong Huang
40a14b51c5
Enable running mode control for runtime and module instance (#1923)
Enable setting running mode when executing a wasm bytecode file
- Four running modes are supported: interpreter, fast-jit, llvm-jit and multi-tier-jit
- Add APIs to set/get the default running mode of the runtime
- Add APIs to set/get the running mode of a wasm module instance
- Add running mode options for iwasm command line tool

And add size/opt level options for LLVM JIT
2023-02-02 18:16:01 +08:00
Patryk
965edff4df
Remove unused variable in handle_cmd_unload_module (#1913) 2023-01-25 11:07:25 +08:00
Wenyong Huang
3403f0a7f4 Merge main into dev/wasi_threads 2023-01-03 18:15:23 +08:00
Wenyong Huang
26728cbef2
Remove unnecessary ret value control when spec test is enabled (#1839)
wamr-test-suites scripts can handle the return value correctly when
spec test is enabled.
2022-12-27 16:34:44 +08:00
TianlongLiang
2953614cb8
Port WAMR to the FreeBSD platform and update the document (#1825) 2022-12-24 10:11:10 +08:00
Marcin Kolny
684ae6554d
Create a placeholder for WASI threads implementation (#1783)
This a simpler version of the PR: https://github.com/bytecodealliance/wasm-micro-runtime/pull/1638
2022-12-06 21:11:27 +08:00
Wenyong Huang
12bcc20710
Implement invokeNative asm code for MinGW (#1753)
And update the document of building iwasm for MinGW.
2022-11-28 17:48:06 +08:00
Wenyong Huang
ec5ab8274d
Fix zephyr sample build errors (#1757) 2022-11-28 11:23:51 +08:00
Huang Qi
9c5e1cb600
wamr-test-suites: Add support for ARM/RISCV by QEMU (#1704)
Enhance wamr-test-suites to add QEMU and Firmware options:
`./test_wamr.sh -Q <qemu> -F <firmware>`
2022-11-28 10:45:32 +08:00
Huang Qi
93d3d09aa1
Clear some warnings and enable -Werror for NuttX (#1756) 2022-11-28 09:44:33 +08:00
Wenyong Huang
29b76dd275
Create module hash for each module in SGX lib-rats (#1745)
Current SGX lib-rats wasm module hash is stored in a global buffer,
which may be overwritten if there are multiple wasm module loadings.
We move the module hash into the enclave module to resolve the issue.

And rename the SGX_IPFS macro/variable in Makefile and Enclave.edl to
make the code more consistent.

And refine the sgx-ra sample document.
2022-11-24 21:48:50 +08:00
YAMAMOTO Takashi
1032aac60b
Add wasm_runtime_get_wasi_exit_code (#1748)
Refer to https://github.com/bytecodealliance/wasm-micro-runtime/issues/1738
2022-11-24 20:26:18 +08:00
Wenyong Huang
8dc9d6dc4f
Enlarge the default wasm operand stack size to 64KB (#1746)
Enlarge the default wasm operand stack size to 64KB since the original default
size 16KB is a little small, and the operand stack overflow exception is often
thrown when running wasm apps.
2022-11-24 15:50:05 +08:00
Zeuson
656a8427e6
linux-sgx: Improve the remote attestation (#1695)
The current implementation of remote attestation does not take into
account the integrity of the wasm module. The SHA256 of the wasm
module has been put into user_data to generate the quote, and more
parameters are exposed for further verification.
2022-11-22 14:45:03 +08:00
Huang Qi
b5efadf205
nuttx: Enable ref types by Kconfig (#1711) 2022-11-17 11:56:59 +08:00
Wenyong Huang
c70e1ebc3d
Avoid generating some unused LLVM IRs (#1696)
Refine the generated LLVM IRs at the beginning of each LLVM AOT/JIT function
to fasten the LLVM IR optimization:
- Only create argv_buf if there are func calls in this function
- Only create native stack bound if stack bound check is enabled
- Only create aux stack info if there is opcode set_global_aux_stack
- Only create native symbol if indirect_mode is enabled
- Only create memory info if there are memory operations
- Only create func_type_indexes if there is opcode call_indirect
2022-11-14 14:32:35 +08:00
dongsheng28849455
f59ffa0d63
Enable Nuttx spec test option and register aot symbols (#1687)
Enable spec test option on Nuttx platform.
Register sqrt/sqrtf in aot global symbol map and
_fixdfdi/__floatundidf in xtensa symbol map.
2022-11-08 12:42:19 +08:00
Wenyong Huang
7fd37190e8
Add control for the native stack check with hardware trap (#1682)
Add a new options to control the native stack hw bound check feature:
- Besides the original option `cmake -DWAMR_DISABLE_HW_BOUND_CHECK=1/0`,
  add a new option `cmake -DWAMR_DISABLE_STACK_HW_BOUND_CHECK=1/0`
- When the linear memory hw bound check is disabled, the stack hw bound check
   will be disabled automatically, no matter what the input option is
- When the linear memory hw bound check is enabled, the stack hw bound check
  is enabled/disabled according to the value of input option
- Besides the original option `--bounds-checks=1/0`, add a new option
  `--stack-bounds-checks=1/0` for wamrc

Refer to: https://github.com/bytecodealliance/wasm-micro-runtime/issues/1677
2022-11-07 18:26:33 +08:00
Huang Qi
4b6e4e1732
Correct the arch name for armv7a on NuttX (#1678) 2022-11-03 21:54:05 +08:00
dongsheng28849455
e517dbc7b2
XIP adaptation for xtensa platform (#1636)
Add macro WASM_ENABLE_WORD_ALING_READ to enable reading
1/2/4 and n bytes data from vram buffer, which requires 4-byte addr
alignment reading.

Eliminate XIP AOT relocations related to the below ones:
   i32_div_u, f32_min, f32_max, f32_ceil, f32_floor, f32_trunc, f32_rint
2022-10-31 17:25:24 +08:00
YAMAMOTO Takashi
77ff7daaf4
Add wasm_runtime_unregister_natives (#1647)
Allow to unregister (or unload) the previously registered native libs,
so that no need to restart the whole engine by using
`wasm_runtime_destroy/wasm_runtime_init`.
2022-10-28 11:03:39 +08:00
Jämes Ménétrey
6adf9194d4
Normalize how the global heap pool is configured across iwasm apps (#1628)
Use the cmake variable `WAMR_BUILD_GLOBAL_HEAP_POOL` and
`WAMR_BUILD_GLOBAL_HEAP_SIZE` to enable/disable the global heap pool
and set its size. And set the default global heap size in core/config.h and
the cmake files.

As a result, the developers who build iwasm can easily enable/disable the
global heap pool and change its size regardless of the iwasm implementation,
without manually finding and patching the right location for that value.
2022-10-25 21:36:24 +08:00
Peter Bee
ceff11ee7e
core/iwasm: Fix build on arm64 host (macOS) (#1625)
Add aarch64 files on nuttx platform

Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
Change-Id: Idf94cf6aba01f1f9191412a71ef31c1a3b944c78
2022-10-21 11:15:51 +08:00
YAMAMOTO Takashi
654ac5feca
Use cmake POSITION_INDEPENDENT_CODE instead of hardcoding -pie -fPIE (#1598)
This fixes unused option warnings on -pie for macOS.
(On macOS cmake produces "-fPIE -Xlinker -pie")

Bump required cmake version to 3.14 for CheckPIESupported.

References:
https://cmake.org/cmake/help/latest/prop_tgt/POSITION_INDEPENDENT_CODE.html
https://cmake.org/cmake/help/latest/module/CheckPIESupported.html#module:CheckPIESupported
2022-10-19 01:51:18 +08:00
Wenyong Huang
a182926a73
Refactor interpreter/AOT module instance layout (#1559)
Refactor the layout of interpreter and AOT module instance:
- Unify the interp/AOT module instance, use the same WASMModuleInstance/
  WASMMemoryInstance/WASMTableInstance data structures for both interpreter
  and AOT
- Make the offset of most fields the same in module instance for both interpreter
  and AOT, append memory instance structure, global data and table instances to
  the end of module instance for interpreter mode (like AOT mode)
- For extra fields in WASM module instance, use WASMModuleInstanceExtra to
  create a field `e` for interpreter
- Change the LLVM JIT module instance creating process, LLVM JIT uses the WASM
  module and module instance same as interpreter/Fast-JIT mode. So that Fast JIT
  and LLVM JIT can access the same data structures, and make it possible to
  implement the Multi-tier JIT (tier-up from Fast JIT to LLVM JIT) in the future
- Unify some APIs: merge some APIs for module instance and memory instance's
  related operations (only implement one copy)

Note that the AOT ABI is same, the AOT file format, AOT relocation types, how AOT
code accesses the AOT module instance and so on are kept unchanged.

Refer to:
https://github.com/bytecodealliance/wasm-micro-runtime/issues/1384
2022-10-18 10:59:28 +08:00
Hanged Fish
3fe441844c
Add ios support for product-mini (#1602)
Generate `xcodeproj`, that could build iwasm shared library for iOS or iOS Simulator

Signed-off-by: HangedFish <bravohangedman@outlook.com>
2022-10-18 07:52:38 +08:00
Jämes Ménétrey
dfd16f8e4f
linux-sgx: Implement SGX IPFS as POSIX backend for file interaction (#1489)
This PR integrates an Intel SGX feature called Intel Protection File System Library (IPFS)
into the runtime to create, operate and delete files inside the enclave, while guaranteeing
the confidentiality and integrity of the data persisted. IPFS can be referred to here:
https://www.intel.com/content/www/us/en/developer/articles/technical/overview-of-intel-protected-file-system-library-using-software-guard-extensions.html

Introduce a cmake variable `WAMR_BUILD_SGX_IPFS`, when enabled, the files interaction
API of WASI will leverage IPFS, instead of the regular POSIX OCALLs. The implementation
has been written with light changes to sgx platform layer, so all the security aspects
WAMR relies on are conserved.

In addition to this integration, the following changes have been made:
 - The CI workflow has been adapted to test the compilation of the runtime and sample
    with the flag `WAMR_BUILD_SGX_IPFS` set to true
 - Introduction of a new sample that demonstrates the interaction of the files (called `file`),
 - Documentation of this new feature
2022-09-28 13:09:58 +08:00
Wenyong Huang
78b5c5b484
Merge dev/socket into main (#1393)
Implement more socket APIs, refer to #1336 and below PRs:
- Implement wasi_addr_resolve function (#1319)
- Fix socket-api byte order issue when host/network order are the same (#1327)
- Enhance sock_addr_local syscall (#1320)
- Implement sock_addr_remote syscall (#1360)
- Add support for IPv6 in WAMR (#1411)
- Implement ns lookup allowlist (#1420)
- Implement sock_send_to and sock_recv_from system calls (#1457)
- Added http downloader and multicast socket options (#1467)
- Fix `bind()` calls to receive the correct size of `sockaddr` structure (#1490)
- Assert on correct parameters (#1505)
- Copy only received bytes from socket recv buffer into the app buffer (#1497)

Co-authored-by: Marcin Kolny <mkolny@amazon.com>
Co-authored-by: Marcin Kolny <marcin.kolny@gmail.com>
Co-authored-by: Callum Macmillan <callumimacmillan@gmail.com>
2022-09-22 21:46:14 +08:00
TianlongLiang
ee210d019f
Dockerfile lint errors fix (#1493)
Fix the Dockerfile linter errors and most warnings
2022-09-22 13:06:11 +08:00
YAMAMOTO Takashi
aba3707529
build_llvm.sh: enable to pass through arguments (#1506)
To make it simpler to specify `--project`.
2022-09-20 17:54:50 +08:00
Zeuson
729c4aeeaa
Enable remote attestation by librats in SGX mode (#1445)
Add library librats, update SGX build scripts, add sample and update document.
2022-09-06 14:29:58 +08:00
Huang Qi
8fcc556e50
ci: Cover more configurations & targets on NuttX (#1448)
Enable building iwasm on Nuttx for target:
* x86
* cortex-m0
* cortex-m4
* cortex-m7
* rv32imac
* rv64imac
* rv64gc
2022-09-05 12:12:32 +08:00
Wenyong Huang
d095876ae6
Enable memory leak check (#1429)
Report the memory leak info when building iwasm with
`cmake .. -DWAMR_BUILD_GC_VERIFY=1`
2022-09-01 16:15:00 +08:00
Huang Qi
c64186b704
Fix potential warning of printf in main.c of posix and windows (#1440) 2022-09-01 14:11:00 +08:00
YAMAMOTO Takashi
7e02be836f
nuttx: Add CONFIG_INTERPRETERS_WAMR_DEBUG_INTERP (#1426)
the corresponding nuttx PR: https://github.com/apache/incubator-nuttx-apps/pull/1299
2022-08-30 18:38:28 +08:00
YAMAMOTO Takashi
ebcbe0b571
wasm_application.c: Do not start debug instance automatically (#1407)
Leave the control from wasm_application_execute_main to host embedders,
eg. product-mini.
2022-08-24 20:50:26 +08:00
YAMAMOTO Takashi
5586f7b82d
source debug: Remove unused platform_port (#1403) 2022-08-24 16:39:32 +08:00
YAMAMOTO Takashi
d41543f829
cmake: Use CMAKE_BINARY_DIR instead of ${CMAKE_CURRENT_SOURCE_DIR}/build (#1410) 2022-08-24 15:57:03 +08:00
liang.he
717e8a48e2
Enable the semantic version mechanism for WAMR (#1374)
Use the semantic versioning (https://semver.org) to replace the current date
versioning system, which is more general and is requested by some developers,
e.g. issue #1357.

There are three parts in the new version string:
- major. Any incompatible modification on ABIs and APIs will lead to an increment
  in the value of major, which mainly includes: AOT calling conventions, AOT file
  format, wasm_export.h, wasm_c_api.h, and so on.
- minor. It represents new features, including MVP/POST-MVP features, libraries,
  WAMR private ones, and so one.
- patch. It represents patches.

The new version will start from 1.0.0. Update the help info and version showing for
iwasm and wamrc.
2022-08-18 19:01:05 +08:00
Wenyong Huang
9cf7b88bad
Enhance cmake makefiles (#1390)
Upgrade `cmake_minimum_required` from `(VERSION 2.8)` to `(VERSION 2.9)` to
yield the warning:
"Compatibility with CMake < 2.8.12 will be removed from a future version of CMake"

Add "-Wno-unused" for CMAKE_CXX_FLAGS to yield the compilation warnings
when build LLVM JIT.

Fix the link error when code coverage is enabled.
2022-08-18 16:27:01 +08:00
Wenyong Huang
6caa6b1d73
Support get return value for SGX os_printf/os_vprintf (#1387)
Fix the issue reported in #1359, change the implementation of
os_printf/os_vprintf for Intel SGX to get the actual bytes written.
2022-08-16 14:23:34 +08:00
YAMAMOTO Takashi
e0a943ee9c
nuttx: Provide a default WASM_STACK_GUARD_SIZE (#1386)
Unbreak builds with a bit older nuttx/apps for now.

Note: The default value here (0) was chosen to match the new default
in nuttx/apps, which is different from the old value used before
the introduction of WASM_STACK_GUARD_SIZE. (1024)
2022-08-15 19:49:39 +08:00
Xu Jun
bc86674a45
Let iwasm return non-zero value when running failed (#1377)
Let iwasm return non-zero value when running failed
so that the caller (e.g. test framework) can check the
running status according to the return value.
2022-08-12 18:03:14 +08:00
Huang Qi
88cf1e36c1
Support custom stack guard size (#1368)
Add a new option WAMR_BUILD_STACK_GUARD_SIZE to set the custom
stack guard size. For most RTOS systems, we use the native stack base
address as the check boundary which may be not safe as POSIX based
systems (like Linux).
2022-08-12 10:17:11 +08:00
Huang Qi
2ee01657a6
Add semaphore support for NuttX (#1367) 2022-08-09 19:35:16 +08:00
Wenyong Huang
bf28030993
Import WAMR Fast JIT (#1343)
Import WAMR Fast JIT which is a lightweight JIT with quick startup, small footprint,
relatively good performance (~40% to ~50% of LLVM JIT) and good portability.

Platforms supported: Linux, MacOS and Linux SGX.
Arch supported: x86-64.
2022-08-02 16:03:50 +08:00
liang.he
ab752cd5c3
Apply latest env variables in github host runner to fix CI (#1334)
Currently we are using `ANDROID_HOME` and `ANDROID_NDK_LATEST_HOME`.
All variables should follow definitions in https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md#environment-variables-3
2022-07-27 14:11:51 +08:00
Cengizhan Pasaoglu
2746d29751
Make robust on choosing target assumption for X86_32 support (#1241)
When WAMR_BUILD_TARGET isn't set, choosing right target is decided
by checking `CMAKE_SIZEOF_VOID_P` variable. However, choosing `X86_32`
target is not doing specifically checking size of void pointer. It is kind
a fallback target for others.

This patch explicitly checks the size of void pointer before setting the target
to `X86_32` to fix the issue.
2022-06-27 20:30:31 +08:00