VolkanaDEV

Compiler Pipeline

How your source becomes something that runs

Three steps

StepWhat it does
1. seed/compiler.bcThe compiler itself, written in Sanguis. Its checksum is pinned, so you know it's the one we shipped.
2. sanguis bleedTurns a .sanguis file into BloodCode (.bc). sg is the short name.
3. sanguis blobTakes the system cells out of a .bc and packs them into a native module (.mod).

The compiler checks itself

Give the compiler its own source and it builds a new copy of itself. That copy is identical to the one you started with, down to the byte. The kit's verify command does this every time you run it, and prints VERIFIED when they match.

The compiler's source is in the kit too, at toolchain/lib/compiler.sanguis. You can read every line.

Files you can read

A .bc file is plain text, so open it and have a look. A module has three parts. BLOB1 says how many bytes of code there are, BLOBOFF says where each cell starts, and BLOB2 is the machine code itself, written in hex.

Any language that can map a file into memory and call an address can load a module. Read it, map it, call it.

Speed

The compiler builds itself in 11 seconds. It used to take 29.

The register emitter makes modules a lot smaller. One kernel-sized module went from 43,760 bytes to 13,536. To be sure smaller didn't mean wrong, we ran a fuzzer against it: 40 seeds, 1,440 calls each, and not one mismatch.

In a web page

All of this works in a browser too. The floor runs as WebAssembly, the compiler runs right on the page, and it can even rebuild itself there in about 10 seconds, byte for byte. Try it on our demo page, or read Sanguis in Web Pages.