Cesium logo Cesium

Compilation Model

November 27, 2026

This page summarizes how Cesium programs are compiled, from the point of view of someone writing Cesium. The compiler’s internals are described in Compiler and Toolchain.

Info: Source

Decision records cesiumlang/cesium#4, #5, #6 and #7. These are accepted plans; the compiler is not yet implemented.

Source Files

  • Cesium source files use the .csm extension.
  • Module interface files use the .csi extension.

The Compiler

  • One self-contained binary. The compiler needs no separate toolchain: no C compiler, no SDK and no system libc on the user’s machine. The linker is built in.

  • The compiler is written in Cesium and reaches its first working version through a bootstrap chain that starts from a small compiler written in portable C.

  • Two backends behind a semantic IR. Every program is lowered to Cesium’s semantic IR, and from there to one of two backends:

    • QBE for development, bootstrapping and quick ports to new architectures;
    • LLVM as the release backend, for optimization, vectorization, full debug information and every supported target.

    QBE comes first; LLVM is added later and is what releases use.

Properties of Compiled Programs

  • libc-free. Natively built Cesium programs do not depend on a C library. The standard library talks to the operating system directly. Programs that link C libraries which need libc use a hosted link mode.
  • C ABI compatible. Cesium functions can call and be called from C.
  • Static dispatch only. There are no virtual calls; overloads are resolved at compile time.
  • Generics are monomorphized.
  • No undefined behavior in arithmetic. Integer arithmetic wraps, and shifts and division by zero have defined results, the same on every backend. See Type System.

Target Platforms

ArchitecturePlatforms
x86_64Windows, Linux, macOS 11+, UEFI, freestanding
aarch64Windows, Linux, macOS 11+, UEFI, freestanding
32-bit ARMfreestanding
PowerPC 750freestanding
SPIR-VVulkan shaders
WebAssemblyWASI and freestanding (tier 2)

Bare-metal targets are a first-class goal: see Freestanding Targets.

Question: Open

The parts of the compilation model that a programmer sees most directly are not designed yet: how files map to namespaces, separate compilation, what an interface file contains, and symbol naming (cesiumlang/cesium#47); the accepted signatures of main (the reference shows void = main() and i32 = main(), and the S0 subset uses i32 = main(i32 argc, ##u8 argv); tracked in cesiumlang/cesiumlang.org#10); and what comptime means (cesiumlang/cesium#55). The compiler’s command line has not been specified either.