Commit Graph

1146 Commits

Author SHA1 Message Date
tonibofarull
e53ab91439
Integrate WASI-NN into WAMR (#1521)
Initial integration of WASI-NN based on #1225:
- Implement the library core/iwasm/libraries/wasi-nn
- Support TensorFlow, CPU, F32 at the first stage
- Add cmake variable `-DWAMR_BUILD_WASI_NN`
- Add test case based on Docker image and update document

Refer to #1573
2022-10-12 12:09:29 +08:00
Jämes Ménétrey
78c38d088e
linux-sgx: Implement POSIX calls based on getsockname and set/getbooloption (#1574) 2022-10-12 09:57:01 +08:00
YAMAMOTO Takashi
1e22d1a9e5
Fix the "register native with iwasm" stuff for macOS (#1558)
- core/shared/platform/darwin/platform_internal.h: macOS has dlopen
- samples/native-lib/README.md: Mention macOS
2022-10-07 15:17:36 +08:00
Callum Macmillan
5ddc335a7f
Add timeout send/recv and multicast client/server socket examples (#1519)
Add a couple of socket examples that can be used with WAMR:
- The `timeout_client` and `timeout_server` examples demonstrate socket
  send and receive timeouts using the socket options
- The `multicast_client` and `multicast_server` examples demonstrate receiving
  multicast packets in WASM

And add several macro controls for `socket_opts` example.
2022-10-07 10:31:21 +08:00
Jämes Ménétrey
e2a3f0f387
linux-sgx: Implement socket API getpeername, recvfrom and sendto (#1556)
Implement some of the popular socket APIs left unimplemented for SGX,
following the merge of dev/socket.
2022-10-06 21:32:33 +08:00
YAMAMOTO Takashi
3094b20bd8
samples/native-lib: Fix exec_env type (#1557)
Change `wasm_exec_env_t *exec_env` to `wasm_exec_env_t exec_env`
2022-10-06 20:21:21 +08:00
Jämes Ménétrey
a7a9e40fc6
linux-sgx: Fix directional OCALL parameter for getsockname (#1554) 2022-10-04 21:40:37 +08:00
Wenyong Huang
a9e5150c82
Upgrade version number to 1.1.0 (#1536) 2022-09-30 17:24:43 +08:00
Wenyong Huang
0cea769b71
Fix sample sgx-ra build error (#1544) 2022-09-30 15:57:04 +08:00
Wenyong Huang
57102456d5
Merge pull request #1542 from bytecodealliance/dev/socket
Keep the commits of dev/socket
2022-09-30 09:38:34 +08:00
Wenyong Huang
301672d8b6 Merge main into dev/socket 2022-09-30 08:32:59 +08:00
Jämes Ménétrey
4489c3da2b
hash map: Fix a wrongly named parameter and enhance the docs (#1540) 2022-09-30 03:02:22 +08:00
Jämes Ménétrey
5b10d4e630
socket: Explicit narrowing type cast and add missing static keywords (#1539)
While compiling the file wasi_socket_ext.c with pedantic options (typically
`-Wimplicit-int-conversion` and `-Wmissing-prototypes`), some warnings are raised.

This PR addresses those warnings by adding missing static statements before
functions and explicitly casting a narrowing conversion.

And fix the error handling after calling getpeername.
2022-09-29 22:44:57 +08:00
dzobbe
3fad613ea2
Enable build wasi_socket_ext.c with both clang and clang++ (#1527)
Enable to run WolfSSL into wasm and need some features from C++:
https://github.com/JamesMenetrey/wolfssl-examples/tree/wasm/Wasm
2022-09-29 20:52:11 +08:00
Marcin Kolny
dc2c6c75f5
Update socket API samples doc to cover UDP client/server and addr_resolve samples (#1538)
Also fix installing `addr_resolve.wasm` example.

Resolves #1534
2022-09-29 18:16:16 +08:00
Wenyong Huang
2a5451a35c
Fix Go binding build error (#1535) 2022-09-29 15:32:21 +08:00
Wenyong Huang
3220ff6941
Clear Windows compile warnings (#1530) 2022-09-29 14:02:58 +08:00
liang.he
1effda4cb5
Fix isssues detected by coverity (#1529)
Add return value checks
Append string terminator
2022-09-29 13:28:18 +08:00
Huang Qi
d7c2e9a6ea
Fix NuttX CI break by install missing dependencies (#1532) 2022-09-29 12:31:56 +08:00
Marcin Kolny
c505da7464
Update __wasi_sock_accept signature to match wasi_snapshot_preview1 (#1531)
The function was introduced to WASI about half a year ago after it already
existed in WAMR.

It caused problems with compiling `wasi_socket_ext.c` with the wasi-sdk
that already had this hostcall exported (wasi-sdk >= 15).

The approach we take is the following:
- we update WASI interface to be compatible with the wasi_snapshot_preview1
- compilation with `wasi_socket_ext.c` supports both wasi_sdk >= 15 and wasi_sdk < 15
  (although we intend to drop support for < 15 at one point of time)
- we override `accept()` from wasi-libc - we do that because `accept()` in `wasi-libc`
  doesn't support returning address (as it doesn't have `getpeername()` implemented),
  so `wasi_socket_ext.c` offers more functionality right now

Resolves #1167 and #1528.

[1] https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/witx/wasi_snapshot_preview1.witx
2022-09-29 09:29:54 +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
Christian Clauss
fa736d1ee9
Fix syntax errors and undefined names in Python code (#1515) 2022-09-27 15:57:08 +08:00
dongsheng28849455
8436e88a07
Fix link error for ESP-IDF 4.4.2 (#1520)
Fix the issue reported by #1484:
Platform ESP-IDF broken for WAMR 1.0.0 with ESP-IDF 4.4.2
Let the dummy ftruncate only work with ESP-IDF earlier than 4.4.2
2022-09-27 09:00:38 +08:00
YAMAMOTO Takashi
3d56c8133c
Fix NuttX build error after dev/socket was merged (#1517) 2022-09-26 20:06:14 +08:00
Hiroshi Hatake
3693cbe54d
Suppress hadolint warnings for pinning versions part (#1511)
Related to https://github.com/bytecodealliance/wasm-micro-runtime/issues/1418.

Suppress hadolint warnings for pinning version.
This is because these warnings are for reproducible builds.
But for development and CIs, ordinary case developers have to use the latest packages.
2022-09-23 10:34:47 +08:00
Wenyong Huang
1ff04a9125
Fix issue in wasm/aot enlarge memory (#1512)
Memory num_bytes_per_page was incorrectly set in memory enlarging for
shared memory, we fix it. And don't set memory_data_size again for shared
memory.
2022-09-23 09:31:44 +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
Qiang
32d2d16908
Fix Fast JIT issues reported by instrument test (#1488)
- Add checks for `pack_argv`
- Fix the checks in creating cc entry/exit basic blocks
2022-09-22 19:37:59 +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
Callum Macmillan
8dd1c8ab86
Copy only received bytes from socket recv buffer into the app buffer (#1497)
**What**

* Updated `copy_buffer_to_iovec_app` so that it copies as much of the buffer into the iovec as specified
* Throw invalid value when allocating an iovec of size 0

**Why**

* A bug found from TCP client example which allocates 1024 for the iovec size (where the buf size is also 1024) but received bytes is passed in as the `buf_size` argument to `copy_buffer_to_iovec_app`. This would return early after hitting this check `buf + data->buf_len > buf_begin + buf_size`. However, if the amount to copy is less than the iovec size, we should copy that much of the buf size. Eg TCP client sample receives 27(?) bytes at a time, and this copies 27 bytes into the iovec of size 1024
* The TCP client example attempts to recv bytes of size 0, this attempts to wasm malloc size 0, which outputs a warning. We should early return if recv bytes of size 0
2022-09-21 06:11:03 +08:00
Shengyun Zhou
ba3af0b196
AOT: fix crash in dumping call stack when the AOT file doesn't contain custom name section (#1508) 2022-09-20 20:47:17 +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
YAMAMOTO Takashi
ab3ad535ab
core/iwasm/compilation/debug/dwarf_extractor.cpp: remove dead code (#1507)
Remove an unused function, dwarf_get_func_info, which is also
seemingly incomplete.
2022-09-20 14:43:29 +08:00
Wenyong Huang
64c0b15c52
loader: Sub local count can be 0 (#1504)
Sub local count is allowed to be 0 in each group of function local types.
2022-09-20 12:40:24 +08:00
Marcin Kolny
c072b5172c
Assert on correct parameters (#1505)
This also fixes debug build
2022-09-20 08:58:02 +08:00
Daniel Ludwig
046f5f2212
Fix Windows/MSVC build issues (#1498)
Fix two issues of building WAMR on Windows:
- The build_llvm.py script calls itself, spawning instances faster than they expire,
   which makes Python3 eat up the entire RAM in a pretty short time.
- The MSVC compiler doesn't support preprocessor statements inside macro expressions.
  Two places inside bh_assert() were found.
2022-09-17 21:16:38 +08:00
YAMAMOTO Takashi
12bbb9189c
source_debugging.md: Add some notes about AOT debug (#1496) 2022-09-17 21:01:29 +08:00
YAMAMOTO Takashi
f5939c7bc1
Fix AOT debug for macOS (#1494)
note: macOS doesn't have elf.h
2022-09-16 18:54:04 +08:00
YAMAMOTO Takashi
1eedde7c33
Fix several issues related to AOT debug (#1492) 2022-09-16 12:06:46 +08:00
Marcin Kolny
f96773410a
Fix bind() calls to receive the correct size of sockaddr structure (#1490)
For some implementations (e.g. Mac OS) `bind()` requires the length to be exactly
equal to either `sockaddr_in` or `sockaddr_in6` structure. Because we always used
 `sizeof(struct sockaddr_storage)`, `bind()` was returning errors. In this change we
 fix the behavior. See StackOverflow [1] for details.

[1] https://stackoverflow.com/questions/73707162/socket-bind-failed-with-invalid-argument-error-for-program-running-on-macos
2022-09-16 11:09:03 +08:00
Shengyun Zhou
edaff3c6ec
thread-mgr: Prevent an already detached thread from being detached again (#1487)
If WASM app has called pthread_detach() to detach a thread, it will be detached again
when thread exits. Attempting to detach an already detached thread may result in crash
in musl-libc. This patch fixes it.
2022-09-15 17:13:33 +08:00
Callum Macmillan
4de5b52ba0
Added http downloader and multicast socket options (#1467)
Add a group of socket options used by cURL and rust stdlib, as well as some UDP multicast options.
2022-09-15 17:09:39 +08:00
Huang Qi
bbea005db6
Make libc-builtin buffered printf be a common feature (#1483)
Add macros to control whether to use the libc-builtin buffered printf
and the buffer size.
2022-09-15 15:09:01 +08:00
Wenyong Huang
ab929c20a3
Add check for code section size, fix interp float operations (#1480)
And enable classic interpreter instead fast interpreter when llvm jit is enabled,
so as to fix the issue that llvm jit cannot handle opcode drop_64/select_64.
2022-09-14 19:49:18 +08:00
Marcin Kolny
b731ca4668
Implement sock_send_to and sock_recv_from system calls (#1457) 2022-09-13 09:00:05 +08:00
Wenyong Huang
56b4a8bd4c Merge main into dev/socket 2022-09-10 22:12:43 +08:00
Wang Ning
7593668066
WARM-IDE: Add check for invalid project name when creating new project (#1461) 2022-09-08 17:34:24 +08:00
Wenyong Huang
8a7dd4dc3e
Remove handling unsupported opcodes in loader (#1464)
Remove handling opcode DROP_64/SELECT_64 in loader stage
prepare_bytecode, as they are the modified opcodes of DROP/SELECT
for optimization purpose, but not the opcodes defined by spec.
2022-09-08 15:38:16 +08:00
Qiang
6820af6212
Fix a potential memory leak issue in wasm_native_init (#1465)
Should call `wasm_native_destroy` to destroy the registered native libs
when registering native lib failed in `wasm_native_init`.
2022-09-08 14:22:34 +08:00
Qiang
da79e3e9b2
Add more checks for Fast JIT gen insn and jit_lock_reg_in_insn (#1449)
Add more checks for Fast JIT generating insn and jit_lock_reg_in_insn
in compile_int_div_no_check and other places to avoid accessing
NULL insn.
2022-09-07 16:52:35 +08:00