From 74f66c3799c02a6c8c26a2ab5cc0a4fda535c861 Mon Sep 17 00:00:00 2001 From: Ankit Ram Date: Tue, 16 Jun 2026 00:56:41 +0530 Subject: [PATCH 1/3] docs: add Wasm GC proposal tutorial and update proposals link Signed-off-by: Ankit Ram --- docs/start/wasmedge/extensions/gc.md | 138 ++++++++++++++++++++ docs/start/wasmedge/extensions/proposals.md | 2 +- 2 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 docs/start/wasmedge/extensions/gc.md diff --git a/docs/start/wasmedge/extensions/gc.md b/docs/start/wasmedge/extensions/gc.md new file mode 100644 index 00000000..ce84226b --- /dev/null +++ b/docs/start/wasmedge/extensions/gc.md @@ -0,0 +1,138 @@ +--- +sidebar_position: 2 +--- + +# Garbage Collection + +WasmEdge supports the [WebAssembly Garbage Collection (GC) proposal](https://github.com/WebAssembly/gc) starting from version `0.14.0`. This allows high-level languages like Kotlin, Dart, and OCaml to compile to WebAssembly without bundling their own garbage collector, resulting in smaller binaries and better runtime performance. + +## What is Wasm GC? + +Normally, WebAssembly manages memory manually — programs allocate and free memory themselves using linear memory. The GC proposal adds first-class garbage-collected types: **structs** (fixed heterogeneous fields) and **arrays** (homogeneous elements), both allocated on the heap and automatically reclaimed when no longer reachable. + +This is enabled by default in WasmEdge since `0.16.0`. You can disable it with the `--disable-gc` CLI flag if needed. + +## Prerequisites + +- WasmEdge `0.14.0` or later. See the [installation guide](../../../start/install.md). +- [`wat2wasm`](https://github.com/WebAssembly/wabt) from the WABT toolkit, to compile `.wat` source files to `.wasm`. + +Install WABT on Linux: + +```bash +apt install wabt +``` + +Or on macOS: + +```bash +brew install wabt +``` + +## Example: Working with Structs + +The following WAT (WebAssembly Text Format) example defines a `$point` struct with two `i32` fields, allocates one, sets a field, and returns a value from it. + +Create a file called `point.wat`: + +```wasm +(module + (type $point (struct (field $x (mut i32)) (field $y (mut i32)))) + + (func (export "make_point") (result i32) + (local $p (ref $point)) + ;; Allocate a new $point struct with x=10, y=20 + (local.set $p + (struct.new $point (i32.const 10) (i32.const 20)) + ) + ;; Update x to 99 + (struct.set $point $x (local.get $p) (i32.const 99)) + ;; Return the value of x + (struct.get $point $x (local.get $p)) + ) +) +``` + +Compile it to a `.wasm` binary: + +```bash +wat2wasm point.wat -o point.wasm +``` + +Run it with WasmEdge: + +```bash +wasmedge --invoke make_point point.wasm +``` + +Expected output: + +``` +99 +``` + +## Example: Working with Arrays + +The following example creates a GC-managed array of `i32` values, fills it with a value, and reads back an element. + +Create a file called `array.wat`: + +```wasm +(module + (type $int_array (array (mut i32))) + + (func (export "array_example") (result i32) + (local $a (ref $int_array)) + ;; Allocate an array of length 5, initialized to 0 + (local.set $a + (array.new_default $int_array (i32.const 5)) + ) + ;; Set element at index 2 to 42 + (array.set $int_array (local.get $a) (i32.const 2) (i32.const 42)) + ;; Return element at index 2 + (array.get $int_array (local.get $a) (i32.const 2)) + ) +) +``` + +Compile and run: + +```bash +wat2wasm array.wat -o array.wasm +wasmedge --invoke array_example array.wasm +``` + +Expected output: + +``` +42 +``` + +## Disabling GC + +If you need to run a Wasm module without GC support (for example, to test compatibility), pass the `--disable-gc` flag: + +```bash +wasmedge --disable-gc your_module.wasm +``` + +## C API + +To configure GC support programmatically via the WasmEdge C API, use the `WasmEdge_Proposal_GC` enumeration value: + +```c +WasmEdge_ConfigureContext *ConfCxt = WasmEdge_ConfigureCreate(); +// GC is enabled by default since 0.16.0. +// To disable it: +WasmEdge_ConfigureRemoveProposal(ConfCxt, WasmEdge_Proposal_GC); +``` + +## Language Support + +Languages that compile to Wasm GC and can run on WasmEdge include: + +- **Kotlin/Wasm** — via the Kotlin compiler's `wasmGc` target +- **Dart** — via `dart compile wasm` +- **OCaml** — via the `wasm_of_ocaml` compiler + +For language-specific guides, refer to the respective language's documentation on compiling to the `wasm32-unknown-unknown` GC target. \ No newline at end of file diff --git a/docs/start/wasmedge/extensions/proposals.md b/docs/start/wasmedge/extensions/proposals.md index faeacc3b..3e1f3618 100644 --- a/docs/start/wasmedge/extensions/proposals.md +++ b/docs/start/wasmedge/extensions/proposals.md @@ -47,7 +47,7 @@ The following proposals are under development and may be supported in the future [Component Model]: https://github.com/WebAssembly/component-model [Exception handling]: https://github.com/WebAssembly/exception-handling [Typed Function References]: https://github.com/WebAssembly/function-references -[Garbage collection]: https://github.com/WebAssembly/gc +[Garbage collection]: ./gc [Relaxed SIMD]: https://github.com/WebAssembly/relaxed-simd [Memory64]: https://github.com/WebAssembly/memory64 [WebAssembly C and C++ API]: https://github.com/WebAssembly/wasm-c-api From e7e9f6b8cca8ad5a249b1318eb24d67af08a7762 Mon Sep 17 00:00:00 2001 From: Ankit Ram Date: Tue, 16 Jun 2026 16:19:17 +0530 Subject: [PATCH 2/3] t push origin docs/wasm-gc-proposal --forcedocs: address Copilot review comments Signed-off-by: Ankit Ram --- docs/start/wasmedge/extensions/gc.md | 9 +++++---- docs/start/wasmedge/extensions/proposals.md | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/start/wasmedge/extensions/gc.md b/docs/start/wasmedge/extensions/gc.md index ce84226b..c755fa73 100644 --- a/docs/start/wasmedge/extensions/gc.md +++ b/docs/start/wasmedge/extensions/gc.md @@ -1,5 +1,5 @@ --- -sidebar_position: 2 +sidebar_position: 3 --- # Garbage Collection @@ -10,7 +10,7 @@ WasmEdge supports the [WebAssembly Garbage Collection (GC) proposal](https://git Normally, WebAssembly manages memory manually — programs allocate and free memory themselves using linear memory. The GC proposal adds first-class garbage-collected types: **structs** (fixed heterogeneous fields) and **arrays** (homogeneous elements), both allocated on the heap and automatically reclaimed when no longer reachable. -This is enabled by default in WasmEdge since `0.16.0`. You can disable it with the `--disable-gc` CLI flag if needed. +This is enabled by default in WasmEdge since `0.16.0`. For WasmEdge `0.14.x`–`0.15.x`, enable it explicitly with the (deprecated) `--enable-gc` flag; you can disable GC with `--disable-gc` when needed. ## Prerequisites @@ -122,9 +122,10 @@ To configure GC support programmatically via the WasmEdge C API, use the `WasmEd ```c WasmEdge_ConfigureContext *ConfCxt = WasmEdge_ConfigureCreate(); -// GC is enabled by default since 0.16.0. -// To disable it: +// WasmEdge 0.16.0+ enables GC by default; to disable it: WasmEdge_ConfigureRemoveProposal(ConfCxt, WasmEdge_Proposal_GC); +// WasmEdge 0.14.x–0.15.x has GC off by default; to enable it instead: +// WasmEdge_ConfigureAddProposal(ConfCxt, WasmEdge_Proposal_GC); ``` ## Language Support diff --git a/docs/start/wasmedge/extensions/proposals.md b/docs/start/wasmedge/extensions/proposals.md index 3e1f3618..e8879c54 100644 --- a/docs/start/wasmedge/extensions/proposals.md +++ b/docs/start/wasmedge/extensions/proposals.md @@ -47,7 +47,7 @@ The following proposals are under development and may be supported in the future [Component Model]: https://github.com/WebAssembly/component-model [Exception handling]: https://github.com/WebAssembly/exception-handling [Typed Function References]: https://github.com/WebAssembly/function-references -[Garbage collection]: ./gc +[Garbage collection]: ./gc.md [Relaxed SIMD]: https://github.com/WebAssembly/relaxed-simd [Memory64]: https://github.com/WebAssembly/memory64 [WebAssembly C and C++ API]: https://github.com/WebAssembly/wasm-c-api From b8b7e2ae70a22bbd2da765cc2819143d63bcd71f Mon Sep 17 00:00:00 2001 From: Ankit Ram Date: Fri, 19 Jun 2026 18:51:33 +0530 Subject: [PATCH 3/3] docs: add plugin documentation pages Signed-off-by: Ankit Ram --- docs/contribute/source/plugin/wasi_http.md | 28 +++++++ docs/contribute/source/plugin/wasi_poll.md | 28 +++++++ docs/contribute/source/plugin/wasm_bpf.md | 39 +++++++++ .../source/plugin/wasmedge_ffmpeg.md | 44 ++++++++++ docs/contribute/source/plugin/wasmedge_ocr.md | 43 ++++++++++ .../source/plugin/wasmedge_opencvmini.md | 43 ++++++++++ .../source/plugin/wasmedge_stablediffusion.md | 84 +++++++++++++++++++ .../contribute/source/plugin/wasmedge_zlib.md | 44 ++++++++++ 8 files changed, 353 insertions(+) create mode 100644 docs/contribute/source/plugin/wasi_http.md create mode 100644 docs/contribute/source/plugin/wasi_poll.md create mode 100644 docs/contribute/source/plugin/wasm_bpf.md create mode 100644 docs/contribute/source/plugin/wasmedge_ffmpeg.md create mode 100644 docs/contribute/source/plugin/wasmedge_ocr.md create mode 100644 docs/contribute/source/plugin/wasmedge_opencvmini.md create mode 100644 docs/contribute/source/plugin/wasmedge_stablediffusion.md create mode 100644 docs/contribute/source/plugin/wasmedge_zlib.md diff --git a/docs/contribute/source/plugin/wasi_http.md b/docs/contribute/source/plugin/wasi_http.md new file mode 100644 index 00000000..d606b9e5 --- /dev/null +++ b/docs/contribute/source/plugin/wasi_http.md @@ -0,0 +1,28 @@ +--- +sidebar_position: 1 +--- + +# Build with WASI-HTTP Plug-in + +The WASI-HTTP plug-in provides an implementation of the [WASI HTTP proposal](https://github.com/WebAssembly/wasi-http), enabling WebAssembly modules to make outbound HTTP requests and handle inbound HTTP connections. It is built on top of [libcpr](https://github.com/libcpr/cpr), a modern C++ HTTP client library. + +## Build WasmEdge with WASI-HTTP Plug-in + +To enable the WasmEdge WASI-HTTP plug-in, developers need to [build WasmEdge from source](../os/linux.md) with the cmake option `-DWASMEDGE_PLUGIN_WASI_HTTP=ON`. + +The build system will automatically fetch and build `libcpr` via CMake's `FetchContent`, so no manual installation of dependencies is required. + +```bash +cd +cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_PLUGIN_WASI_HTTP=ON +cmake --build build +cmake --install build +``` + +:::note +If the built `wasmedge` CLI tool cannot find the WASI-HTTP plug-in, you can set the `WASMEDGE_PLUGIN_PATH` environment variable to the plug-in installation path (such as `/usr/local/lib/wasmedge/`, or the built plug-in path `build/plugins/wasi_http/`) to try to fix this issue. +::: + +Then you will have an executable `wasmedge` runtime under `/usr/local/bin` and the WASI-HTTP plug-in under `/usr/local/lib/wasmedge/libwasmedgePluginWasiHttp.so` after installation. + +For more information, you can refer to the [GitHub repository](https://github.com/WasmEdge/WasmEdge/tree/master/plugins/wasi_http). diff --git a/docs/contribute/source/plugin/wasi_poll.md b/docs/contribute/source/plugin/wasi_poll.md new file mode 100644 index 00000000..03862bbf --- /dev/null +++ b/docs/contribute/source/plugin/wasi_poll.md @@ -0,0 +1,28 @@ +--- +sidebar_position: 2 +--- + +# Build with WASI-Poll Plug-in + +The WASI-Poll plug-in provides an implementation of the [WASI Poll proposal](https://github.com/WebAssembly/wasi-poll), which enables WebAssembly modules to perform I/O multiplexing — waiting on multiple I/O events simultaneously. This is essential for building efficient, event-driven WebAssembly applications on the WasmEdge runtime. + +## Build WasmEdge with WASI-Poll Plug-in + +To enable the WasmEdge WASI-Poll plug-in, developers need to [build WasmEdge from source](../os/linux.md) with the cmake option `-DWASMEDGE_PLUGIN_WASI_POLL=ON`. + +The WASI-Poll plug-in has no external dependencies beyond the WasmEdge runtime itself. + +```bash +cd +cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_PLUGIN_WASI_POLL=ON +cmake --build build +cmake --install build +``` + +:::note +If the built `wasmedge` CLI tool cannot find the WASI-Poll plug-in, you can set the `WASMEDGE_PLUGIN_PATH` environment variable to the plug-in installation path (such as `/usr/local/lib/wasmedge/`, or the built plug-in path `build/plugins/wasi_poll/`) to try to fix this issue. +::: + +Then you will have an executable `wasmedge` runtime under `/usr/local/bin` and the WASI-Poll plug-in under `/usr/local/lib/wasmedge/libwasmedgePluginWasiPoll.so` after installation. + +For more information, you can refer to the [GitHub repository](https://github.com/WasmEdge/WasmEdge/tree/master/plugins/wasi_poll). diff --git a/docs/contribute/source/plugin/wasm_bpf.md b/docs/contribute/source/plugin/wasm_bpf.md new file mode 100644 index 00000000..f78ad09d --- /dev/null +++ b/docs/contribute/source/plugin/wasm_bpf.md @@ -0,0 +1,39 @@ +--- +sidebar_position: 3 +--- + +# Build with Wasm-BPF Plug-in + +The Wasm-BPF plug-in allows WebAssembly programs to interact with [eBPF](https://ebpf.io/) programs running in the Linux kernel. This enables use cases such as network monitoring, performance tracing, and security enforcement from within a WebAssembly module running on WasmEdge. + +## Prerequisites + +The Wasm-BPF plug-in requires `libbpf >= 1.2.0`, `libelf`, and `zlib`. On Ubuntu 20.04: + +```bash +sudo apt update +sudo apt install -y libbpf-dev libelf-dev zlib1g-dev +``` + +:::note +If `libbpf >= 1.2.0` is not available through your package manager, the build system will automatically download and build it from source via `FetchContent`. In that case, you still need `libelf` and `zlib` installed. +::: + +## Build WasmEdge with Wasm-BPF Plug-in + +To enable the WasmEdge Wasm-BPF plug-in, developers need to [build WasmEdge from source](../os/linux.md) with the cmake option `-DWASMEDGE_PLUGIN_WASM_BPF=ON`. + +```bash +cd +cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_PLUGIN_WASM_BPF=ON +cmake --build build +cmake --install build +``` + +:::note +If the built `wasmedge` CLI tool cannot find the Wasm-BPF plug-in, you can set the `WASMEDGE_PLUGIN_PATH` environment variable to the plug-in installation path (such as `/usr/local/lib/wasmedge/`, or the built plug-in path `build/plugins/wasm_bpf/`) to try to fix this issue. +::: + +Then you will have an executable `wasmedge` runtime under `/usr/local/bin` and the Wasm-BPF plug-in under `/usr/local/lib/wasmedge/libwasmedgePluginWasmBpf.so` after installation. + +For more information, you can refer to the [GitHub repository](https://github.com/WasmEdge/WasmEdge/tree/master/plugins/wasm_bpf). diff --git a/docs/contribute/source/plugin/wasmedge_ffmpeg.md b/docs/contribute/source/plugin/wasmedge_ffmpeg.md new file mode 100644 index 00000000..666999ed --- /dev/null +++ b/docs/contribute/source/plugin/wasmedge_ffmpeg.md @@ -0,0 +1,44 @@ +--- +sidebar_position: 4 +--- + +# Build with WasmEdge-FFmpeg Plug-in + +The WasmEdge-FFmpeg plug-in provides WebAssembly bindings to the [FFmpeg](https://ffmpeg.org/) multimedia framework, enabling WasmEdge applications to encode, decode, transcode, mux, demux, stream, filter, and play audio and video content. It wraps the core FFmpeg libraries: `libavcodec`, `libavformat`, `libavfilter`, `libavdevice`, `libavutil`, `libswresample`, and `libswscale`. + +## Prerequisites + +Install the FFmpeg development libraries on your system. + +For Ubuntu 20.04: + +```bash +sudo apt update +sudo apt install -y libavdevice-dev libavfilter-dev libavformat-dev \ + libavcodec-dev libswresample-dev libswscale-dev libavutil-dev +``` + +For macOS: + +```bash +brew install ffmpeg +``` + +## Build WasmEdge with WasmEdge-FFmpeg Plug-in + +To enable the WasmEdge-FFmpeg plug-in, developers need to [build WasmEdge from source](../os/linux.md) with the cmake option `-DWASMEDGE_PLUGIN_FFMPEG=ON`. + +```bash +cd +cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_PLUGIN_FFMPEG=ON +cmake --build build +cmake --install build +``` + +:::note +If the built `wasmedge` CLI tool cannot find the WasmEdge-FFmpeg plug-in, you can set the `WASMEDGE_PLUGIN_PATH` environment variable to the plug-in installation path (such as `/usr/local/lib/wasmedge/`, or the built plug-in path `build/plugins/wasmedge_ffmpeg/`) to try to fix this issue. +::: + +Then you will have an executable `wasmedge` runtime under `/usr/local/bin` and the WasmEdge-FFmpeg plug-in under `/usr/local/lib/wasmedge/libwasmedgePluginWasmEdgeFFmpeg.so` after installation. + +For more information, you can refer to the [GitHub repository](https://github.com/WasmEdge/WasmEdge/tree/master/plugins/wasmedge_ffmpeg). diff --git a/docs/contribute/source/plugin/wasmedge_ocr.md b/docs/contribute/source/plugin/wasmedge_ocr.md new file mode 100644 index 00000000..c806f63f --- /dev/null +++ b/docs/contribute/source/plugin/wasmedge_ocr.md @@ -0,0 +1,43 @@ +--- +sidebar_position: 5 +--- + +# Build with WasmEdge-OCR Plug-in + +The WasmEdge-OCR plug-in provides optical character recognition (OCR) capabilities to WebAssembly applications running on WasmEdge. It is powered by [Tesseract](https://github.com/tesseract-ocr/tesseract), an open-source OCR engine, and [Leptonica](http://leptonica.org/), its image processing dependency. + +## Prerequisites + +Install Tesseract and Leptonica development libraries on your system. + +For Ubuntu 20.04: + +```bash +sudo apt update +sudo apt install -y libtesseract-dev libleptonica-dev +``` + +For macOS: + +```bash +brew install tesseract leptonica +``` + +## Build WasmEdge with WasmEdge-OCR Plug-in + +To enable the WasmEdge-OCR plug-in, developers need to [build WasmEdge from source](../os/linux.md) with the cmake option `-DWASMEDGE_PLUGIN_OCR=ON`. + +```bash +cd +cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_PLUGIN_OCR=ON +cmake --build build +cmake --install build +``` + +:::note +If the built `wasmedge` CLI tool cannot find the WasmEdge-OCR plug-in, you can set the `WASMEDGE_PLUGIN_PATH` environment variable to the plug-in installation path (such as `/usr/local/lib/wasmedge/`, or the built plug-in path `build/plugins/wasmedge_ocr/`) to try to fix this issue. +::: + +Then you will have an executable `wasmedge` runtime under `/usr/local/bin` and the WasmEdge-OCR plug-in under `/usr/local/lib/wasmedge/libwasmedgePluginWasmEdgeOCR.so` after installation. + +For more information, you can refer to the [GitHub repository](https://github.com/WasmEdge/WasmEdge/tree/master/plugins/wasmedge_ocr). diff --git a/docs/contribute/source/plugin/wasmedge_opencvmini.md b/docs/contribute/source/plugin/wasmedge_opencvmini.md new file mode 100644 index 00000000..11bfaf7f --- /dev/null +++ b/docs/contribute/source/plugin/wasmedge_opencvmini.md @@ -0,0 +1,43 @@ +--- +sidebar_position: 6 +--- + +# Build with WasmEdge-OpenCVMini Plug-in + +The WasmEdge-OpenCVMini plug-in exposes a subset of [OpenCV](https://opencv.org/) image processing functions to WebAssembly applications running on WasmEdge. It is designed for AI input/output pre- and post-processing tasks such as image resizing, color conversion, and basic transformations. + +## Prerequisites + +Install OpenCV 4 on your system. + +For Ubuntu 20.04: + +```bash +sudo apt update +sudo apt install -y libopencv-dev +``` + +For macOS: + +```bash +brew install opencv +``` + +## Build WasmEdge with WasmEdge-OpenCVMini Plug-in + +To enable the WasmEdge-OpenCVMini plug-in, developers need to [build WasmEdge from source](../os/linux.md) with the cmake option `-DWASMEDGE_PLUGIN_OPENCVMINI=ON`. + +```bash +cd +cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_PLUGIN_OPENCVMINI=ON +cmake --build build +cmake --install build +``` + +:::note +If the built `wasmedge` CLI tool cannot find the WasmEdge-OpenCVMini plug-in, you can set the `WASMEDGE_PLUGIN_PATH` environment variable to the plug-in installation path (such as `/usr/local/lib/wasmedge/`, or the built plug-in path `build/plugins/wasmedge_opencvmini/`) to try to fix this issue. +::: + +Then you will have an executable `wasmedge` runtime under `/usr/local/bin` and the WasmEdge-OpenCVMini plug-in under `/usr/local/lib/wasmedge/libwasmedgePluginWasmEdgeOpenCVMini.so` after installation. + +For more information, you can refer to the [GitHub repository](https://github.com/WasmEdge/WasmEdge/tree/master/plugins/wasmedge_opencvmini). diff --git a/docs/contribute/source/plugin/wasmedge_stablediffusion.md b/docs/contribute/source/plugin/wasmedge_stablediffusion.md new file mode 100644 index 00000000..f1b64404 --- /dev/null +++ b/docs/contribute/source/plugin/wasmedge_stablediffusion.md @@ -0,0 +1,84 @@ +--- +sidebar_position: 11 +--- + +# Build with WasmEdge Stable Diffusion Plug-in + +The WasmEdge Stable Diffusion plug-in enables WebAssembly applications to run image generation and image-to-image inference workloads using the [stable-diffusion.cpp](https://github.com/leejet/stable-diffusion.cpp) backend. It supports CPU inference out of the box, with optional CUDA and Metal acceleration for GPU-backed environments. + +## Prerequisites + +The Stable Diffusion plug-in has no mandatory system library dependencies — the `stable-diffusion.cpp` source is fetched automatically via CMake's `FetchContent` during the build. However, for GPU-accelerated builds, the following are required: + +- **CUDA** (for NVIDIA GPUs): Install the [CUDA Toolkit](https://developer.nvidia.com/cuda-downloads) appropriate for your platform. +- **Metal** (for Apple Silicon): Available by default on macOS with Xcode command-line tools installed. +- **OpenMP** (optional, for multi-threaded CPU inference): Install via your system package manager. + +For Ubuntu: + +```bash +sudo apt update +sudo apt install -y build-essential +# Optional: for OpenMP support +sudo apt install -y libomp-dev +``` + +For macOS: + +```bash +xcode-select --install +``` + +## Build WasmEdge with the Stable Diffusion Plug-in + +To enable the WasmEdge Stable Diffusion plug-in, developers need to [build WasmEdge from source](../os/linux.md) with the cmake option `-DWASMEDGE_PLUGIN_STABLEDIFFUSION=ON`. + +```bash +cd +cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release \ + -DWASMEDGE_PLUGIN_STABLEDIFFUSION=ON +cmake --build build +cmake --install build +``` + +### Optional: Enable CUDA Acceleration + +```bash +cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release \ + -DWASMEDGE_PLUGIN_STABLEDIFFUSION=ON \ + -DWASMEDGE_PLUGIN_STABLEDIFFUSION_CUDA=ON +cmake --build build +cmake --install build +``` + +### Optional: Enable Metal Acceleration (Apple Silicon) + +```bash +cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release \ + -DWASMEDGE_PLUGIN_STABLEDIFFUSION=ON \ + -DWASMEDGE_PLUGIN_STABLEDIFFUSION_METAL=ON +cmake --build build +cmake --install build +``` + +### Optional: Enable OpenMP + +```bash +cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release \ + -DWASMEDGE_PLUGIN_STABLEDIFFUSION=ON \ + -DWASMEDGE_PLUGIN_STABLEDIFFUSION_OPENMP=ON +cmake --build build +cmake --install build +``` + + +:::note +If the built `wasmedge` CLI tool cannot find the Stable Diffusion plug-in, you can set the `WASMEDGE_PLUGIN_PATH` environment variable to the plug-in installation path (such as `/usr/local/lib/wasmedge/`, or the built plug-in path `build/plugins/wasmedge_stablediffusion/`) to try to fix this issue. +::: + +Then you will have an executable `wasmedge` runtime under `/usr/local/bin` and the Stable Diffusion plug-in under `/usr/local/lib/wasmedge/libwasmedgePluginStableDiffusion.so` after installation. + +## More Information + +- [WasmEdge Stable Diffusion Plug-in source on GitHub](https://github.com/WasmEdge/WasmEdge/tree/master/plugins/wasmedge_stablediffusion) +- [stable-diffusion.cpp upstream](https://github.com/leejet/stable-diffusion.cpp) diff --git a/docs/contribute/source/plugin/wasmedge_zlib.md b/docs/contribute/source/plugin/wasmedge_zlib.md new file mode 100644 index 00000000..ad0f50fb --- /dev/null +++ b/docs/contribute/source/plugin/wasmedge_zlib.md @@ -0,0 +1,44 @@ +--- +sidebar_position: 12 +--- + +# Build with WasmEdge zlib Plug-in + +The WasmEdge zlib plug-in provides zlib compression and decompression functionality to WebAssembly applications running on WasmEdge. It allows Wasm modules that depend on zlib (such as those compiled from C/C++ with zlib linkage) to use the host system's zlib implementation directly. + +## Prerequisites + +Install zlib development headers on your system. + +For Ubuntu: + +```bash +sudo apt update +sudo apt install -y zlib1g-dev +``` + +For macOS: + +```bash +brew install zlib +``` + +## Build WasmEdge with the zlib Plug-in + +To enable the WasmEdge zlib plug-in, developers need to [build WasmEdge from source](../os/linux.md) with the cmake option `-DWASMEDGE_PLUGIN_ZLIB=ON`. + +```bash +cd +cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_PLUGIN_ZLIB=ON +cmake --build build +cmake --install build +``` + + +:::note +If the built `wasmedge` CLI tool cannot find the zlib plug-in, you can set the `WASMEDGE_PLUGIN_PATH` environment variable to the plug-in installation path (such as `/usr/local/lib/wasmedge/`, or the built plug-in path `build/plugins/wasmedge_zlib/`) to try to fix this issue. +::: + +Then you will have an executable `wasmedge` runtime under `/usr/local/bin` and the zlib plug-in under `/usr/local/lib/wasmedge/libwasmedgePluginWasmEdgeZlib.so` after installation. + +For more information, you can refer to the [GitHub repository](https://github.com/WasmEdge/WasmEdge/tree/master/plugins/wasmedge_zlib).