koch: rebuild nifler/nifmake when the nimony pin moves

`bundleChecksums` built the two host tools only `if not fileExists`, so
bumping `NimonyStableCommit` in a tree that already has `bin/nifler`
leaves them on the previous commit while the compiler links the new
`dist/nimony/src/lib`. The two halves of the IC toolchain then disagree
about the on-disk formats, with nothing saying so.

The failure mode is the wrong way round: a fresh CI checkout has no
`bin/`, builds both tools from the new pin and goes green; only a
working tree that already has them breaks. Stamp each tool with the
nimony commit it was built from and rebuild when that no longer matches.
Where the commit cannot be read (a bundled `dist` with no `.git`), keep
the old build-if-absent rule rather than rebuilding on every boot.
This commit is contained in:
araq
2026-08-31 09:14:50 +02:00
parent b6248a0b80
commit 82b1b9a3c9

View File

@@ -196,10 +196,31 @@ proc bundleChecksums(latest: bool) =
# to `koch boot`, but `nimCompileFold` spawns a fresh `nim c` that would
# otherwise inherit the ambient configuration.
const nifOptions = "-d:release --noNimblePath --skipUserCfg --skipParentCfg"
if not fileExists("bin/nifler".exe):
nimCompileFold("Compile nifler", "dist/nimony/src/nifler/nifler.nim", options = nifOptions)
if not fileExists("bin/nifmake".exe):
nimCompileFold("Compile nifmake", "dist/nimony/src/nifmake/nifmake.nim", options = nifOptions)
# Rebuilding these only when the binary is ABSENT silently keeps the tools of
# the PREVIOUS pin: bump `NimonyStableCommit` in a checkout that already has
# `bin/nifler`, and the compiler links the new `dist/nimony/src/lib` while
# `nifler`/`nifmake` still speak the old one. A fresh CI checkout has no
# `bin/`, so it builds them and looks green — only the working tree that
# already has them breaks, which is the worst way round to find out. So stamp
# each tool with the nimony commit it came from and rebuild on a mismatch.
# If the commit cannot be determined (a bundled `dist` with no `.git`), fall
# back to the old build-if-absent rule rather than rebuilding every time.
let nimonyHead = block:
let (outp, status) = osproc.execCmdEx(
"git -C " & quoteShell(distDir / "nimony") & " rev-parse HEAD")
if status == 0: outp.strip else: ""
proc bundleNifTool(name, src: string) =
let stamp = "bin" / ("." & name & ".nimony-commit")
let builtFrom = if fileExists(stamp): readFile(stamp).strip else: ""
if not fileExists(("bin" / name).exe) or
(nimonyHead.len > 0 and builtFrom != nimonyHead):
nimCompileFold("Compile " & name, src, options = nifOptions)
if nimonyHead.len > 0: writeFile(stamp, nimonyHead)
bundleNifTool("nifler", "dist/nimony/src/nifler/nifler.nim")
bundleNifTool("nifmake", "dist/nimony/src/nifmake/nifmake.nim")
proc bundleNimsuggest(args: string) =
bundleChecksums(false)