Repository navigation
build: stop a stale stage0 from compiling the stdlib (and reporting it as an untracked error) - #1496
Conversation
|
Merged The only conflict was the Verified in a clean worktree at 7553c34:
Note: this environment needed |
7553c34 to
df0f1ad
Compare
|
Rebased onto The rebase had one conflict, in commit 2 ( Still needs CI green + review from @jberdine. |
…-opping Each stage target names a directory and had no prerequisites, so as a file target make considered it up to date the moment the directory existed. Once you had built a stage, `make stageN` printed "'stageN' is up to date" and recursed into nothing -- reusing whatever binaries were left in stageN/bin, however old. That is how a stage0 built weeks earlier survived a git pull, a bootstrap submodule bump and a rebuild: nothing ever asked make to look inside the directory again. Make the aggregates phony so they always recurse. Recursing every time is cheap now: the stage0 rules key off real inputs (cb1adfc), and stages 1-3 delegate freshness to skargo, which tracks its own state. Under the default -j the inner sub-make inherits the jobserver and the #1581 prerequisite ordering between the stage skargo builds is unchanged. CI and Docker consumers already build from clean trees (.circleci/base.yml, skiplang/Dockerfile, bin/bump_bootstrap.sh), so this only changes behaviour on a warm local tree -- which is the case it fixes: `make`, `make test` and `make install` now re-check the stage artifacts instead of no-opping. The stages are listed explicitly rather than matched with `stage%`: make skips implicit-rule search for phony targets, so a phony target built by a pattern rule gets "Nothing to be done" instead. Naming them also turns a typo like `make stage7` into an error rather than a successful no-op. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
…e$(STAGE) Two problems, both of the same silent-staleness kind the phony stage targets fix: `stageD/bin/skc` had no prerequisites at all, so once built it was never rebuilt however much of the compiler or prelude changed. Its recipe already computed the source list; hoist it into STAGED_SRC and use it (plus the prelude build inputs, PRELUDE_BUILD_SRCS) as prerequisites, so the target is genuinely tracked and the find runs once instead of twice. The last line then moved the emitted IR out of `stage$(STAGE)`, not stageD. That is only coherent under `make STAGE=D`; with the default STAGE=1 it relocates stage1's skc.ll and plants a stray skc-d.ll in stage1's deps directory, where `make promote` globs skc-*.ll and would match two files. On a tree without a stage1 it instead aborts with `mv: cannot stat` after the whole compile has already succeeded. Name stageD literally: identical under STAGE=D, correct for `make stageD`. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
The comment justified the second `make clean` with "the stage rules key off stage directory mtimes, so a partial clean would reuse stale stages". They no longer do: the stage aggregates are phony and the stage rules key off real inputs, so a warm tree rebuilds exactly what changed. The cleans are still right, for the reason the first one already states: a from-scratch bootstrap is the point of the verification, and it keeps the skc-*.ll glob that `make promote` copies from unambiguous. Say that instead of describing behaviour that no longer exists. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
df0f1ad to
65f8b77
Compare
|
Rebased onto Commits 1, 2, 5 and 7 of the original series are absorbed by main ( |
Fixes #1408.
What this fixes
A stale
stage0silently compiles the current prelude and reports errors for language features it predates. Astage0/bin/skcolder than@allow_tracked_callfails with 47 ×Cannot call an untracked function from a tracked context, which reads exactly like the stdlib having been broken by theuntrackedmigration. It has not been.Two make-level defects combined to cause it (both diagnosed in #1408):
stage0/lib/libstd.sklibhad no dependency onstage0/bin/skc, so an outdatedskcalready sitting instage0/binwas used as-is to compile the current prelude — and the bootstrap IR it should have been rebuilt from was never unpacked, socheck-bootstrapnever ran on this path either. Fixed on main by cb1adfc (stage0/lib/libstd.sklib: stage0/bin/skc <prelude srcs> …, a real file target).stage%names a directory and had no prerequisites, so as a file target make considers it up to date the moment the directory exists: on a warm treemake stageN(and plainmake,make test,make install) printed "up to date"/"Nothing to be done" and recursed into nothing — reusing however stale askcwas instageN/bin, surviving agit pull, a bootstrap bump and a rebuild. Fixed by this PR.Rebase status (2026-11-19, onto
main@ e3d2ba7, head65f8b777)Rebased from
ef1d0618; four of the original seven commits are absorbed by main and were dropped:stage0/bin/skcbefore compiling the stdlib with itstage0/lib/libstd.sklibtarget withstage0/bin/skcprerequisite)PRELUDE_BUILD_SRCS; archive targets are real files now, so the order-only trick is unnecessary).PHONY, so plaincponly fires on real changes; the remaining wasm.bcchain is #1495)&:grouped targets — one recipe, once even under-j, which also resolves the #1492 race)What remains (3 commits):
.PHONY: stage0 stage1 stage2 stage3 stageDwith an explicit rule (phony targets skip implicit-rule search, so astage%pattern would get "Nothing to be done"; naming them also turnsmake stage7into an error instead of a silent no-op). Recursing every time is cheap: stage0's rules key off real inputs (cb1adfc) and stage1+ delegate freshness to skargo; under the default-jthe sub-make inherits the jobserver and the make -j on skiplang/compiler races on shared stage target dir (state.db collisions, libbacktrace configure race) #1581 prerequisite ordering between stage skargo builds is unchanged.stageD/bin/skcits sources, and stop it writing intostage$(STAGE)— no prerequisites meant it was never rebuilt after source edits; and with the defaultSTAGE=1its last line relocated stage1'sskc.llinto stage1's deps dir (wheremake promoteglobsskc-*.ll) or aborted withmv: cannot statafter a successful compile. Now keyed on$(STAGED_SRC) $(PRELUDE_BUILD_SRCS)and namesstageDliterally.bump_bootstrap.shcomment that justifiedmake cleanwith stage-directory mtimes — the cleans stay, but for the real reasons: a true from-scratch verification and an unambiguousskc-*.llglob.Validation (rebased head
65f8b777,skiplabs/skip:latest, GNU Make 4.3, 8 cores)make STAGE=0: green. Warmmake STAGE=0: 0.13s, recurses (phony) with every stage0 file target reported up to date — noclang++relink, no stdlib recompile.origin/main's Makefile:make stage0→ "'stage0' is up to date",make→ "Nothing to be done" — no recursion at all.src/*.skfires thelibstd.sklibrecipe (plus the dependent skfmt/skargo relinks);rm stage0/bin/skcfires exactly the skc relink (real relink green);make -n stage7→ "No rule to make target 'stage7'".make STAGE=1: green in 9m26s; warmmake STAGE=1rerun: 24.8s (stage0 targets up to date in ~0.1s; the three stage1 skargo invocations re-run their own freshness check, everything Fresh, no relink);stage1/bin/skc --versionruns.shellcheck bin/bump_bootstrap.shclean (make check-sh); no.sk/.c/.tschanges, socheck-fmtis unaffected. Full CI re-runs on this head..circleci/base.yml(make STAGE=1in a fresh container; the stage0 cache's mtime refresh makes the now-always-recursed file targets correctly up to date),skiplang/Dockerfileand rootDockerfile(make clean && make STAGE=0),bin/bump_bootstrap.sh(make cleanbefore each stage) all build from clean trees, where phony vs directory target makes no difference.Not in scope
#1408's third suggestion — a runtime diagnostic when const-init detects compiler/stdlib version skew — remains a backstop for skew this line of fixes prevents at the source. Follow-up.
The seven pre-existing same-class defects filed from the original review remain open and unaffected: #1490, #1491, #1492, #1493, #1494, #1495, #1498. (#1492's
-jdouble-run hazard is now addressed on main by the&:grouped targets this branch no longer needs to split; #1495's wasmllc/llvm-archain is the one.PHONY-prerequisite case left.)Original series written by Claude (Opus 5, 1M context) via Claude Code, on behalf of @mbouaziz. Rebased onto e3d2ba7 and re-validated with Mistral Vibe (Mistral Vibe CLI); commits carry the corresponding Co-Authored-By trailers. GNU make semantics verified empirically on GNU Make 4.3; build results from real runs inside
skiplabs/skip:latest.