PROPHET/CC

The own C toolchain.

ProphetCC

A C toolchain: preprocessor, compiler, assembler and linker, built on its own C library alone. It compiles the whole ProphetOS kernel, its libraries and programs, and it runs on ProphetOS itself, for every target it has.

What ProphetCC adds comes as attributes, builtins and analyses: ownership and borrowing, bounds, tested results, tagged unions, a checked mode that stops a fault by name.

Every stage is held against the host's chain on every change: the preprocessor token for token, the compiler over the run of what it emits, the assembler and linker byte for byte.

Tools

  • cpp: the preprocessor
  • cc: the compiler
  • as: the assembler
  • ld: the linker
  • build: the build driver

Targets

  • x86_64
  • aarch64
  • NVIDIA GPU (SM86)
  • SPIR-V (reader and writer)

Features

Tools

  • cpp, cc, as, ld: preprocessor, compiler, assembler, linker
  • Assembler and linker byte-identical to binutils
  • Builds the whole kernel
  • Runs on ProphetOS itself

Targets

  • x86_64
  • aarch64
  • NVIDIA GPU (SM86)
  • SPIR-V (reader and writer)

Safety analyses

  • Ownership and borrowing on parameters, locals and members
  • Bounds of arrays and counted_by pointers
  • Nullable pointers and fallible results tested before use
  • Error sets, tagged unions, complete switches over enums
  • Implicit conversions that change a value refused
  • Checked mode: every operation that can fault is checked

Compile time

  • Functions marked comptime run in the compiler
  • Their faults are compile errors
  • Constant branches decided, unreachable code dropped

Optimisation

  • Inlining, constants, common expressions
  • Locals and small arrays in registers
  • Loop work hoisted, addresses split into kept and stepping parts
  • Division by constants as multiplication, rotations recognised
  • Registers by the cost in loops, spills read back from registers
  • Every pass switchable on its own
  • Loops over rows in the vector units and on the card, every result held against the loop as written
  • Four outer rounds of a loop in one inner loop, every result bit for bit

Security

  • Key material wiped where its use ends
  • Control flow protection and indirect branch thunks
  • Kernel code model

Performance

Measured with ProphetCC Build 20261119184422 on an Intel Xeon W-11955M (x86_64), the machine quiet. Every compiler at -O2 (kefir at -O1, its one level) over the same preprocessed source, zig cc for the baseline x86_64. Each compiler ran alone in rounds of its own, the processor cooled to its idle warmth before every round; a round is the best of five runs taken three times, and a cell the least of up to four rounds. In each row the colours go by rank, from the best in green over yellow-green, yellow and orange to the last in red.

Library code of ProphetOS

WorkProphetCCgcc 16.2clang 22.1zig cckefir 0.5
SHA-256, 1 MiB4.01 ms3.04 ms2.93 ms2.93 ms5.72 ms
SHA-512, 1 MiB2.35 ms1.90 ms1.88 ms1.88 ms3.12 ms
BLAKE2s2.26 ms1.70 ms1.71 ms1.70 ms3.39 ms
ChaCha2030.7 ms28.7 ms16.8 ms16.9 ms64.2 ms
Poly1305, 4 MiB2.29 ms2.07 ms1.92 ms1.90 ms2.58 ms
CRC32, 2 MiB14.6 ms14.0 ms7.56 ms7.56 ms15.9 ms
X25519, 400 scalar products59.5 ms56.5 ms38.0 ms38.2 ms103.2 ms
ML-KEM-768, 200 key exchanges50.3 ms33.9 ms24.9 ms24.9 ms66.6 ms
ML-DSA-87, 20 signatures11.5 ms8.67 ms8.87 ms8.89 ms18.5 ms
calc, exact integers of 10,000 digits4.71 ms4.57 ms5.20 ms5.20 ms16.0 ms
LZ4, pack 4 MiB2.18 ms2.10 ms1.90 ms1.86 ms-
LZ4, unpack 4 MiB0.61 ms0.88 ms0.54 ms0.54 ms-
LZJB, pack 4 MiB2.13 ms2.00 ms2.05 ms2.01 ms-
LZJB, unpack 4 MiB0.85 ms1.04 ms0.67 ms0.70 ms-

