The Seen compiler is self-hosted: it compiles itself. The bootstrap system ensures this property is maintained safely across changes.
A self-hosted compiler can compile its own source code. To verify this:
This proves the compiler is correct and self-consistent.
| File | Purpose |
|---|---|
bootstrap/stage1_frozen |
Frozen, verified bootstrap compiler |
bootstrap/stage1_frozen.sha256 |
SHA-256 hash for integrity |
compiler_seen/target/seen |
Production compiler |
scripts/safe_rebuild.sh |
Safe rebuild with verification |
.githooks/pre-commit |
Automatic bootstrap check on commit |
The recommended way to rebuild after compiler changes:
./scripts/safe_rebuild.sh
This script:
bootstrap/stage1_frozencompiler_seen/target/seenEnable automatic bootstrap verification on commit:
git config core.hooksPath .githooks
The hook:
compiler_seen/src/compiler_seen/src/)./scripts/safe_rebuild.shOnly update when you have a verified working compiler:
# 1. Verify current compiler passes bootstrap
./scripts/safe_rebuild.sh
# 2. If successful, update frozen compiler
cp stage2_head bootstrap/stage1_frozen
sha256sum bootstrap/stage1_frozen > bootstrap/stage1_frozen.sha256
# 3. Commit
git add bootstrap/
git commit -m "Update frozen bootstrap compiler"
Build stages manually:
# Stage 2: frozen compiler builds the source
./bootstrap/stage1_frozen compile compiler_seen/src/main_compiler.seen stage2_new
# Stage 3: stage2 builds the source
./stage2_new compile compiler_seen/src/main_compiler.seen stage3_new
# Verify
diff stage2_new stage3_new # should be identical
If the production compiler is broken:
# Option 1: Use the frozen bootstrap compiler
./bootstrap/stage1_frozen compile compiler_seen/src/main_compiler.seen recovery_compiler
# Option 2: Check out a known-good commit
git checkout ead1940 -- compiler_seen/src/
./bootstrap/stage1_frozen compile compiler_seen/src/main_compiler.seen recovery_compiler
Some features require a two-phase bootstrap:
This is necessary when the new feature uses syntax or constructs that the current frozen compiler doesn't understand.
| Problem | Cause | Solution |
|---|---|---|
| "undefined value" error | New method not in old compiler | Two-phase bootstrap (stub first) |
| GEP index out of bounds | Struct field count mismatch | Update struct_layouts.seen, verify field order |
| S2 != S3 != S4 | Non-deterministic codegen | Check for HashMap/time usage in compiler |
| Cache invalidation | Changed declarations | Clear .seen_cache/ and /tmp/seen_ir_cache |
