Skip to content
A jigsaw of white pieces with a single golden piece dropped into place.

xc

A typed, class-based C-like language and its multi-backend toolchain, for targets from native 64-bit hosts down to a banked 6502.

xc (repo: xc) is a compiler and toolchain for the xc language, a typed, class-based take on C. It provides auto type inference, classes with inheritance and protocols, automatic reference counting (ARC) with weak references, a heap with new / delete, closures and bound methods, multiple return values with tuple unpacking, exceptions (throws / try / catch), threading primitives, and a Foundation-style standard library. It stays close enough to C to keep a familiar syntax and inline assembly.

The compiler is built around a shared SSA-style intermediate representation. The front end lowers source to IR once. A shared optimiser runs on that IR: CSE, strength reduction, inlining, loop unrolling and rotation, if-conversion, tail-recursion elimination, and auto-vectorisation on capable targets. A per-architecture back end turns the optimised IR into native code, so a new target needs only a new back end.

The driver ships as xcc and behaves like a C compiler: xcc -o prog file.xc builds a native binary for the host, and -A <arch> cross-compiles to another target. The compiler is also self-hosting: a second implementation written in the xc language is byte-identical through every stage.

The toolchain drives several back ends from one language and one IR:

  • arm64: native Mach-O executables for Apple silicon (and the default host).
  • x86-64: native Linux executables. From 0.72 they are linked dynamically against glibc, as a C compiler’s are, so they can load GTK 4, libGL and other system libraries; -static links them over musl instead, so they run on any distribution. (Up to 0.71 the static link is the default and -dynamic asks for glibc.)
  • arm9 (AArch32): position-independent ELF.
  • win64: native PE executables with full C interop.
  • m68k: Motorola 68000/68030 (-A m68k for the 68000, -A 68030 for the 030). GEMDOS .prg executables, run with xcc-sim-68k.
  • WebAssembly: WAT / .wasm output.
  • xt6502: a banked 6502 target. The CPU has a hardware stack and memory-mapped bank selectors, and a linker script describes its code and data windows. The back end emits assembly that the in-house assembler turns into a banked binary.

The language

The xc language reference: types, operators, control flow, classes, inheritance and protocols, ARC and the heap, closures and bound methods, threading, modules and shared libraries, and inline assembly.

Read the language docs →

Standard library

The Foundation-style class library: Number / String / Data / Array, Stdio, Math, Time, the Heap, sorting, and the lower-level system and memory helpers.

Browse the API →

Using the compiler

Installing the toolchain, the full xcc CLI flag reference, optimisation levels, per-target memory models, the allocator and ARC, linker scripts, and migrating between releases.

See compiler usage →

Downloads

Get the latest xcc release, browse the historical archive, and read the changelog.

Get the toolchain →