![]() * Optimize memory initialization handling in AOT loader (#3983) Save memory if the file buffer is always exist before exit. Signed-off-by: Huang Qi <huangqi3@xiaomi.com> * Break aot_create_comp_data into small functions Signed-off-by: Huang Qi <huangqi3@xiaomi.com> * Handle a new scenario where an item is both exported and imported. (#3984) * Error message improvement (#4000) Improve error message in the scenario where the runtime was built with ref types disabled but the module uses reference types feature. * Ensure __heap_base and __data_end global indices are validated against import count (#3996) * Fix table index calculations in wasm_loader and wasm_mini_loader (#4004) * Add an example of how to embed WAMR in Zephyr user mode (#3998) * [fuzzing] Use software bound-check during fuzzing (#4003) * Update CMakeLists.txt of fuzzing - enable software bound-check - enable wasi - disable libc builtin and multiple modules * Fix off-by-one error in result offset calculation for function calls * Check whether related table has funcref elem in opcode call_indirect (#3999) * check whether table has funcref elem in call_indirect * check whether table has funcref elem in call_indirect when gc is enabled * Improve stack consistency by ensuring sufficient space for dummy offsets (#4011) One more corner case: if the `frame_offset` increases and becomes equal to the `frame_offset_boundary` after the last assignment within the for loop. * Add documentation regarding security issues and the status of Wasm proposals (#3972) Add documentation regarding security issues and the status of Wasm proposals. * Enable shrunk memory by default and add related configurations (#4008) - Enable shrunk memory by default and add related configurations - Improve error messages for memory access alignment checks - Add documentation for WAMR shrunk memory build option - Update NuttX workflow to disable shrunk memory build option * build(deps): Bump actions/upload-artifact from 4.5.0 to 4.6.0 (#4021) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.5.0 to 4.6.0. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4.5.0...v4.6.0) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): Bump github/codeql-action from 3.28.0 to 3.28.1 (#4020) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.0 to 3.28.1. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.0...v3.28.1) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Refine read leb int wasm loader of fast interpreter (#4017) * .github: Add shared lib builds (#3975) So far, no workflows would attempt to build the shared version of the iwasm library (namely, vmlib). Note that, as opposed to GC_EH_BUILD_OPTIONS and DEFAULT_BUILD_OPTIONS, the actual default options defined by the build system are assumed, for the sake of simplicity and avoiding repeated code. * fixes for compiling on windows (#4026) * Refine getting const offsets in wasm loader of fast-interp (#4012) - Refine const offsets in loader for fast-interp - handle const cell num overflow - Use const array, remove list * Synchronize the GC spec tests to the commit from December 9. 2024. (#4022) - Synchronize the GC spec tests to the commit from December 9. 2024. - Revise the error messages to be consistent with the spec test cases. - bypass gc spec test on the nuttx platform as a workaround * Fix wasm loader check data segment count (#4039) correctly report error when datacount section has non-zero data segment count while the data section is not present * Update Rust target from 'wasm32-wasi' to 'wasm32-wasip1' in CI (#4050) - update Rust target from 'wasm32-wasi' to 'wasm32-wasip1' in ci * build(deps): Bump github/codeql-action from 3.28.1 to 3.28.5 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.1 to 3.28.5. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.1...v3.28.5) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): Bump github/codeql-action from 3.28.5 to 3.28.8 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.5 to 3.28.8. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.5...v3.28.8) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Use wasm32-wasip1 instead of wasm32-wasi target for rust code (#4057) Rust compiler previously deprecated, and now removed the wasm32-wasi target and replaced it with wasm32-wasip1. This change updates all the occurrences of wasm32-wasi in the context of Rust compilation. covers the wasi-nn/test. * add a validator for aot module (#3995) - Add AOT module validation to ensure memory constraints are met - Enable AOT validator in build configuration and update related source files * Show wasm proposals status during compilation and execution (#3989) - add default build configuration options and enhance message output for WAMR features - Add Wasm proposal status printing functionality * initial * Add versioning support and update CMake configuration * Add versioning information for libraries and executables across multiple platforms * Refactor versioning documentation and adopt semantic versioning guidelines * Remove deprecated version.h file and update versioning documentation * Add version.h and update versioning documentation for embedded platforms * Add workflow to confirm version.h is in sync and integrate it into Android compilation workflow * Cleanup check_version_h workflow by removing unnecessary outputs and permissions * Update memory allocation functions to use allocator user data (#4043) * [fuzzing] execute every exported function (#3959) - Enhance wasm mutator fuzz tests by adding export function execution and random value generation - Use --fuel to limit loop size - Use predefined values and enhance argument logging in execution * In wasm32, fix potential conversion overflow when enlarging 65536 pages (#4064) fix enlarge 65536 pages conversion overflow in wasm32 * fix(aot): ensure value_cmp does not exceed br_count in branch table compilation (#4065) * build(deps): Bump github/codeql-action from 3.28.8 to 3.28.9 (#4074) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.8 to 3.28.9. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.8...v3.28.9) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Unit test:type matching issue and code redundancy (#4079) * Add a conditional check for the macro __STDC_VERSION__ (#4080) * build_llvm.py: Allow to build xtensa target on non-xtensa host Signed-off-by: Huang Qi <huangqi3@xiaomi.com> * [gc] Subtyping fix (#4075) * fix(build_llvm.py): clean up whitespace and formatting in build script Signed-off-by: Huang Qi <huangqi3@xiaomi.com> * feat: add support for EXTERNREF value type and enable AOT validator in fuzz tests (#4083) * fix(unit-test): libc_builtin_test issues (#4073) - uninitialized buffer pointers (crashes) - match integer constant size with printf specifier Signed-off-by: Peter Tatrai <peter.tatrai.ext@siemens.com> * fix(build_llvm_libraries.yml): Correct script path for build_llvm.py Signed-off-by: Huang Qi <huangqi3@xiaomi.com> * fix(aot_emit_aot_file): prevent buffer emission for zero byte_count (#4095) if using a debug building of wamrc to run spec test. there will be: core/iwasm/compilation/aot_emit_aot_file.c:1794:13: runtime error: null pointer passed as argument 2, which is declared to never be null * Cmake improvements (#4076) - Utilizes the standard CMake variable BUILD_SHARED_LIBS to simplify the CMake configuration. - Allows the use of a single library definition for both static and shared library cases, improving maintainability and readability of the CMake configuration. - Install vmlib public header files - Installs the public header files for the vmlib target to the include/iwasm directory. - Install cmake package - Adds the necessary CMake configuration files (iwasmConfig.cmake and iwasmConfigVersion.cmake). - Configures the installation of these files to the appropriate directory (lib/cmake/iwasm). - Ensures compatibility with the same major version. - Improve windows product-mini CMakeLists.txt - Fix missing symbols when linking windows product-mini with shared vmlib - Improve Darwin product-mini CMakeLists.txt --------- Signed-off-by: Peter Tatrai <peter.tatrai.ext@siemens.com> * fix: when load aot init expr,no type_idx set. (#4094) Fix an assertion from *gc_object.c line 91* `bh_assert(rtt_type->type_flag == WASM_TYPE_STRUCT;` * prevent data overflow on 32 bit platform for memory.grow * cr suggestions * cr suggestions * format * cr suggestions * feat: use C linkage in aot_comp_option.h for C++ embeding (#4106) Co-authored-by: xiangjia.xj <xiangjia.xj@alibaba-inc.com> * build(deps): Bump actions/upload-artifact from 4.6.0 to 4.6.1 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.6.0 to 4.6.1. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4.6.0...v4.6.1) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): Bump github/codeql-action from 3.28.9 to 3.28.10 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.9 to 3.28.10. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.9...v3.28.10) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Apply suggestions from code review remove confusing comments. * build(deps): Bump ossf/scorecard-action from 2.4.0 to 2.4.1 Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.4.0 to 2.4.1. - [Release notes](https://github.com/ossf/scorecard-action/releases) - [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md) - [Commits]( |
||
---|---|---|
.. | ||
wasm-src | ||
CMakeLists.txt | ||
README.md | ||
sample_test_run.py |
"socket-api" sample introduction
This sample demonstrates how to use WAMR socket-api to develop wasm network applications. Two wasm applications are provided: tcp-server and tcp-client, and this sample demonstrates how they communicate with each other.
Preparation
Please install WASI SDK, download the wasi-sdk release and extract the archive to default path /opt/wasi-sdk
.
And install wabt, download the wabt release and extract the archive to default path /opt/wabt
Build the sample
mkdir build
cd build
cmake ..
make
iwasm
and the following Wasm modules (along with their corresponding native version) will be generated:
addr_resolve.wasm
,addr_resolve
send_recv.wasm
,send_recv
socket_opts.wasm
,socket_opts
tcp_client.wasm
,tcp_client
tcp_server.wasm
,tcp_server
udp_client.wasm
,udp_client
udp_server.wasm
,udp_server
Note that iwasm is built with libc-wasi and lib-pthread enabled.
Run workload
TCP client/server
Start the tcp server, which opens port 1234 and waits for clients to connect.
cd build
./iwasm --addr-pool=0.0.0.0/15 tcp_server.wasm
Start the tcp client, which connects the server and receives message.
cd build
./iwasm --addr-pool=127.0.0.1/15 tcp_client.wasm
The output of client is like:
[Client] Create socket
[Client] Connect socket
[Client] Client receive
[Client] 115 bytes received:
Buffer received:
Say Hi from the Server
Say Hi from the Server
Say Hi from the Server
Say Hi from the Server
Say Hi from the Server
[Client] BYE
send_recv.wasm
contains a thread as a server and a thread as a client. They
send and receive data via 127.0.0.1:1234.
$ ./iwasm --addr-pool=127.0.0.1/0 ./send_recv.wasm
The output is:
Server is online ...
Client is running...
Start receiving.
Start sending.
Send 106 bytes successfully!
Receive 106 bytes successlly!
Data:
The stars shine down
It brings us light
Light comes down
To make us paths
It watches us
And mourns for us
Socket options
socket_opts.wasm
shows an example of getting and setting various supported socket options
$ ./iwasm socket_opts.wasm
The output is:
[Client] Create TCP socket
[Client] Create UDP socket
[Client] Create UDP IPv6 socket
setsockopt SO_RCVTIMEO result is expected
getsockopt SO_RCVTIMEO result is expected
...
[Client] Close sockets
The timeout_client.wasm
and timeout_server.wasm
examples demonstrate socket send and receive timeouts using the socket options. Start the server, then start the client.
$ ./iwasm --addr-pool=0.0.0.0/15 timeout_server.wasm
The output is:
Wait for client to connect
Client connected, sleeping for 10s
Shutting down
$ ./iwasm --addr-pool=127.0.0.1/15 timeout_client.wasm
The output is:
Waiting on recv, which should timeout
Waiting on send, which should timeout
Success. Closing socket
The multicast_client
and multicast_server
examples demonstrate receiving multicast packets in WASM. Start the client and then the server with a multicast IP address and port.
$ ./iwasm --addr-pool=0.0.0.0/0,::/0 multicast_client.wasm <Multicast IP> <Port>
$ ./iwasm --addr-pool=0.0.0.0/0,::/0 multicast_client.wasm 224.0.0.1
$ ./iwasm --addr-pool=0.0.0.0/0,::/0 multicast_client.wasm FF02:113D:6FDD:2C17:A643:FFE2:1BD1:3CD2
The output should be
Joined multicast group. Waiting for datagram...
Reading datagram message...OK.
The message from multicast server is: "Test message"
$ ./multicast_server <Multicast IP> <Port>
$ ./multicast_server 224.0.0.1
$ ./multicast_server FF02:113D:6FDD:2C17:A643:FFE2:1BD1:3CD2
The output should be
Datagram sent
Domain name server resolution
addr_resolve.wasm
demonstrates the usage of resolving a domain name
$ ./iwasm --allow-resolve=*.com addr_resolve.wasm github.com
The command displays the host name and its corresponding IP address:
Host: github.com
IPv4 address: 140.82.121.4 (TCP)
UDP client/server
Start the UDP server, which opens port 1234 and waits for clients to send a message.
cd build
./iwasm --addr-pool=0.0.0.0/15 udp_server.wasm
Start the tcp client, which sends a message to the server and waits for the response.
cd build
./iwasm --addr-pool=127.0.0.1/15 udp_client.wasm
The output of client is like:
[Client] Create socket
[Client] Client send
[Client] Client receive
[Client] Buffer received: Hello from server
[Client] BYE
The output of the server is like:
[Server] Create socket
[Server] Bind socket
[Server] Wait for clients to connect ..
[Server] received 17 bytes from 127.0.0.1:60927: Hello from client
Documentation
Refer to socket api document for more details.