Skip to content

fix: self_host_full takes gen0 from the checked-in bootstrap C - #1435

Merged
godofecht merged 1 commit into
mainfrom
fix/self-host-fixed-point
Oct 7, 2026
Merged

godofecht merged 1 commit into
mainfrom
fix/self-host-fixed-point

Conversation

@godofecht

Copy link
Copy Markdown
Contributor

Report

./flow tool compiler/scripts/self_host_full.flow failed locally on main after #1363: gen1.c != gen2.c, differing in the vector_size preamble and some TOK_* lines. CI's required "flowc self-host (no Python)" job passed on the same commit.

Root cause

The checked-in compiler/bootstrap/flowc_stage_a.c is at the fixed point. The local failure came from gen0 selection in self_host_full.flow: it took the first executable among the roundtrip drivers (compiler/build/stage_a_driver_flow_self, ...) and compiler/build/flowc_bootstrap, and never checked any of them against the bootstrap C. A flowc_bootstrap built before #1363 merged (the one in a long-lived checkout) emits gen1.c without the #739 vector preamble, gen1 then emits it in gen2.c, and the fixed point fails.

CI was green because each job starts from a clean checkout and bootstrap_from_c.sh builds flowc_bootstrap fresh right before the gate. The CI check already covers this: flowc-selfhost runs self_host_full for every change under compiler/**, which includes compiler/src and compiler/bootstrap, and it is a required check. No ci.yml change is needed.

Fix

gen0 is now gl_flowc_cached("FLOWC_BOOTSTRAP", root), the helper the parity gates already use: compiler/build/flowc_bootstrap, rebuilt when missing or older than the bootstrap C. FLOWC_BOOTSTRAP still overrides it. The roundtrip call to self_host_full now checks the checked-in bootstrap as well, where before it compared compiler/src against a driver compiled from compiler/src.

tests/scripts/self_host_gen0.flow (run by ./flow test-scripts in the required "Native tools" job) runs the real gate against a scratch root whose compiler is a small C program, with a stale flowc_bootstrap and a stale roundtrip driver in place, and checks that a stale gen0 forced through FLOWC_BOOTSTRAP still fails the fixed point.

Baseline and proof

  • Clean origin/main 81ecf1e, macOS arm64: self_host_full ALL PASS (gen0 = fresh flowc_bootstrap).
  • Same tree, FLOWC_BOOTSTRAP = the pre-cgen: remaining SIMD lowering for hot C loops (#739) #1363 flowc_bootstrap from a long-lived checkout: FAIL fixed point: gen1.c != gen2.c, diff > typedef float flowc_v4f32 __attribute__((vector_size(16))); ... and < const int32_t TOK_PLUS_EQ = 42; ..., matching the report.
  • New test on the old script: 1 passed, 2 failed (stale_bootstrap_is_rebuilt, roundtrip_driver_is_ignored). On the new script: 3 passed.

Gates

See the comment below for the gate run on this branch.

Risk

Low. Script and test only; no compiler/src or bootstrap C change. roundtrip now spends one extra cc -O2 of the bootstrap C when flowc_bootstrap is missing.

@godofecht

godofecht commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor Author

Gates on branch head 58f4ad5, macOS arm64, FLOW_GATE_JOBS=2:

  • fmt_check --check: pass
  • self_host_full: ALL PASS (gen0 = fresh compiler/build/flowc_bootstrap)
  • test-lang: pass
  • tests/cgen/run.flow: pass
  • parity_lowering, parity_effects, parity_proofs, parity_mlir, parity_field_dsl, parity_dynamics_dsl, parity_flow_blocks, parity_shader_dsl: pass
  • parse_coverage --check: pass
  • roundtrip.flow: pass (its self_host_full step now uses flowc_bootstrap as gen0, ALL PASS)
  • test-scripts self_host_gen0: 3 passed
  • script_refs: pass
  • corpus_parity --check: 1016 < floor 1033 on Darwin. The same count shows up in an earlier run on main for another PR, and neither touched file is a non-match. This failure predates this PR and only happens on Darwin. The required Linux job passes.

self_host_full picked the first executable among the roundtrip.flow
drivers and compiler/build/flowc_bootstrap, with no check against
compiler/bootstrap/flowc_stage_a.c. A flowc_bootstrap built before #1363
made gen1.c != gen2.c locally (missing vector_size preamble, TOK_* lines
moved), while CI, building from a clean checkout, passed. The checked-in
bootstrap C is at the fixed point.

gen0 now comes from gl_flowc_cached: compiler/build/flowc_bootstrap,
rebuilt when missing or older than the bootstrap C. FLOWC_BOOTSTRAP still
overrides it. tests/scripts/self_host_gen0.flow runs the real gate against
a scratch root with a stale flowc_bootstrap and a stale roundtrip driver;
both checks fail on the old selection.
@godofecht
godofecht force-pushed the fix/self-host-fixed-point branch from 58f4ad5 to b93fc82 Compare October 7, 2026 14:35
@godofecht
godofecht merged commit 03a7d60 into main Oct 7, 2026
35 checks passed
godofecht added a commit that referenced this pull request Oct 7, 2026
selfcompile_audit.flow and package_flowc.flow picked the first executable
among the roundtrip.flow drivers (stage_a_driver_flow_self and friends)
and compiler/build/flowc_bootstrap, with no check against
compiler/bootstrap/flowc_stage_a.c. The audit then checked, and the
package shipped, whatever stale binary was left in compiler/build. #1435
fixed the same selection in self_host_full.flow.

Both now use gl_flowc_cached: flowc_bootstrap, rebuilt when missing or
older than the bootstrap C. FLOWC_AUDIT_BIN still overrides the audit;
the package honours FLOWC_BOOTSTRAP, as self_host_full does. The package
ships the binary as bin/flowc-core behind the bin/flowc wrapper that
build.sh writes, so the prebuilt bin/flowc keeps the
`flowc <in.flow> <out.c>` interface.

corpus_parity, fmt_check, parse_coverage and mlir_vs_c carried inline
copies of the helper and now call it. The helper builds to a temporary
file and renames it, as mlir_vs_c did, so concurrent gates never run a
half-written binary.

tests/scripts/self_host_gen0.flow runs the real audit and packaging
against a scratch root with a stale flowc_bootstrap, a stale roundtrip
driver and the env override. Five of the six new checks fail on the old
selection.
@godofecht
godofecht deleted the fix/self-host-fixed-point branch October 12, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant