Skip to content

Link: an out/lib under the cwd is linked only when it is this compiler's runtime byte for byte (D30, #761 class) - #1720

Merged
ehartford merged 1 commit into
mainfrom
rt-link-generation
Sep 26, 2026
Merged

ehartford merged 1 commit into
mainfrom
rt-link-generation

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

with run, -e, -n and -p from a checkout whose out/lib was built by an older compiler died at link with an undefined with_vec_free_buffer_drop_origin: link_stage_resolve_runtime_root took any out/lib under the cwd ahead of the compiler's embedded objects. The same program linked from any other directory. This is #761's mixed-generation link, not a codegen regression.

Fix (D30): without the build's explicit WITH_OUT_DIR (which the seed's stage1 link relies on), an on-disk runtime directory is used only when its rt_core.o is byte-identical to the embedded one; otherwise the embedded objects are extracted.

Test: behav_stale_out_lib_runtime_is_not_linked plants a stale out/lib and runs the compiler with no artifact root.

Battery: queued (seed-driven), verdict to follow. Draft until green.

…r's runtime byte for byte (D30, #761 class)

`link_stage_resolve_runtime_root` took any `out/lib` under the current
directory ahead of the compiler's embedded objects, so `with run`, `-e`,
`-n` and `-p` from a checkout whose out/lib was built by an older compiler
linked that stale rt_core.o and died with an undefined
with_vec_free_buffer_drop_origin. The same program linked from any other
directory.

D30: an on-disk runtime object is a cache of the embedded one, and a cache
hit is byte-identical. Without the build's explicit artifact root
(WITH_OUT_DIR, which prepare-bootstrap-link-root relies on so the seed links
stage1 against the runtime compiled from the active tree) a candidate
directory is used only when its rt_core.o equals the embedded rt_core.o;
otherwise the embedded objects are extracted as before.

Test: behav_stale_out_lib_runtime_is_not_linked plants a stale out/lib in a
case and runs the compiler with no WITH_OUT_DIR, as a developer's shell
does (new p7_run_without_out_dir helper; p7_run_with_compiler now shares
its body).
@ehartford

Copy link
Copy Markdown
Contributor Author

Seed-driven battery green on bf3c028 (host darwin-aarch64, seed per seed.lock):

rtlink build  rc=0
rtlink build :fixpoint rc=0
rtlink build :test rc=0
rtlink build :test-green rc=0
rtlink build :last-green rc=0
rtlink build :user-programs-safe rc=0

