Skip to content

The build refuses a symlinked out/gen; generated compiler modules are stage inputs (the stack's 'self-miscompile' was cross-worktree contamination) - #1971

Merged
ehartford merged 1 commit into
fix-1766from
fix-gen-dir-guard
Oct 2, 2026
Merged

ehartford merged 1 commit into
fix-1766from
fix-gen-dir-guard

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Layer 6 of stack #1969. The 'self-miscompile' the stack battery hit was not the compiler: every scratch worktree symlinked out/gen to the main checkout's; compat-runtime-source writes out/gen/compiler/EmbeddedStdlibData.w there and the stage compiles read it, so a stage2 in one worktree embedded ANOTHER worktree's stdlib mid-build. Proof: lldb showed different AST node ids for gen_pull's parameter type between the good and bad stage2; the EMBEDDED_STD_* text dumped from the bad binary was batch-b's (a gen_pull[T, G: Gen[T]] present in no commit of that tree); a clean control build of the exact commit is fine. Fixpoint caught it because stage2 and stage3 were built minutes apart while the shared file changed; the per-layer gates each used one self-consistent binary; the #1654 mid-run guard was blind because the Embedded*Data.w modules were deps, not inputs. b2b9145 (reverted during the bisect) was innocent and is back in layer 4.

Fix: build_graph_refuse_shared_gen_dir (src/main.w) refuses a symlinked out/gen, naming its target; build.w declares the four generated modules as inputs of the stage targets (in: lines in stage2.state); selfhost gen_link case red-first; behav_gen_pull_infers_from_generator_arg.w fails on the contaminated binary, passes clean. Full build 347 s, :fixpoint 16/16, :gate rc=0 (on the fix branch's tree).

… stage inputs

A stage2 built on 2026-10-02 in a worktree whose out/gen was a symlink to
~/with/out/gen embedded a sibling worktree's std/task.w: that tree's build
rewrote out/gen/compiler/EmbeddedStdlibData.w while the stage2 compile ran.
The compiler so built failed `ns(3).pull()` with "cannot infer type
parameter 'T'" (the sibling spells gen_pull `[T, G: Gen[T]](g: G)`, which
this Sema cannot bind T from), stage3 embedded yet another text, every unit
differed at fixpoint-compare, and the afternoon went to a 12-line
ComptimeEval change (b2b9145) that was innocent: a stage2 built from the
same commit with its own out/gen checks the program ok.

Two silent tools, fixed:

- The build driver refuses an out/gen that is a symlink, names where it
  points and says to copy the directory instead (generated sources are per
  tree, D50). build/selfhost.w's build.w suite pins it: a project whose
  out/gen links elsewhere fails `with build` with that message; the pre-fix
  compiler built it green.
- target_with_compiler_source_inputs declares the four generated modules
  (EmbeddedStdlibData, EmbeddedRuntimeData, EmbeddedBundlesData,
  EmbeddedClangResourceData) as inputs of every compiler build, not only as
  dep outputs, so the #1654 mid-run guard and the freshness check cover a
  rewrite under the compile.

test/behavior/behav_gen_pull_infers_from_generator_arg.w pins the rejected
program as a user program: it fails on the contaminated stage2 and passes
on a clean one.

(cherry picked from commit 9167a3e9195cca08f2394708ecc540f15cf01ba4)
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery GREEN on stack top 7bdd704 (seed-driven, with run tools/battery.w, stack #1972 = #1966 → #1956 → #1961 → #1968 → #1959 → #1971 → #1970, on main 30f89aa): gate rc=0 wall=489s, battery-checks rc=0 wall=379s — fixpoint, drop and move audits, every corpus. Earlier reds on this stack were (a) #1239/#1955 fallout in fixtures the sweeps did not compile, fixed in-layer and in #1970, and (b) a stage2≠stage3 'self-miscompile' that turned out to be cross-worktree contamination through a shared out/gen symlink, root-caused with lldb and guarded in #1971; the bisect-reverted commit was innocent and is restored. Run from a worktree with its own out/gen.

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