session-2026-09-28.md 2.1 KB

Session save — 2026-09-28: V3 self-hosting FIXPOINT reached

master — suite 111/111, tree clean except the user's uncommitted compiler/toto.mod edit.

Headline: the fixpoint

bootstrap/fixpoint.sh:

Stage 1: gm2 builds V3 (CR -m)              -> m2s1
Stage 2: m2s1 compiles the whole compiler   -> stage2.ssa (assembled -> m2s2)
Stage 3: m2s2 compiles the whole compiler   -> stage3.ssa
cmp stage2.ssa stage3.ssa  *** FIXPOINT OK (1,991,439 bytes) ***

The V3 compiler now rebuilds itself to a byte-identical image. Tags: v3-fixpoint, v3-bootstrap.

The last fix (b6ae57b)

QbeGen.InitHeap allocated each nested element sub-array (ARRAY … OF ARRAY … on the heap/stack) but never initialised its descriptor header, so a local ARRAY [0..15] OF Name handed garbage to GetName (scanner) when names[i] was passed as an ARRAY OF CHAR. Now InitHeap(eb, elem) is called on each sub-array.

Arc completed

From "sources compile and link" to the fixpoint — every step a real V3 runtime/ABI bug with a minimal repro: nested modules; inline record array fields; the NUL-terminated string model; p^ as a VAR actual; de-eagered NIL guards; off-by-one string scans; short-circuit AND/OR; nested-array heap initialisation.

Codebases / tags of interest

  • v3-fixpoint — b6ae57b (the fix + docs/summary_fixpoint.md).
  • v3-bootstrap — 42cbe36 (bootstrap/fixpoint.sh).
  • Earlier: v3-short-circuit, v3-selfcompiles, v3-inline-array-fields, v3-nul-strings, v3-deref-var-actual, v3-selfcompile-image, …

Remaining polish

  • Cross-stage FileIO selection is implicit (stage 1 uses the host FileIO; the compiled image embeds the self-hosted one). Make it explicit if desired.
  • Optionally M2make-driven build; more stdlib; unicode (step 6 plan).
  • The toolchain still needs gm2 only for Stage 1 (bootstrapping the seed binary); fixpoint.sh documents the stage-aware CR flag.

Resume

cd .../m2compiler-V3
./bootstrap/fixpoint.sh          # FIXPOINT OK: stage2.ssa == stage3.ssa
cd compiler && ./build.sh && ./run_tests.sh   # 111/111