All five give the same results, each work held by a checksum of its output. A dash: the compiler stops on that unit.

MP3 decoder, a whole song

WayProphetCCgcc 16.2clang 22.1zig cc
MP3 decoder, fixed point418.0 ms429.5 ms258.6 ms260.6 ms
MP3 decoder, floating point359.8 ms294.3 ms299.8 ms301.0 ms

All four decode the song to the same 11,570,688 bytes, in both ways. ProphetCC is slower here than in Build 20261118021336: the cause is found and fixed after this build.

Code size

OverProphetCCgcc 16.2clang 22.1zig cckefir 0.5
194 programs of ProphetOS (193 all five take)978,628 bytes940,648 bytes1,089,531 bytes1,145,498 bytes785,892 bytes

With the flags of the ProphetOS build for its programs.

Compile time

WorkProphetCCgcc 16.2clang 22.1zig cckefir 0.5
Compiling the same 193 programs3.48 s15.46 s15.46 s20.25 s23.20 s

Held against gcc

CheckResult
Lowering corpus, every function run218 of 218 as gcc
Records passed and returned across calls6600 of 6600 as gcc
Preprocessor over the tree of ProphetOS594 of 614 files token for token
C23 cases, -O0 and -O2, also by the own assembler66 of 66 as gcc -std=c23
Code gcc refuses78 of 78 refused too
Vector types, every case run129 of 129 as gcc
Stack room of arrays, x86_64 and aarch6441 of 41
Random programs (Csmith)37 alike, 0 apart
_BitInt up to 65535 bits, constants, switch, static values1160 of 1160 lines as gcc
Floats to and from __int12817 of 17 lines, three levels
Vectors across calls (SysV)13 of 13 lines, both ways
Records built where their result goes45 of 45 lines, both ways
Thread-local storage, eight threads4 of 4, by the host's and by the own assembler
The own linker against the host's, corpus44 of 44
Stack protector9 of 9 runs, the overflow caught
Source lines (-g), by the host's and by the own assembler0 findings at -O0 and -O2
The C runtime's helpers, against libgcc1,876,258 of 1,876,258
The safe stage, fuzzed: crashes, wrong refusals0 and 0 in 783 mutants

Usage

ProphetCC ships with ProphetOS and runs on it. Download ProphetOS.

cc -S prog.cthe assembler text prog.s
cc prog.cthe object prog.o
cc -O0 prog.cwithout optimisation; -O2 is the default
cc --target=aarch64 prog.cfor aarch64
cc --target=sm86 kern.ca kernel for the NVIDIA card, as kern.psm

Changelog

The marks of a line, and they stand in this order: + something new, ~ something changed, - something taken out, * a bug fixed in this build, ! a bug that is known and still open.

ProphetCC Build 20261126135331
2026-11-26 13:53

Shipped in ProphetOS Build 20261126144701

Changes:
+ ProphetCC: a Tiger Lake cost table, cheapest-row pick
+ ProphetCC: an ARMv7-R target (the KV260 R5F)
* ProphetCC: signed short division never faults
ProphetCC Build 20261125053322
2026-11-25 05:33
Changes:
+ Card: rows across thread blocks
+ Card: shared memory words
+ Card: loads and stores seen by the CPU
~ Card: small arrays kept in registers
ProphetCC Build 20261120160316
2026-11-20 16:03
Changes:
+ Loops over rows in AVX2, AVX-512, NEON
+ Loops over rows on the NVIDIA card
+ Vector types as whole instructions
+ _Atomic for objects of one register
+ long double as 128-bit IEEE without x87
+ Thread storage on aarch64
+ Debug information: types, objects, call frames
+ <stdbit.h> past one register
~ Constants kept in registers across loop turns
~ _BitInt past 128 bits in more places
~ Chains of conditionals of any length
~ gpucc folded into cc --target=sm86
! Some loops over doubles stay scalar
ProphetCC Build 20261119184422
2026-11-19 18:44
Changes:
+ Thread storage in the own assembler
+ -ffunction-sections, -fdata-sections, -fshort-wchar
~ #embed in one piece, far faster
~ More than 65535 header files
* Objects past 64 sections refused
* Short jumps over an alignment too long
* Sources over 4 MiB cut off
! MP3 decoder slower than the build before
ProphetCC Build 20261119180610
2026-11-19 18:06
Changes:
+ Freestanding C23 headers
+ long double on x86_64
+ goto into blocks with arrays
~ else-if chains without bound
~ #pragma once by file identity
~ Huge switches compile fast
~ Many macros compile fast
* Two returns merged wrongly
* goto back kept stack room
! Very long chains: much memory
ProphetCC Build 20261117231347
2026-11-17 23:13
Changes:
+ C23: nullptr, constexpr, #embed and more
+ _BitInt up to 65535 bits
+ Thread-local variables
+ Stack protector
+ Source lines for debuggers (-g)
+ Slices with __builtin_slice
+ Vectors and wide integers across calls
+ BMI instructions with -mbmi and -march=x86-64-v3
~ Structs built in place, members too, less copying
~ Float units of ProphetOS compiled by ProphetCC
ProphetCC Build 20261117134844
2026-11-17 13:48
Changes:
~ Sums of products four at a time
~ Division by a constant as a product
~ Small functions put in place
~ Short loops laid out
~ Leaner x86_64 code, fewer reloads
~ MP3 fixed point faster than gcc
ProphetCC Build 20261116130111
2026-11-16 13:01
Changes:
+ aarch64 back end
+ One cc for x86_64, aarch64 and the GPU
+ _BitInt up to 128 bits
+ Evaluation at compile time
+ Checks for tagged unions, error sets, non-null pointers
+ Lock checks for shared data
~ Floats kept in float registers
~ Repeated values computed once
~ Constants and ranges folded at compile time
ProphetCC Build 20261114123129
2026-11-14 12:31
Changes:
+ x86_64 back end, C to assembler text
+ Own assembler for every form the compiler writes
+ 128-bit integers, inline asm, atomics
+ Structs and floats across calls
+ Vector types and shuffles
+ Second calling convention
+ Card kernels over lanes
ProphetCC Build 20261106104112
2026-11-06 10:41
Changes:
+ GPU: vertex and fragment stages
+ GPU: tensor-core products (f16, bf16, tf32, s8)
+ GPU: atomics from C
ProphetCC Build 20261103015323
2026-11-03 01:53
Changes:
+ GPU: assembler for SM 8.6
+ GPU: any SM 8.6 program runs on the card
+ GPU: branches and scheduling
ProphetCC Build 20261027161625
2026-10-27 16:16
Changes:
~ Library versions read as dates
ProphetCC Build 20261023114417
2026-10-23 11:44
Changes:
+ ProphetCC, a project of its own: cpp, cc, as, ld
ProphetCC, part of ProphetOS Build 20261117135219
2026-11-17 13:52

Shipped in ProphetOS Build 20261117135219

Changes:
~ ProphetCC: crypto up to 30 percent faster
~ ProphetCC: MP3 fixed way 6 percent faster
~ ProphetCC: smaller code
ProphetCC, part of ProphetOS Build 20261116131439
2026-11-16 13:14

Shipped in ProphetOS Build 20261116131439

Changes:
~ ProphetCC: fixed way 17 percent past gcc
* ProphetCC: liveness over a loop's own block
ProphetCC, part of ProphetOS Build 20261114123957
2026-11-14 12:39

Shipped in ProphetOS Build 20261114123957

Changes:
~ ProphetCC its own project, pinned
ProphetCC, part of ProphetOS Build 20261106112153
2026-11-06 11:21

Shipped in ProphetOS Build 20261106112153

Changes:
+ Own compiler checks for the GPU part
ProphetCC, part of ProphetOS Build 20261103020404
2026-11-03 02:04

Shipped in ProphetOS Build 20261103020404

Changes:
+ ProphetCC compiles C for the GPU
ProphetCC, part of ProphetOS Build 20261022182246
2026-10-22 18:22

Shipped in ProphetOS Build 20261022182246

Changes:
+ Own C compiler IR