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)

There is no riscv64 target - wyn cross riscv64 answers Unknown target. wyn cross wasm is accepted but WebAssembly is not usable; see below.

Backend ​

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

WebAssembly is not usable. wyn build --wasm does not produce WebAssembly in either argument order: wyn build app.wyn --wasm silently writes a native binary and prints a success tick, and wyn build --wasm app.wyn fails with No main.wyn found in --wasm because the flag is parsed as a path. wyn cross wasm is accepted but needs Emscripten, and the runtime still has POSIX dependencies that need #ifdef guards. Treat WASM as unimplemented, not as a flag that needs the right incantation.

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
windows-x64MinGW or zig✅ Working
wasm32-❌ Not supported (see above)

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 - v1.21.0