[GH-ISSUE #2054] update.sh: failed engine build leaves BUILD.json stamped with new source hash — engine never rebuilt (stale binary reports old version) #821

Closed
opened 2026-11-04 01:46:13 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @MrKop-git on GitHub (Oct 12, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2054

update.sh: a failed engine build leaves BUILD.json stamped with the new source hash — the engine is then never rebuilt

Environment

  • Linux (CachyOS/Arch rolling), CUDA 12 toolkit at /opt/cuda-12.8, GTX 1080 Ti (sm_61 → engine-cuda12, "source": "local")
  • System gcc had just been upgraded 14 → 16 (CUDA 12.8's nvcc rejects gcc > 14 as host compiler)
  • Repo at v0.1.43, engine previously built at v0.1.42

What happened (observable on disk)

  1. 2026-10-11 11:44 — engine built fine (0.1.42), engine-cuda12/strata --version → strata 0.1.42
  2. 2026-10-12 11:16 — git pull to v0.1.43 (tag verified: git describe --tags → v0.1.43), then ./update.sh at 11:20
  3. The rebuild failed (nvcc's #error -- unsupported GNU version! gcc versions later than 14 are not supported, from the gcc-16 upgrade)
  4. Afterwards:
    • engine-cuda12/strata — unchanged old binary (mtime still 2026-10-11 11:44, still reports 0.1.42)
    • engine-cuda12/BUILD.json — rewritten at 11:20 with version: 0.1.43 and the new src hash
  5. Every subsequent ./update.sh printed "engine already built for this PC" and finished with "Strata is updated (engine 0.1.43)" while the running binary was still 0.1.42. The mismatch persisted silently across multiple update runs.

(Consistency side note: with BUILD.json moved away, ./update.sh instead reports "engine 0.1.42" and does nothing — update_installed_engine() returns early when the stamp is missing, so there is no state in which the update offers to rebuild.)

Workaround used

Invoking build_engine() directly with CC=gcc-14 CXX=g++-14 CUDAHOSTCXX=g++-14 rebuilt 0.1.43 correctly.

Suggested hardening

  • Before accepting meta.get("src") == source_hash(ENGINE_SOURCES) as "already built", also verify the installed binary's actual version matches source_version() (e.g. run strata --version, or compare a build-id/version resource). A stale-binary/new-stamp mismatch currently survives forever.
  • Consider logging a loud warning when a build attempt fails after the stamp strategy could have been affected, and never write the stamp unless the link step succeeded.

Secondary: host compiler on rolling distros

host_compiler_defs() only honors CC/CXX/CUDAHOSTCXX when the user sets them. On Arch-type systems gcc regularly moves ahead of what a given CUDA 12.x nvcc accepts, and the failure is a raw nvcc #error inside CMake compiler detection — hard to interpret. It would help a lot if install_build_tools() auto-fell-back to an older installed host compiler (e.g. probe g++-14, g++-13, …) when the default one is newer than the toolkit supports.

Happy to provide full logs of the 11:20 run's output if useful — thanks for a great project, the conversation-cache/session design is lovely.

Originally created by @MrKop-git on GitHub (Oct 12, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/2054 ## `update.sh`: a failed engine build leaves `BUILD.json` stamped with the new source hash — the engine is then never rebuilt ### Environment - Linux (CachyOS/Arch rolling), CUDA 12 toolkit at `/opt/cuda-12.8`, GTX 1080 Ti (sm_61 → `engine-cuda12`, `"source": "local"`) - System gcc had just been upgraded 14 → 16 (CUDA 12.8's nvcc rejects gcc > 14 as host compiler) - Repo at v0.1.43, engine previously built at v0.1.42 ### What happened (observable on disk) 1. 2026-10-11 11:44 — engine built fine (0.1.42), `engine-cuda12/strata --version` → `strata 0.1.42` 2. 2026-10-12 11:16 — `git pull` to v0.1.43 (tag verified: `git describe --tags` → `v0.1.43`), then `./update.sh` at 11:20 3. The rebuild failed (nvcc's `#error -- unsupported GNU version! gcc versions later than 14 are not supported`, from the gcc-16 upgrade) 4. Afterwards: - `engine-cuda12/strata` — **unchanged old binary** (mtime still 2026-10-11 11:44, still reports 0.1.42) - `engine-cuda12/BUILD.json` — **rewritten at 11:20 with `version: 0.1.43` and the new `src` hash** 5. Every subsequent `./update.sh` printed "engine already built for this PC" and finished with "Strata is updated (**engine 0.1.43**)" while the running binary was still 0.1.42. The mismatch persisted silently across multiple update runs. (Consistency side note: with `BUILD.json` moved away, `./update.sh` instead reports "engine **0.1.42**" and does nothing — `update_installed_engine()` returns early when the stamp is missing, so there is no state in which the update offers to rebuild.) ### Workaround used Invoking `build_engine()` directly with `CC=gcc-14 CXX=g++-14 CUDAHOSTCXX=g++-14` rebuilt 0.1.43 correctly. ### Suggested hardening - Before accepting `meta.get("src") == source_hash(ENGINE_SOURCES)` as "already built", also verify the installed binary's actual version matches `source_version()` (e.g. run `strata --version`, or compare a build-id/version resource). A stale-binary/new-stamp mismatch currently survives forever. - Consider logging a loud warning when a build attempt fails *after* the stamp strategy could have been affected, and never write the stamp unless the link step succeeded. ### Secondary: host compiler on rolling distros `host_compiler_defs()` only honors `CC`/`CXX`/`CUDAHOSTCXX` when the user sets them. On Arch-type systems gcc regularly moves ahead of what a given CUDA 12.x nvcc accepts, and the failure is a raw nvcc `#error` inside CMake compiler detection — hard to interpret. It would help a lot if `install_build_tools()` auto-fell-back to an older installed host compiler (e.g. probe `g++-14`, `g++-13`, …) when the default one is newer than the toolkit supports. Happy to provide full logs of the 11:20 run's output if useful — thanks for a great project, the conversation-cache/session design is lovely.
Author
Owner

@MrKop-git commented on GitHub (Oct 12, 2026):

Full post-mortem (we dug out of this state — more hardening opportunities found)

Picking this back up after fully recovering, with the exact trigger and two more failure-mode details that would have saved us hours.

Trigger confirmed

The system gcc was upgraded 14 → 16 (Arch/CachyOS rolling) between the successful 0.1.42 build (Oct 11) and the git pull + ./update.sh to 0.1.43 (Oct 12). CUDA 12.8's nvcc rejects gcc > 14 as host compiler → CMake's CUDA compiler-id detection dies. So the same setup that built fine yesterday fails today with zero Strata-side changes — rolling-distro users will hit this regularly.

The poisoned on-disk state (for anyone reproducing)

engine-cuda12/strata       → old 0.1.42 binary (mtime unchanged)
engine-cuda12/BUILD.json   → version 0.1.43 + NEW source hash
./update.sh                → "engine already built for this PC", forever

Recovery that worked: CC=gcc-14 CXX=g++-14 CUDAHOSTCXX=g++-14 + invoking build_engine() directly (plus proxy env for the llama.cpp fetch). update.sh alone cannot recover from this state — nor from a deleted BUILD.json (see below).

Additional hardening opportunities discovered on the way out

  1. A stale build-cuda12/CMakeCache.txt with STRATA_ENABLE_CUDA=OFF turns the failure opaque. If the build dir was ever configured without the engine defs (in our case: an interrupted earlier attempt, plus a manual cmake -S . -B build-cuda12), cmake_build() can configure "successfully" and then die at ninja: error: unknown target 'strata' — twice (the retry repeats the identical failure), ending with a message that doesn't point at the real problem. Suggestion: after configure, verify the target actually exists; if not, wipe the build dir once and reconfigure before giving up. (Wiping the dir and re-running with the gcc-14 env fixed it here.)

  2. update_installed_engine() returns silently when BUILD.json is missing. That's the one state a user who "cleaned up a bit" cannot recover from at all: with the stamp gone it neither downloads nor compiles — it just prints the binary's version and exits. Suggestion: treat missing stamp + existing binary (or missing both, with a local toolchain) as unknown provenance → rebuild, or at minimum log why nothing is being done.

The minimal fix for the original bug remains the one from the report: before trusting meta["src"] == source_hash(), check the installed binary's actual version against source_version() — a stale-binary/new-stamp mismatch then self-heals on the next update instead of surviving forever.

Positive finding worth keeping (data point, not a bug)

Because of unrelated GPU-driver crashes this box rebooted ~8 times in one day while serving a ~47k-token session. The engine's built-in restore (it picks autosave.bin, falls back to autosave.1.bin, both visible in the log with read+check timings) combined with a 5-minute autosave wrapper recovered the session on every single crash with ≤5 min loss. That part of the design works beautifully.

<!-- gh-comment-id:6119714403 --> @MrKop-git commented on GitHub (Oct 12, 2026): ## Full post-mortem (we dug out of this state — more hardening opportunities found) Picking this back up after fully recovering, with the exact trigger and two more failure-mode details that would have saved us hours. ### Trigger confirmed The system gcc was upgraded 14 → 16 (Arch/CachyOS rolling) *between* the successful 0.1.42 build (Oct 11) and the `git pull` + `./update.sh` to 0.1.43 (Oct 12). CUDA 12.8's nvcc rejects gcc > 14 as host compiler → CMake's CUDA compiler-id detection dies. So the same setup that built fine yesterday fails today with zero Strata-side changes — rolling-distro users will hit this regularly. ### The poisoned on-disk state (for anyone reproducing) ``` engine-cuda12/strata → old 0.1.42 binary (mtime unchanged) engine-cuda12/BUILD.json → version 0.1.43 + NEW source hash ./update.sh → "engine already built for this PC", forever ``` Recovery that worked: `CC=gcc-14 CXX=g++-14 CUDAHOSTCXX=g++-14` + invoking `build_engine()` directly (plus proxy env for the llama.cpp fetch). `update.sh` alone cannot recover from this state — nor from a deleted BUILD.json (see below). ### Additional hardening opportunities discovered on the way out 1. **A stale `build-cuda12/CMakeCache.txt` with `STRATA_ENABLE_CUDA=OFF` turns the failure opaque.** If the build dir was ever configured without the engine defs (in our case: an interrupted earlier attempt, plus a manual `cmake -S . -B build-cuda12`), `cmake_build()` can configure "successfully" and then die at `ninja: error: unknown target 'strata'` — twice (the retry repeats the identical failure), ending with a message that doesn't point at the real problem. Suggestion: after configure, verify the target actually exists; if not, wipe the build dir once and reconfigure before giving up. (Wiping the dir and re-running with the gcc-14 env fixed it here.) 2. **`update_installed_engine()` returns silently when `BUILD.json` is missing.** That's the one state a user who "cleaned up a bit" cannot recover from at all: with the stamp gone it neither downloads nor compiles — it just prints the binary's version and exits. Suggestion: treat missing stamp + existing binary (or missing both, with a local toolchain) as *unknown provenance → rebuild*, or at minimum log why nothing is being done. The minimal fix for the original bug remains the one from the report: before trusting `meta["src"] == source_hash()`, check the installed binary's actual version against `source_version()` — a stale-binary/new-stamp mismatch then self-heals on the next update instead of surviving forever. ### Positive finding worth keeping (data point, not a bug) Because of unrelated GPU-driver crashes this box rebooted ~8 times in one day while serving a ~47k-token session. The engine's built-in restore (it picks `autosave.bin`, falls back to `autosave.1.bin`, both visible in the log with read+check timings) combined with a 5-minute autosave wrapper recovered the session on **every single crash with ≤5 min loss**. That part of the design works beautifully.
Author
Owner

@Niko1221 commented on GitHub (Oct 12, 2026):

Thank you, MrKop-git, for the post-mortem. The two-line description of the on-disk state (old binary, new BUILD.json) was exactly what we needed, and the gcc 14 -> 16 trigger is a good one to know about.

Fixed in 0.1.43.1: setup no longer trusts a BUILD.json on its own. It now reads the version compiled into the engine file and compares it with the source's: a stale binary beside a new stamp is compiled again on the next ./update.sh (and UPDATE.bat), and a build that finishes without producing an engine of the source's version stops with a message and writes no stamp and installs nothing, so the old engine and its old stamp stay as they were. The HIP build has the same check.

Not done in this release, and worth their own issues if you want them: choosing an older installed host compiler (g++-14, g++-13) automatically when the default one is newer than the toolkit supports, repairing a wiped build folder whose cache has the engine switched off, and rebuilding when BUILD.json is missing but a binary is there. For the compiler, CC=gcc-14 CXX=g++-14 CUDAHOSTCXX=g++-14 ./update.sh is the way for now.

<!-- gh-comment-id:6129339087 --> @Niko1221 commented on GitHub (Oct 12, 2026): Thank you, MrKop-git, for the post-mortem. The two-line description of the on-disk state (old binary, new BUILD.json) was exactly what we needed, and the gcc 14 -> 16 trigger is a good one to know about. Fixed in 0.1.43.1: setup no longer trusts a BUILD.json on its own. It now reads the version compiled into the engine file and compares it with the source's: a stale binary beside a new stamp is compiled again on the next `./update.sh` (and `UPDATE.bat`), and a build that finishes without producing an engine of the source's version stops with a message and writes no stamp and installs nothing, so the old engine and its old stamp stay as they were. The HIP build has the same check. Not done in this release, and worth their own issues if you want them: choosing an older installed host compiler (`g++-14`, `g++-13`) automatically when the default one is newer than the toolkit supports, repairing a wiped build folder whose cache has the engine switched off, and rebuilding when BUILD.json is missing but a binary is there. For the compiler, `CC=gcc-14 CXX=g++-14 CUDAHOSTCXX=g++-14 ./update.sh` is the way for now.
Author
Owner

@qiuzan2001 commented on GitHub (Oct 15, 2026):

The three follow-ups from your last comment, as their own issues: #2576 (an older installed g++ when the default is newer than the toolkit accepts), #2578 (a build folder configured without the strata target), #2579 (an engine binary without its BUILD.json is never updated).

<!-- gh-comment-id:6184608821 --> @qiuzan2001 commented on GitHub (Oct 15, 2026): The three follow-ups from your last comment, as their own issues: #2576 (an older installed g++ when the default is newer than the toolkit accepts), #2578 (a build folder configured without the `strata` target), #2579 (an engine binary without its BUILD.json is never updated).
Author
Owner

@Niko1221 commented on GitHub (Oct 19, 2026):

Thanks for the report. This is fixed in 0.2.0-beta (or an earlier release), and we're closing it as part of the tracker reset for 0.2.0-beta.

If it still happens on 0.2.0-beta, add the area prefix to the title ([Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]), put the Strata version and your hardware in the issue form fields, and comment /reopen. A check runs and reopens it.

<!-- gh-comment-id:6270768496 --> @Niko1221 commented on GitHub (Oct 19, 2026): Thanks for the report. This is fixed in 0.2.0-beta (or an earlier release), and we're closing it as part of the tracker reset for 0.2.0-beta. If it still happens on 0.2.0-beta, add the area prefix to the title ([Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]), put the Strata version and your hardware in the issue form fields, and comment `/reopen`. A check runs and reopens it.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#821
No description provided.