Skip to content

Commit daeaec4

Browse files
author
Adithya Krishna
authored
[Feat] - Migration of Docs from Old Site (#126)
* Migration of Books to Docs - v1 Signed-off-by: Adithya Krishna <[email protected]> * Added zh Files Signed-off-by: Adithya Krishna <[email protected]> * Reverted Previous Change Signed-off-by: Adithya Krishna <[email protected]> * Fixed Spacing Issues Signed-off-by: Adithya Krishna <[email protected]> * Fixed Broken Links Signed-off-by: Adithya Krishna <[email protected]> * Fixed MD Syntax Error Signed-off-by: Adithya Krishna <[email protected]> * Fix Admonitions Signed-off-by: Adithya Krishna <[email protected]> * Fixed Prettier Issues Signed-off-by: Adithya Krishna <[email protected]> * Fixed Broken Link Signed-off-by: Adithya Krishna <[email protected]> * Fixed Broken Links in Zh Docs Signed-off-by: Adithya Krishna <[email protected]> * Fixed Broken Links in Zh Docs Signed-off-by: Adithya Krishna <[email protected]> * Fixed Broken Links in ZhTW Docs Signed-off-by: Adithya Krishna <[email protected]> * Added JS SDK Signed-off-by: Adithya Krishna <[email protected]> * Updated AOT Docs Signed-off-by: Adithya Krishna <[email protected]> * Updated Installer Docs Signed-off-by: Adithya Krishna <[email protected]> * Updated Yomo Signed-off-by: Adithya Krishna <[email protected]> * Updated CLI Signed-off-by: Adithya Krishna <[email protected]> * Updated Proposals Signed-off-by: Adithya Krishna <[email protected]> * Added C++ SDK Signed-off-by: Adithya Krishna <[email protected]> * Made Other Changes Signed-off-by: Adithya Krishna <[email protected]> * Prettier Format Signed-off-by: Adithya Krishna <[email protected]> * Updated K8s ContainerD Docs Signed-off-by: Adithya Krishna <[email protected]> * Added Changes WRT #2535 Signed-off-by: Adithya Krishna <[email protected]> * Added Changes to Wasi_Logging and Build from Src Signed-off-by: Adithya Krishna <[email protected]> * Fixed Lint Issues Signed-off-by: Adithya Krishna <[email protected]> * Updated CLI, WasiLogging, Install Docs Signed-off-by: Adithya Krishna <[email protected]> * Updated NodeJS SDK Docs Signed-off-by: Adithya Krishna <[email protected]> * Prettier Format Signed-off-by: Adithya Krishna <[email protected]> * Updated AOT Doc Signed-off-by: Adithya Krishna <[email protected]> * Prettier Fix Signed-off-by: Adithya Krishna <[email protected]> * Made Requested Changes Signed-off-by: Adithya Krishna <[email protected]> * Made Requested Changes - v2 Signed-off-by: Adithya Krishna <[email protected]> * Fixed Broken Links Signed-off-by: Adithya Krishna <[email protected]> * Fixed Broken Links - v2 Signed-off-by: Adithya Krishna <[email protected]> * Fixed Lint Issues Signed-off-by: Adithya Krishna <[email protected]> --------- Signed-off-by: Adithya Krishna <[email protected]>
1 parent fd3cc60 commit daeaec4

File tree

50 files changed

+857
-226
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+857
-226
lines changed

docs/contribute/installer.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
sidebar_position: 7
33
---
44

5-
# Installer System explanation
5+
# Installer Guide
66

77
## Overview
88

9-
WasmEdge installer is designed for installing the Core Tools (`wasmedge`, `wasmedgec`), the Libraries (`libwasmedge`), the Extensions(`wasmedge-tensorflow`), and the Plugins(`wasi-nn`, `wasi-crytpo`).
9+
WasmEdge installer is designed for installing the Core Tools (`wasmedge`, `wasmedge compile`), the Libraries (`libwasmedge`), the Extensions(`wasmedge-tensorflow`), and the Plugins(`wasi-nn`, `wasi-crytpo`).
1010

1111
## Dependencies
1212

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Develop WasmEdge Plug-in in Rust SDK with witc
2+
3+
Once you complete C++ plugin code, you can use witc[^1] to generate Rust Plugin SDK
4+
5+
## Example wasmedge_opencvmini
6+
7+
Consider you get a file `wasmedge_opencvmini.wit` with below content
8+
9+
```wit
10+
imdecode: func(buf: list<u8>) -> u32
11+
imshow: func(window-name: string, mat-key: u32) -> unit
12+
waitkey: func(delay: u32) -> unit
13+
```
14+
15+
Using witc can generate Rust plugin code for it
16+
17+
```shell
18+
witc plugin wasmedge_opencvmini.wit
19+
```
20+
21+
Now, you will create a SDK crate by
22+
23+
```shell
24+
cargo new --lib opencvmini-sdk && cd opencvmini-sdk
25+
```
26+
27+
witc put rust code to stdout, therefore, you might like to create a new module file for generated code
28+
29+
```shell
30+
witc plugin wasmedge_opencvmini.wit > src/generated.rs
31+
```
32+
33+
Finally, you write down `mod generated` in `src/lib.rs` to access the code, and write some wrappers
34+
35+
```rust
36+
mod generated;
37+
38+
pub fn imdecode(buf: &[u8]) -> u32 {
39+
unsafe { generated::imdecode(buf.as_ptr(), buf.len()) }
40+
}
41+
pub fn imshow(window_name: &str, mat_key: u32) -> () {
42+
unsafe { generated::imshow(window_name.as_ptr(), window_name.len(), mat_key) }
43+
}
44+
pub fn waitkey(delay: u32) -> () {
45+
unsafe { generated::waitkey(delay) }
46+
}
47+
```
48+
49+
[^1]: <https://github.com/second-state/witc>

docs/contribute/source/build_from_src.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@ WasmEdge provides various tools for enabling different runtime environments for
2929
- `wasmedge` executes a `WASM` file in the interpreter mode or a compiled `WASM` file in the ahead-of-time compilation mode.
3030
- To disable building all tools, you can set the CMake option `WASMEDGE_BUILD_TOOLS` to `OFF`.
3131
2. `wasmedgec` is the ahead-of-time `WASM` compiler.
32+
3233
- `wasmedgec` compiles a general `WASM` file into a compiled `WASM` file.
3334
- To disable building the ahead-of-time compiler only, you can set the CMake option `WASMEDGE_BUILD_AOT_RUNTIME` to `OFF`.
35+
36+
<!-- prettier-ignore -->
37+
:::note
38+
The usage of `wasmedgec` is equal to `wasmedge compile`. We decide to deprecate `wasmedgec` in the future.
39+
:::
40+
3441
3. `libwasmedge.so` is the WasmEdge C API shared library. (`libwasmedge.dylib` on MacOS and `wasmedge.dll` on Windows)
3542
- `libwasmedge.so`, `libwasmedge.dylib`, or `wasmedge.dll` provides the C API for the ahead-of-time compiler and the WASM runtime.
3643
- The APIs related to the ahead-of-time compiler will always fail if the CMake option `WASMEDGE_BUILD_AOT_RUNTIME` is set as `OFF`.
@@ -89,6 +96,7 @@ Developers can follow the steps to build WasmEdge with plug-ins from source.
8996
- [WasmEdge-Image](../source/plugin/image.md)
9097
- [WasmEdge-TensorFlow](../source/plugin/tensorflow.md)
9198
- [WasmEdge-TensorFlowLite](../source/plugin/tensorflowlite.md)
99+
- [WASI-Logging](../source/plugin/wasi_logging.md)
92100

93101
## Run Tests
94102

docs/contribute/source/os/riscv64.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ ubuntu@riscv-lab:/labs/riscv-lab/WasmEdge/examples/wasm$ wasmedge --reactor add.
6464
4
6565
```
6666

67-
### Execute the wasmedgec tool
67+
### Execute wasmedge compile
6868

69-
To improve the performance, the `wasmedgec` can compile WebAssembly into native machine code. After compiling with the `wasmedgec` AOT compiler, the wasmedge tool can execute the WASM in AOT mode which is much faster.
69+
To improve the performance, the `wasmedge compile` can compile WebAssembly into native machine code. After compiling with the `wasmedge compile` AOT compiler, the wasmedge tool can execute the WASM in AOT mode which is much faster.
7070

7171
```bash
72-
ubuntu@riscv-lab:/labs/riscv-lab/WasmEdge/examples/wasm$ wasmedgec fibonacci.wasm fibonacci_aot.wasm
72+
ubuntu@riscv-lab:/labs/riscv-lab/WasmEdge/examples/wasm$ wasmedge compile fibonacci.wasm fibonacci_aot.wasm
7373
[2023-02-01 22:39:15.807] [info] compile start
7474
[2023-02-01 22:39:15.857] [info] verify start
7575
[2023-02-01 22:39:15.866] [info] optimize start
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Build WasmEdge With WASI-Logging Plug-in
6+
7+
## Prerequisites
8+
9+
The prerequisite of the Wasi-Logging plug-in is the same as the WasmEdge building environment on the [Linux](../os/linux.md) and [MacOS](../os/macos.md) platforms.
10+
11+
## Build WasmEdge with WASI-Logging Plug-in
12+
13+
To enable the WASI-Logging Plug-in, developers need to build the WasmEdge from source with the cmake option `-DWASMEDGE_PLUGIN_WASI_LOGGING=ON`.
14+
15+
```bash
16+
cd <path/to/your/wasmedge/source/folder>
17+
mkdir -p build && cd build
18+
cmake -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_PLUGIN_WASI_LOGGING=ON .. && make -j
19+
# For the WASI-Logging plug-in, you should install this project.
20+
cmake --install .
21+
```
22+
23+
> If the built `wasmedge` CLI tool cannot find the WASI-Logging plug-in, you can set the `WASMEDGE_PLUGIN_PATH` environment variable to the plug-in installation path (`/usr/local/lib/wasmedge`, or the built plug-in path `build/plugins/wasi_logging`) to try to fix this issue. You should find `libwasmedgePluginWasiLogging.so` in your `WASMEDGE_PLUGIN_PATH`
24+
25+
Then you will have an executable `wasmedge` runtime under `/usr/local/bin` and the WASI-Logging plug-in under `/usr/local/lib/wasmedge/libwasmedgePluginWasiLogging.so` after installation.

docs/develop/build-and-run/aot.md

Lines changed: 66 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -4,68 +4,70 @@ sidebar_position: 3
44

55
# The AoT Compiler
66

7-
One of the most important features of WasmEdge is the AoT compiler. The `wasmedgec` tool can compile any wasm file into native machine code (i.e., the AOT compiler). For the pure WebAssembly, the `wasmedge` tool will execute the WASM in interpreter mode. After compiling with the `wasmedgec` AOT compiler, the `wasmedge` tool can execute the WASM in AOT mode which is much faster.
7+
After [installation](../build-and-run/install.md), users can execute the `wasmedge compile` command.
88

9-
Use the `wasmedgec -v` or `wasmedgec --version` command to check the version of `wasmedgec` installed.
9+
The usage of the `wasmedge compile` command will be:
1010

1111
```bash
12-
$ wasmedgec -v
13-
wasmedge version {{ wasmedge_version }}
14-
```
15-
16-
Use `wasmedgec -h` or `wasmedgec --help` to show the help message.
17-
18-
```bash
19-
$ wasmedge -h
12+
$ wasmedge compile -h
2013
USAGE
21-
wasmedgec [OPTIONS] [--] WASM WASM_SO
14+
wasmedge compile [OPTIONS] [--] WASM WASM_SO
2215

2316
...
2417
```
2518

26-
## Output Format: Universal WASM
19+
The `wasmedge compile` command can compile WebAssembly into native machine code (i.e., the AOT compiler). For the pure WebAssembly, the `wasmedge` tool will execute the WASM in interpreter mode. After compiling with the `wasmedge compile` AOT compiler, the `wasmedge` tool can execute the WASM in AOT mode which is much faster.
2720

28-
By default, the `wasmedgec` AOT compiler tool could wrap the AOT-compiled native binary into a custom section in the origin WASM file. We call this the universal WASM binary format.
21+
## Options
2922

30-
This AOT-compiled WASM file is compatible with any WebAssembly runtime. However, when this WASM file is executed by the WasmEdge runtime, WasmEdge will extract the native binary from the custom section and execute it in AOT mode.
23+
The options of the `wasmedge compile` command are as follows.
3124

32-
<!-- prettier-ignore -->
33-
:::note
34-
On MacOS platforms, the universal WASM format will `bus error` in execution. It's because the `wasmedgec` tool optimizes the WASM in `O2` level by default. We are trying to fix this issue. For working around, please use the shared library output format instead.
35-
:::
36-
37-
```bash
38-
wasmedgec app.wasm app_aot.wasm
39-
wasmedge app_aot.wasm
40-
```
41-
42-
## Output Format: Shared Library
43-
44-
Users can assign the shared library extension for the output files (`.so` on Linux, `.dylib` on MacOS, and `.dll` on Windows) to generate the shared library output format output.
45-
46-
This AOT-compiled WASM file is only for WasmEdge use, and cannot be used by other WebAssembly runtimes.
47-
48-
```bash
49-
wasmedgec app.wasm app_aot.so
50-
wasmedge app_aot.so
51-
```
52-
53-
## Example for the AoT compiler
25+
1. `-h|--help`: Show the help messages. Will ignore other arguments below.
26+
2. (Optional) `--dump`: Dump the LLVM IR to `wasm.ll` and `wasm-opt.ll`.
27+
3. (Optional) `--interruptible`: Generate the binary which supports interruptible execution.
28+
- By default, the AOT-compiled WASM not supports [interruptions in asynchronous executions](../../embed/c/reference/0.12.x#async).
29+
4. (Optional) Statistics information:
30+
- By default, the AOT-compiled WASM not supports all statistics even if the options are turned on when running the `wasmedge` tool.
31+
- Use `--enable-time-measuring` to generate code for enabling the statistics of time measuring in execution.
32+
- Use `--enable-gas-measuring` to generate code for enabling the statistics of gas measuring in execution.
33+
- Use `--enable-instruction-count` to generate code for enabling the statistics of counting WebAssembly instructions.
34+
- Or use `--enable-all-statistics` to generate code for enabling all of the statistics.
35+
5. (Optional) `--generic-binary`: Generate the generic binary of the current host CPU architecture.
36+
6. (Optional) WebAssembly proposals:
37+
- Use `--disable-import-export-mut-globals` to disable the [Import/Export of Mutable Globals](https://github.com/WebAssembly/mutable-global) proposal (Default `ON`).
38+
- Use `--disable-non-trap-float-to-int` to disable the [Non-Trapping Float-to-Int Conversions](https://github.com/WebAssembly/nontrapping-float-to-int-conversions) proposal (Default `ON`).
39+
- Use `--disable-sign-extension-operators` to disable the [Sign-Extension Operators](https://github.com/WebAssembly/sign-extension-ops) proposal (Default `ON`).
40+
- Use `--disable-multi-value` to disable the [Multi-value](https://github.com/WebAssembly/multi-value) proposal (Default `ON`).
41+
- Use `--disable-bulk-memory` to disable the [Bulk Memory Operations](https://github.com/WebAssembly/bulk-memory-operations) proposal (Default `ON`).
42+
- Use `--disable-reference-types` to disable the [Reference Types](https://github.com/WebAssembly/reference-types) proposal (Default `ON`).
43+
- Use `--disable-simd` to disable the [Fixed-width SIMD](https://github.com/webassembly/simd) proposal (Default `ON`).
44+
- Use `--enable-multi-memory` to enable the [Multiple Memories](https://github.com/WebAssembly/multi-memory) proposal (Default `OFF`).
45+
- Use `--enable-tail-call` to enable the [Tail call](https://github.com/WebAssembly/tail-call) proposal (Default `OFF`).
46+
- Use `--enable-extended-const` to enable the [Extended Constant Expressions](https://github.com/WebAssembly/extended-const) proposal (Default `OFF`).
47+
- Use `--enable-threads` to enable the [Threads](https://github.com/webassembly/threads) proposal (Default `OFF`).
48+
- Use `--enable-all` to enable ALL proposals above.
49+
7. (Optional) `--optimize`: Select the LLVM optimization level.
50+
- Use `--optimize LEVEL` to set the optimization level. The `LEVEL` should be one of `0`, `1`, `2`, `3`, `s`, or `z`.
51+
- The default value will be `2`, which means `O2`.
52+
8. Input WASM file (`/path/to/wasm/file`).
53+
9. Output path (`/path/to/output/file`).
54+
- By default, the `wasmedge compile` command will output the [universal WASM format](#output-format-universal-wasm).
55+
- If the specific file extension (`.so` on Linux, `.dylib` on MacOS, and `.dll` on Windows) is assigned in the output path, the `wasmedge compile` command will output the [shared library format](#output-format-shared-library).
5456

55-
Use `wasmedgec XYZ.wasm XYZ.wasm` to compile WebAssembly into native machine code.
57+
## Example
5658

5759
Take the [fibonacci.wasm](https://github.com/WasmEdge/WasmEdge/raw/master/examples/wasm/fibonacci.wasm) for example. It exported a `fib()` function which takes a single `i32` integer as the input parameter.
5860

5961
You can run:
6062

6163
```bash
62-
wasmedgec fibonacci.wasm fibonacci_aot.wasm
64+
wasmedge compile fibonacci.wasm fibonacci_aot.wasm
6365
```
6466

6567
or:
6668

6769
```bash
68-
wasmedgec fibonacci.wasm fibonacci_aot.so # On Linux.
70+
wasmedge compile fibonacci.wasm fibonacci_aot.so # On Linux.
6971
```
7072

7173
The output will be:
@@ -79,7 +81,7 @@ The output will be:
7981
[2022-09-09 14:22:10.600] [info] compile done
8082
```
8183

82-
Next, you can execute the output file with `wasmedge` and measure the execution time:
84+
Then you can execute the output file with `wasmedge` and measure the execution time:
8385

8486
```bash
8587
time wasmedge --reactor fibonacci_aot.wasm fib 30
@@ -111,39 +113,29 @@ user 0m0.427s
111113
sys 0m0.012s
112114
```
113115

114-
## All options for the AoT compiler
116+
## Output Format: Universal WASM
115117

116-
The options of the `wasmedgec` CLI tool are as follows.
118+
By default, the `wasmedge compile` AOT compiler tool could wrap the AOT-compiled native binary into a custom section in the origin WASM file. We call this the universal WASM binary format.
117119

118-
1. `-v|--version`: Show the version information. Will ignore other arguments below.
119-
2. `-h|--help`: Show the help messages. Will ignore other arguments below.
120-
3. (Optional) `--dump`: Dump the LLVM IR to `wasm.ll` and `wasm-opt.ll`.
121-
4. (Optional) `--interruptible`: Generate the binary which supports interruptible execution.
122-
- By default, the AOT-compiled WASM not supports [interruptions in asynchronous executions].
123-
5. (Optional) Statistics information:
124-
- By default, the AOT-compiled WASM not supports all statistics even if the options are turned on when running the `wasmedge` tool.
125-
- Use `--enable-time-measuring` to generate code for enabling the statistics of time measuring in execution.
126-
- Use `--enable-gas-measuring` to generate code for enabling the statistics of gas measuring in execution.
127-
- Use `--enable-instruction-count` to generate code for enabling the statistics of counting WebAssembly instructions.
128-
- Or use `--enable-all-statistics` to generate code for enabling all of the statistics.
129-
6. (Optional) `--generic-binary`: Generate the generic binary of the current host CPU architecture.
130-
7. (Optional) WebAssembly proposals:
131-
- Use `--disable-import-export-mut-globals` to disable the [Import/Export of Mutable Globals](https://github.com/WebAssembly/mutable-global) proposal (Default `ON`).
132-
- Use `--disable-non-trap-float-to-int` to disable the [Non-Trapping Float-to-Int Conversions](https://github.com/WebAssembly/nontrapping-float-to-int-conversions) proposal (Default `ON`).
133-
- Use `--disable-sign-extension-operators` to disable the [Sign-Extension Operators](https://github.com/WebAssembly/sign-extension-ops) proposal (Default `ON`).
134-
- Use `--disable-multi-value` to disable the [Multi-value](https://github.com/WebAssembly/multi-value) proposal (Default `ON`).
135-
- Use `--disable-bulk-memory` to disable the [Bulk Memory Operations](https://github.com/WebAssembly/bulk-memory-operations) proposal (Default `ON`).
136-
- Use `--disable-reference-types` to disable the [Reference Types](https://github.com/WebAssembly/reference-types) proposal (Default `ON`).
137-
- Use `--disable-simd` to disable the [Fixed-width SIMD](https://github.com/webassembly/simd) proposal (Default `ON`).
138-
- Use `--enable-multi-memory` to enable the [Multiple Memories](https://github.com/WebAssembly/multi-memory) proposal (Default `OFF`).
139-
- Use `--enable-tail-call` to enable the [Tail call](https://github.com/WebAssembly/tail-call) proposal (Default `OFF`).
140-
- Use `--enable-extended-const` to enable the [Extended Constant Expressions](https://github.com/WebAssembly/extended-const) proposal (Default `OFF`).
141-
- Use `--enable-threads` to enable the [Threads](https://github.com/webassembly/threads) proposal (Default `OFF`).
142-
- Use `--enable-all` to enable ALL proposals above.
143-
8. (Optional) `--optimize`: Select the LLVM optimization level.
144-
- Use `--optimize LEVEL` to set the optimization level. The `LEVEL` should be one of `0`, `1`, `2`, `3`, `s`, or `z`.
145-
- The default value will be `2`, which means `O2`.
146-
9. Input WASM file (`/path/to/wasm/file`).
147-
10. Output path (`/path/to/output/file`).
148-
- By default, the `wasmedgec` tool will output the universal Wasm format, which embeds a native code section into the Wasm file.
149-
- If the specific file extension (`.so` on Linux, `.dylib` on MacOS, and `.dll` on Windows) is assigned in the output path, the `wasmedgec` tool will output the [shared library format](https://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html).
120+
This AOT-compiled WASM file is compatible with any WebAssembly runtime. However, when this WASM file is executed by the WasmEdge runtime, WasmEdge will extract the native binary from the custom section and execute it in AOT mode.
121+
122+
<!-- prettier-ignore -->
123+
:::note
124+
On MacOS platforms, the universal WASM format will `bus error` in execution. It's because the `wasmedge compile` tool optimizes the WASM in `O2` level by default. We are trying to fix this issue. For working around, please use the shared library output format instead.
125+
:::
126+
127+
```bash
128+
wasmedge compile app.wasm app_aot.wasm
129+
wasmedge app_aot.wasm
130+
```
131+
132+
## Output Format: Shared Library
133+
134+
Users can assign the shared library extension for the output files (`.so` on Linux, `.dylib` on MacOS, and `.dll` on Windows) to generate the shared library output format output.
135+
136+
This AOT-compiled WASM file is only for WasmEdge use, and cannot be used by other WebAssembly runtimes.
137+
138+
```bash
139+
wasmedge compile app.wasm app_aot.so
140+
wasmedge app_aot.so
141+
```

0 commit comments

Comments
 (0)