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 LinuxHow 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-bitBackend
| Mode | Command | Compiler | Use Case |
|---|---|---|---|
| Dev | wyn run | TCC (bundled) | Fast iteration, scripting |
| Default | wyn build | System cc | Development builds |
| Release | wyn build --release | clang/gcc -O2 | Production, small binaries |
| WASM | wyn build --wasm | Emscripten | Browser, playground |
Cross-Compiler Requirements
Most targets need a cross-compiler installed:
| Target | Required Tool | Status |
|---|---|---|
| linux-x64 (from Mac) | zig (brew install zig) | ✅ Working |
| linux-arm64 (from Mac) | brew install aarch64-unknown-linux-gnu or zig | ✅ Working |
| ios | Xcode (Apple clang) | ✅ Working |
| android | Android NDK | ✅ Working |
| wasm32 | Emscripten or zig | 🔧 In progress |
| windows-x64 | MinGW 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:
| Program | Size (release) |
|---|---|
| Hello world | ~50KB |
| HTTP server | ~120KB |
| CLI tool | ~80KB |
Use --release with -s (strip) for smallest output.
See Also
- Mobile Development — build for iOS and Android
- Deploying — deploy compiled binaries
- CLI Commands —
wyn crosscommand