@ehartford
ehartford marked this pull request as ready for review September 26, 2026 08:31
@ehartford
ehartford merged commit 2911b1d into main Sep 26, 2026
@ehartford
ehartford deleted the rt-link-generation branch September 26, 2026 16:23
ehartford pushed a commit that referenced this pull request Sep 27, 2026
…t is this seed's generation; a seed change clears the checkout's runtime objects; the runner-compile fallback is loud (#1797)

The pinned darwin seed (nightly-20260925, 607a52f) predates #1720's D30
check, so in a checkout whose out/lib held 2026-09-22 objects it linked the
native build runner against that stale runtime, died on the undefined
with_vec_free_buffer_drop_origin, printed a warning, fell back to comptime
evaluation, could not evaluate embedded-clang-resource-source there, and
was red before stage1 — while the 09-22 out/release/bin/with stayed in
place. Reproduced in a scratch worktree from the 09-22 tree and its seed.

- src/main.w: the runner is compiled only once out/bootstrap-lib is this
  compiler's generation — prepare-bootstrap-link-root completed in this run,
  or its rt_core.o byte for byte the embedded one (Link.w's D30 check, now
  pub) — and with WITH_OUT_DIR naming the build's root, exactly as stage1
  links. File existence said nothing about which generation built them.
  The fallback message is an error naming the cause and the cure.
- build.w: embedded-clang-resource-source runs in the runner (the seed's
  evaluator cannot run it), so it is ordered after the root is prepared.
- tools/battery.w: the driving seed's digest is recorded
  (out/.build-state/battery-seed.sha256); when it changed, out/lib,
  out/bootstrap-lib and out/tmp/with_runtime are removed before :gate.

Verified with stage1 as the driver: `:abi-hash-check --no-deps` compiles
the runner (root already this generation), `:stage2` is green with the
runner compiled after the root is prepared (a first cut that waited only
for completion went red: the resource action ran before the root).
ehartford added a commit that referenced this pull request Sep 27, 2026
…nup, and the native runner linked from this seed's bootstrap root (#1797) (#1795)

* build.w: `with build :gate` is the pre-battery gate — the fixed list plus every test target the last battery measured under 60 s (Eric, 2026-09-27)

A 6-layer stack took hours to land because the pre-battery gate was a
checklist an agent remembered, and an 18 s target (deep-debug-tool-tests)
was only ever run by the 25-minute battery. The gate is now one target:
build, selfcheck (the stage2 self-check of src/main.w; no stage1 variant
exists), reseed-check-build-w (which checks build.w and, through the fresh
release binary's embedded stdlib, lib/std/build.w), abi-hash-check,
unit-return-review, spec-inventory-check, examples-tests,
c-migrator-basic-tests, deep-debug-tool-tests, user-programs-safe, plus
every test lane the last battery measured under 60 s, then a gate-shape
line naming the measured members.

Test lanes are the non-Group targets reached from `test` through Group
targets only, minus test-green and seed-driver; a lane's own deps are
prerequisites, never tests. The measurements are the ledger
out/.build-state/battery-times.tsv that tools/battery.w merges from its
gate and checks runs (the driver's build-times.tsv is per invocation, so a
:dev in between would erase the battery's numbers). build.w is evaluated
once per build-source hash, so the battery deletes the evaluated-graph
cache when it rewrites the ledger. A fresh worktree has no ledger and runs
the fixed list.

The fixed list is built by push, not a collection literal: the pinned
seed's evaluator cannot take .len() of a literal (the #1122 class).

* tools/battery.w: run :gate first, report the first red live, --fail-fast (Eric, 2026-09-27)

A red known at minute 1 was read at minute 20: the battery wrote its
verdict only at the end, and the pre-battery gate was a checklist. Now the
battery runs `src/main build :gate` (the release build plus the fixed gate
and every lane the last battery measured under 60 s) before the 25-minute
checks; a red gate writes `RED (gate): <targets>` and stops. Both steps run
the child on an OS thread (std.thread; std.process has no non-blocking wait)
while the main thread polls the log once a second and appends
`RED: <target>` to out/battery/status.txt the moment a target fails; the
run still collects every red. `--fail-fast` is passed through to the driver
for the repair loop. The final RED/GREEN, BATTERY_DONE, logs and wall-time
lines are unchanged.

failed_targets now reads every failure spelling the driver has (test
target failed:, '<x>' failed, survey: skipping, the closing failed: list);
it used to match only the quoted build.w form.

After each step the driver's per-invocation build-times.tsv is merged into
out/.build-state/battery-times.tsv, the ledger build.w's gate reads (latest
measurement per target wins), and the evaluated-graph cache is removed so
the next build re-reads it.

Verified in a scratch git rig with fake gate/checks scripts: the RED line
was in status.txt while the child still ran; the ledger merged and sorted;
the flag reached the child. `with check` cannot verify the file: it rejects
every implicit-main script (filed separately).

* CLAUDE.md/AGENTS.md: the pre-battery gate is `src/main build :gate`; per-file-class checks for stack layers; the battery reports its first red live (Eric, 2026-09-27)

The gate was a checklist in an agent's memory, so steps were skipped and a
6-layer stack took hours to land. It is now one line — `src/main build
:gate`, the fixed list plus every test target the last battery measured
under 60 s — and every stack layer runs it before it reports done. A change
under src/Mir*.w, src/MirLower.w, src/MirValidate*.w or any validator runs
:deep-debug-tool-tests --no-deps and :drop-audit first; a change under
build/ or to build.w checks build.w and lib/std/build.w with the fresh
release binary. Agents read one existing behaviour test before writing a
fixture. The battery paragraph says the battery runs :gate first and writes
RED: <target> to status.txt live, with --fail-fast for repair loops.

The agents section no longer forbids :drop-audit and a full src/main build:
the gate is a full build, and the MIR rule requires the drop audit.

* CLAUDE.md/AGENTS.md: the other hosts — Linux is `ssh eric-5090`, Windows is the VM on eric-5090 then `ssh win10` (Eric, 2026-09-27)

* Build: the native runner links against the bootstrap link root once it is this seed's generation; a seed change clears the checkout's runtime objects; the runner-compile fallback is loud (#1797)

The pinned darwin seed (nightly-20260925, 607a52f) predates #1720's D30
check, so in a checkout whose out/lib held 2026-09-22 objects it linked the
native build runner against that stale runtime, died on the undefined
with_vec_free_buffer_drop_origin, printed a warning, fell back to comptime
evaluation, could not evaluate embedded-clang-resource-source there, and
was red before stage1 — while the 09-22 out/release/bin/with stayed in
place. Reproduced in a scratch worktree from the 09-22 tree and its seed.

- src/main.w: the runner is compiled only once out/bootstrap-lib is this
  compiler's generation — prepare-bootstrap-link-root completed in this run,
  or its rt_core.o byte for byte the embedded one (Link.w's D30 check, now
  pub) — and with WITH_OUT_DIR naming the build's root, exactly as stage1
  links. File existence said nothing about which generation built them.
  The fallback message is an error naming the cause and the cure.
- build.w: embedded-clang-resource-source runs in the runner (the seed's
  evaluator cannot run it), so it is ordered after the root is prepared.
- tools/battery.w: the driving seed's digest is recorded
  (out/.build-state/battery-seed.sha256); when it changed, out/lib,
  out/bootstrap-lib and out/tmp/with_runtime are removed before :gate.

Verified with stage1 as the driver: `:abi-hash-check --no-deps` compiles
the runner (root already this generation), `:stage2` is green with the
runner compiled after the root is prepared (a first cut that waited only
for completion went red: the resource action ran before the root).

* Build: the runner may link when no runtime directory on disk is another generation's — an absent out/lib or out/bootstrap-lib is nothing to mistrust (#1797 follow-up)

The first cut waited for prepare-bootstrap-link-root or a byte-identical
out/bootstrap-lib, so a project with neither (behav_build_early_cutoff's
two-target build, every user project) never compiled the runner and its
actions fell to the evaluator: behavior-tests red on the branch battery.
Readiness is now: the root was prepared in this run, or no complete
out/lib / out/bootstrap-lib (Link.w's cimport_stubs.o probe) holds another
generation's rt_core.o. Verified: the test passes against a stage2 built
from this rule; :abi-hash-check --no-deps compiles the runner; :stage2
green with the resource action after the prepared root.

---------

Co-authored-by: Eric Hartford <[email protected]>
ehartford pushed a commit that referenced this pull request Sep 27, 2026
… carries #1720 and #1797 (Fixes #1797)

Cut from main 9993935 after #1795 merged: that tree's seed-driven battery
is green, :install-user verified the binary against last-green, and its
reseed gate compiled the native build runner natively. The previous seed
(nightly-20260925, 607a52f) predates #1720's D30 rule and linked the
runner against whatever out/lib a checkout held; in one with 2026-09-22
objects it died on an undefined runtime symbol and fell back to comptime
evaluation, which cannot run this tree's actions (#1797). Workflow pins
by `with run tools/bump_seed_pins.w`; the old seed fetched and verified
the asset (`src/main build :seed`, digest cffa4a40…). This branch's
battery runs driven by the new seed.
ehartford pushed a commit that referenced this pull request Sep 27, 2026
… carries #1720 and #1797 (Fixes #1797)

Cut from main 9993935 after #1795 merged: that tree's seed-driven battery
is green, :install-user verified the binary against last-green, and its
reseed gate compiled the native build runner natively. The previous seed
(nightly-20260925, 607a52f) predates #1720's D30 rule and linked the
runner against whatever out/lib a checkout held; in one with 2026-09-22
objects it died on an undefined runtime symbol and fell back to comptime
evaluation, which cannot run this tree's actions (#1797). Workflow pins
by `with run tools/bump_seed_pins.w`; the old seed fetched and verified
the asset (`src/main build :seed`, digest cffa4a40…). This branch's
battery runs driven by the new seed.
ehartford pushed a commit that referenced this pull request Sep 28, 2026
… carries #1720 and #1797 (Fixes #1797)

Cut from main 9993935 after #1795 merged: that tree's seed-driven battery
is green, :install-user verified the binary against last-green, and its
reseed gate compiled the native build runner natively. The previous seed
(nightly-20260925, 607a52f) predates #1720's D30 rule and linked the
runner against whatever out/lib a checkout held; in one with 2026-09-22
objects it died on an undefined runtime symbol and fell back to comptime
evaluation, which cannot run this tree's actions (#1797). Workflow pins
by `with run tools/bump_seed_pins.w`; the old seed fetched and verified
the asset (`src/main build :seed`, digest cffa4a40…). This branch's
battery runs driven by the new seed.
ehartford added a commit that referenced this pull request Sep 28, 2026
… carries #1720 and #1797 (Fixes #1797) (#1801)

Cut from main 9993935 after #1795 merged: that tree's seed-driven battery
is green, :install-user verified the binary against last-green, and its
reseed gate compiled the native build runner natively. The previous seed
(nightly-20260925, 607a52f) predates #1720's D30 rule and linked the
runner against whatever out/lib a checkout held; in one with 2026-09-22
objects it died on an undefined runtime symbol and fell back to comptime
evaluation, which cannot run this tree's actions (#1797). Workflow pins
by `with run tools/bump_seed_pins.w`; the old seed fetched and verified
the asset (`src/main build :seed`, digest cffa4a40…). This branch's
battery runs driven by the new seed.

Co-authored-by: Eric Hartford <[email protected]>
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