Skip to content

Cross-Compilation

Wyn compiles to multiple platforms from any host using C as the portable backend.

Quick Start

bash
wyn run app.wyn                    # TCC (fastest iteration)
wyn build app.wyn                  # System cc (default)
wyn build --release app.wyn        # Optimized (-O2)
wyn cross linux-x64 app.wyn        # Cross-compile to Linux

How It Works

Wyn emits portable C code, then invokes the appropriate C compiler for the target platform. This means any platform with a C compiler is a valid target.

  • Dev builds: TCC (bundled) — compiles in milliseconds
  • Release builds: System clang/gcc — full optimizations
  • Cross builds: Target-specific C cross-compiler

Targets

bash
wyn cross linux-x64 app.wyn        # Linux x86_64
wyn cross linux-arm64 app.wyn       # Linux ARM64
wyn cross windows-x64 app.wyn       # Windows x86_64
wyn cross macos-x64 app.wyn         # macOS Intel
wyn cross macos-arm64 app.wyn        # macOS Apple Silicon
wyn cross ios app.wyn                # iOS (requires Xcode)
wyn cross android app.wyn            # Android ARM64 (requires NDK)
wyn cross wasm32 app.wyn             # WebAssembly (requires emcc)
wyn cross riscv64 app.wyn            # RISC-V 64-bit

Backend

ModeCommandCompilerUse Case
Devwyn runTCC (bundled)Fast iteration, scripting
Defaultwyn buildSystem ccDevelopment builds
Releasewyn build --releaseclang/gcc -O2Production, small binaries
WASMwyn build --wasmEmscriptenBrowser, playground

Cross-Compiler Requirements

Most targets need a cross-compiler installed:

TargetRequired ToolStatus
linux-x64 (from Mac)zig (brew install zig)✅ Working
linux-arm64 (from Mac)brew install aarch64-unknown-linux-gnu or zig✅ Working
iosXcode (Apple clang)✅ Working
androidAndroid NDK✅ Working
wasm32Emscripten or zig🔧 In progress
windows-x64MinGW or zig✅ Working

Cross-compilation builds the runtime library for the target automatically — no pre-built libraries needed.

bash
# Install zig (recommended — covers all Linux targets)
brew install zig

# Then cross-compile
wyn build --target linux-x64 app.wyn    # → app.wyn.linux (ELF x86_64)
wyn build --target linux-arm64 app.wyn   # → app.wyn.linux (ELF ARM64)

Binary Size

Wyn produces small, self-contained binaries with no runtime dependencies:

ProgramSize (release)
Hello world~50KB
HTTP server~120KB
CLI tool~80KB

Use --release with -s (strip) for smallest output.

See Also

MIT License