Compiler

Self-Hosting and Compiler Generations

The generation model used to evolve Raz without making each release depend on older compiler generations at runtime.

Raz Gen2 Manual·Compiler

Raz Gen2 is developed as a self-hosting compiler written in Raz. Each compiler generation is produced using the previous generation, then becomes the tool used to compile programs written for its own language version and build the next compiler generation.

Generation model

gen0 -- S1 --> gen1 -- S2 --> gen2 -- S3 --> gen3
                    |
                    +-- compiles programs written in L1

In this model, S1 is the source set used to produce gen1, S2 produces gen2, and so on. After a generation is established, its compiler is used to compile programs in its supported language version and to produce the next generation.

Rules

  • Generation n is built using generation n-1.
  • After the new generation is established, it is not required to recompile its own source with itself before it can be used.
  • A language generation may introduce or change syntax and compiler APIs used by the next generation. Breaking changes are permitted when they are part of the deliberate generation transition.
  • Self-hosting must be demonstrated by a reproducible bootstrap/build path, not merely by the compiler being written in Raz.

Compiler responsibilities

The compiler translates and validates Raz source, then emits C++17 for the configured GNU C++ toolchain. Standard-library modules provide APIs to programs; they are not a substitute for the compiler frontend. Raz standard-library source can be compiled as part of a program, while native C/C++ headers remain native dependencies.

Verification

The build and release workflow should record the source generation, compiler used for the build, compiler version metadata, and resulting binary checksum. Bootstrap verification should compare the expected compiler artifacts and should remain distinct from the compile-only language test suite.

Practical constraint: legacy generations may be kept as historical artifacts only when they are needed to reproduce a bootstrap step. They should not become active development dependencies after the replacement generation is established.