Skip to content

C99 Emission & WASI Targets

Wysna compiles through intermediate representations directly into ANSI/ISO C99 source code. This architecture provides maximum portability, predictable binary layouts, and easy interoperability with existing C/C++ libraries.

Why target C99 instead of direct LLVM IR or raw assembly?

  1. Unrivaled Portability: C99 runs on virtually any architecture: x86_64, ARM64 (Apple Silicon), RISC-V, and embedded microcontrollers.
  2. Decades of Compiler Optimizations: Modern C compilers (LLVM Clang, GCC) perform world-class dead code elimination, auto-vectorization (SIMD), and loop unrolling.
  3. Auditable Code: You can inspect the emitted .c file and understand exactly how your Wysna data structures are mapped to memory.
  4. Effortless C FFI: Interfacing with C libraries (SQLite, OpenGL, OpenSSL) does not require complex glue wrappers.

Wysna includes first-class support for compiling to WASI (wasm32-wasip1) via wasi-sdk:

Terminal window
wysna build src/main.wysna --target wasi -o app.wasm

You can execute the resulting .wasm binary in any WASI-compliant runtime:

Terminal window
# Running with Wasmtime
wasmtime app.wasm
# Running with Wasmer
wasmer run app.wasm
# Running with Node.js
node --experimental-wasi-unstable-preview1 runner.mjs app.wasm

Wysna can also compile library modules into standalone WebAssembly packages for modern web browsers. Memory buffers, function calls, and UTF-8 strings are exchanged across the Wasm linear memory boundary using standardized ABI serialization.