# `nanowasm`, the tiny Wasm interpreter that does not block you **This project is still unfinished and is not meant for production use.** This project aims to provide the most minimal Wasm interpreter possible in strictly portable ANSI C (C89/C90). It can run one or more Wasm applications concurrently, without threading. This project requires the [Nanowasm extensions](https://gitea.privatedns.org/xavi/nanowasm-design/) to the WebAssembly language. A NanoWasm-compatible program can be built from a MVP WebAssembly program with [`nwc`](https://gitea.privatedns.org/xavi/nwc/). ## Features - Portable **ANSI C** implementation. **Runs on bare metal environments**. - **No dependencies** other than an ANSI C (C89/C90) compiler. - Asynchronous interface that allows to **run multiple applications** **concurrently, without threads**. - **I/O-agnostic** implementation for maximum flexibility: read modules from a network, write the stack into a file, implement a MMU in software... Anything is possible! - Suitable for **resource-constrained devices**, such as microcontrollers. - **No memory allocator required**. - Supports both **big-endian and little-endian architectures**. ### Comparison chart | Feature | `nanowasm` | [`wasm-micro-runtime`] | [`wasm3`] | [`wac`] | [`toywasm`] | | ------- | ------- | ------- | ------- | ------- | ------- | | **Asynchronous interface** | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | | **I/O-agnostic** | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | | **No heap required** | ✅ | ❌ | ❌ | ❌ | ❌ | | **Big-endian support** | ✅ | ⚠️ | ✅ | ❌ | ✅ | | **No compiler-specific extensions** | ✅ | ❌ | ❌ | ❌ | ❌ | | **C dialect** | **`c89`** | `gnu99` | `c99` | `gnu99` | `c11` | | **Public functions** | **7** | 156 | 44 | N/A | N/A | | **Minimal `.text` footprint** | **49 KiB** | 452 KiB | 519 KiB | N/A | N/A | | **Per-module memory usage** | ~1016 bytes | N/A | N/A | N/A | N/A | | **Per-instance memory usage** | ~728 bytes | N/A | N/A | N/A | N/A | Also, see a [detailed explanation](COMPARE.md) behind the numbers above. ## What `nanowasm` is not As opposed to other interpreters, `nanowasm` prefers lower memory usage rather than run-time performance. Therefore, it should not be unfairly compared _performance_-wise against other interpreters. ## How to build Use the conventional process in CMake projects: ``` cmake -B cmake --build ``` ## Examples - [`example/minimal.c`](examples/minimal.c) provides the essential minimum code required to work with `nanowasm` i.e., without any imports. This is only meant as a starting point for implementations, and not as a standalone program. - [`example/proc_exit.c`](examples/proc_exit.c) defines the code required to support the following minimal C program built with [`wasi-sdk`](https://github.com/WebAssembly/wasi-sdk): ```c int main() { return 0; } ``` ## License ``` nanowasm, a tiny WebAssembly/Wasm interpreter Copyright (C) 2023-2025 Xavier Del Campo Romero This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. ``` Also, see [LICENSE](LICENSE). [`wasm-micro-runtime`]: https://github.com/bytecodealliance/wasm-micro-runtime [`wasm3`]: https://github.com/wasm3/wasm3 [`wac`]: https://github.com/kanaka/wac [`toywasm`]: https://github.com/yamt/toywasm