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.
The C99 Emission Strategy
Section titled “The C99 Emission Strategy”Why target C99 instead of direct LLVM IR or raw assembly?
- Unrivaled Portability: C99 runs on virtually any architecture: x86_64, ARM64 (Apple Silicon), RISC-V, and embedded microcontrollers.
- Decades of Compiler Optimizations: Modern C compilers (LLVM Clang, GCC) perform world-class dead code elimination, auto-vectorization (SIMD), and loop unrolling.
- Auditable Code: You can inspect the emitted
.cfile and understand exactly how your Wysna data structures are mapped to memory. - Effortless C FFI: Interfacing with C libraries (SQLite, OpenGL, OpenSSL) does not require complex glue wrappers.
Compiling for WebAssembly (WASI)
Section titled “Compiling for WebAssembly (WASI)”Wysna includes first-class support for compiling to WASI (wasm32-wasip1) via wasi-sdk:
wysna build src/main.wysna --target wasi -o app.wasmRunning the WebAssembly Module
Section titled “Running the WebAssembly Module”You can execute the resulting .wasm binary in any WASI-compliant runtime:
# Running with Wasmtimewasmtime app.wasm
# Running with Wasmerwasmer run app.wasm
# Running with Node.jsnode --experimental-wasi-unstable-preview1 runner.mjs app.wasmIn-Browser Execution
Section titled “In-Browser Execution”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.