Skip to content

Fix wrong cached objects after line-shifting edits and response-file changes - #1687

Open
Yaraslaut wants to merge 2 commits into
masterfrom
fix/key-line-structure-and-response-files
Open

Yaraslaut wants to merge 2 commits into
masterfrom
fix/key-line-structure-and-response-files

Conversation

@Yaraslaut

Copy link
Copy Markdown
Member

Two ways the compile cache served an object built from something other than what was asked, both reproduced end to end with the launcher. Builds on #1686.

Changes

  • The key keeps the preprocessed text's line structure.
    • The key hashed -E -P / /EP output, which drops line markers and collapses blank and comment lines. Inserting a comment above a function therefore left the key unchanged, while std::source_location, __builtin_LINE and every -g line table moved.
    • Reproduced: after adding three comment lines the compile was a HIT whose function reported line 2, where a real compile reports 5.
    • The probe now keeps its markers (-E, /E). KeyedPreprocessedText reduces each marker (GNU # N "path" flags, MSVC #line N "path") to its line number and flags, so the key stays portable: Catch2 across two folders still shares 107 of 107.
  • A response file's text is keyed.
    • The driver expands @file itself, so both the object key and the direct-mode manifest key hashed only its name.
    • Reproduced: changing -O0 to -O2 inside the file was answered with the -O0 object.
    • ResponseFileKeyItems keys each file's bytes, with the source root, build tree and dependency cache tokenized.
    • A file is refused, with the reason in the verbose trace, when it cannot be read, names another response file, or carries an output or dependency-file flag.
  • objkey-v9 / manifest-v10.
  • The rule (compile-cache.md, AGENT.md tripwire) and docs/tools/fastcache-cc.md are updated.

Both came out of an audit of the cache for wrong-object paths; the remaining findings are being filed as separate issues.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CnCkwgtUsaSM5HcgB3APNU

Yaraslaut and others added 2 commits October 17, 2026 19:00
…o a line-shifting edit is no longer served the old object

The key hashed `-E -P` / `/EP` output, which drops line markers and collapses blank
and comment lines. So inserting a comment above a function left the hashed text
byte-identical while std::source_location, __builtin_LINE and every -g line table
moved: one key, two different objects, and the edited file was served the object
built before the edit. Reproduced end to end with the launcher: after adding three
comment lines the compile was a HIT whose function reported line 2, where a real
compile reports 5.

The probe now keeps its markers (`-E`, `/E`), and KeyedPreprocessedText reduces each
marker -- GNU's `# N "path" flags` and MSVC's `#line N "path"` -- to its line number
and flags before hashing. Dropping the path keeps the key portable, which is all the
suppression was for: __FILE__ is already expanded in the text, and a name recorded
after preprocessing is root binding's and the prefix maps' to answer. Catch2 across
two folders still shares 107 of 107. objkey-v9 / manifest-v10.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CnCkwgtUsaSM5HcgB3APNU
…g only inside @file stop sharing one object

A driver expands `@file` itself, so the arguments inside it reached neither the object
key nor the direct-mode manifest key -- both hashed the NAME. Reproduced with the
launcher: compiling with `-O0` in the file, then changing it to `-O2`, was answered with
the `-O0` object (a direct-mode HIT; `mov $0x2` where -O2 gives `mov $0x1`).

ResponseFileKeyItems keys each response file's BYTES, with the source root, build tree
and dependency cache replaced by their tokens so checkouts still share; no tokenizer of
the launcher's can disagree with the driver's about bytes. A file that cannot be read,
that names another response file, or that carries an output or dependency-file flag the
launcher must read off the command line keeps the compile uncached, with the reason in
the verbose trace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CnCkwgtUsaSM5HcgB3APNU
@Yaraslaut Yaraslaut added the type/bug Behaves incorrectly against its stated contract label Oct 17, 2026
This was referenced Oct 17, 2026
@github-actions github-actions Bot added the area/launcher apps/fastcache-cc/ - the compiler launcher and its cache key label Oct 17, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/launcher apps/fastcache-cc/ - the compiler launcher and its cache key type/bug Behaves incorrectly against its stated contract

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant