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 preprocessorcc: the compileras: the assemblerld: the linkerbuild: 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_bypointers - 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
comptimerun 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
| Work | ProphetCC | gcc 16.2 | clang 22.1 | zig cc | kefir 0.5 |
|---|---|---|---|---|---|
| SHA-256, 1 MiB | 4.01 ms | 3.04 ms | 2.93 ms | 2.93 ms | 5.72 ms |
| SHA-512, 1 MiB | 2.35 ms | 1.90 ms | 1.88 ms | 1.88 ms | 3.12 ms |
| BLAKE2s | 2.26 ms | 1.70 ms | 1.71 ms | 1.70 ms | 3.39 ms |
| ChaCha20 | 30.7 ms | 28.7 ms | 16.8 ms | 16.9 ms | 64.2 ms |
| Poly1305, 4 MiB | 2.29 ms | 2.07 ms | 1.92 ms | 1.90 ms | 2.58 ms |
| CRC32, 2 MiB | 14.6 ms | 14.0 ms | 7.56 ms | 7.56 ms | 15.9 ms |
| X25519, 400 scalar products | 59.5 ms | 56.5 ms | 38.0 ms | 38.2 ms | 103.2 ms |
| ML-KEM-768, 200 key exchanges | 50.3 ms | 33.9 ms | 24.9 ms | 24.9 ms | 66.6 ms |
| ML-DSA-87, 20 signatures | 11.5 ms | 8.67 ms | 8.87 ms | 8.89 ms | 18.5 ms |
| calc, exact integers of 10,000 digits | 4.71 ms | 4.57 ms | 5.20 ms | 5.20 ms | 16.0 ms |
| LZ4, pack 4 MiB | 2.18 ms | 2.10 ms | 1.90 ms | 1.86 ms | - |
| LZ4, unpack 4 MiB | 0.61 ms | 0.88 ms | 0.54 ms | 0.54 ms | - |
| LZJB, pack 4 MiB | 2.13 ms | 2.00 ms | 2.05 ms | 2.01 ms | - |
| LZJB, unpack 4 MiB | 0.85 ms | 1.04 ms | 0.67 ms | 0.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
| Way | ProphetCC | gcc 16.2 | clang 22.1 | zig cc |
|---|---|---|---|---|
| MP3 decoder, fixed point | 418.0 ms | 429.5 ms | 258.6 ms | 260.6 ms |
| MP3 decoder, floating point | 359.8 ms | 294.3 ms | 299.8 ms | 301.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
| Over | ProphetCC | gcc 16.2 | clang 22.1 | zig cc | kefir 0.5 |
|---|---|---|---|---|---|
| 194 programs of ProphetOS (193 all five take) | 978,628 bytes | 940,648 bytes | 1,089,531 bytes | 1,145,498 bytes | 785,892 bytes |
With the flags of the ProphetOS build for its programs.
Compile time
| Work | ProphetCC | gcc 16.2 | clang 22.1 | zig cc | kefir 0.5 |
|---|---|---|---|---|---|
| Compiling the same 193 programs | 3.48 s | 15.46 s | 15.46 s | 20.25 s | 23.20 s |
Held against gcc
| Check | Result |
|---|---|
| Lowering corpus, every function run | 218 of 218 as gcc |
| Records passed and returned across calls | 6600 of 6600 as gcc |
| Preprocessor over the tree of ProphetOS | 594 of 614 files token for token |
| C23 cases, -O0 and -O2, also by the own assembler | 66 of 66 as gcc -std=c23 |
| Code gcc refuses | 78 of 78 refused too |
| Vector types, every case run | 129 of 129 as gcc |
| Stack room of arrays, x86_64 and aarch64 | 41 of 41 |
| Random programs (Csmith) | 37 alike, 0 apart |
| _BitInt up to 65535 bits, constants, switch, static values | 1160 of 1160 lines as gcc |
| Floats to and from __int128 | 17 of 17 lines, three levels |
| Vectors across calls (SysV) | 13 of 13 lines, both ways |
| Records built where their result goes | 45 of 45 lines, both ways |
| Thread-local storage, eight threads | 4 of 4, by the host's and by the own assembler |
| The own linker against the host's, corpus | 44 of 44 |
| Stack protector | 9 of 9 runs, the overflow caught |
| Source lines (-g), by the host's and by the own assembler | 0 findings at -O0 and -O2 |
| The C runtime's helpers, against libgcc | 1,876,258 of 1,876,258 |
| The safe stage, fuzzed: crashes, wrong refusals | 0 and 0 in 783 mutants |
Usage
ProphetCC ships with ProphetOS and runs on it. Download ProphetOS.
cc -S prog.c | the assembler text prog.s |
cc prog.c | the object prog.o |
cc -O0 prog.c | without optimisation; -O2 is the default |
cc --target=aarch64 prog.c | for aarch64 |
cc --target=sm86 kern.c | a 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.
Shipped in ProphetOS Build 20261126144701
+ ProphetCC: a Tiger Lake cost table, cheapest-row pick + ProphetCC: an ARMv7-R target (the KV260 R5F) * ProphetCC: signed short division never faults
+ Card: rows across thread blocks + Card: shared memory words + Card: loads and stores seen by the CPU ~ Card: small arrays kept in registers
+ 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
+ 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
+ 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
+ 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
~ 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
+ 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
+ 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
+ GPU: vertex and fragment stages + GPU: tensor-core products (f16, bf16, tf32, s8) + GPU: atomics from C
+ GPU: assembler for SM 8.6 + GPU: any SM 8.6 program runs on the card + GPU: branches and scheduling
~ Library versions read as dates
+ ProphetCC, a project of its own: cpp, cc, as, ld
Shipped in ProphetOS Build 20261117135219
~ ProphetCC: crypto up to 30 percent faster ~ ProphetCC: MP3 fixed way 6 percent faster ~ ProphetCC: smaller code
Shipped in ProphetOS Build 20261116131439
~ ProphetCC: fixed way 17 percent past gcc * ProphetCC: liveness over a loop's own block
Shipped in ProphetOS Build 20261114123957
~ ProphetCC its own project, pinned
Shipped in ProphetOS Build 20261106112153
+ Own compiler checks for the GPU part
Shipped in ProphetOS Build 20261103020404
+ ProphetCC compiles C for the GPU
Shipped in ProphetOS Build 20261022182246
+ Own C compiler IR