Skip to content

Commit 67bccc3

Browse files
16bit-ykikoclaude
andcommitted
fix: restore preamble-only PCH hash to fix shared preamble test
The previous change hashed compile arguments (including the source file path) into the preamble hash, causing files with identical preambles but different paths to generate separate PCH files. Revert to hashing only the preamble text, matching the behavior before this refactor. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f93ff4b commit 67bccc3

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/server/compiler.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -445,14 +445,13 @@ et::task<bool> Compiler::ensure_pch(Session& session,
445445
co_return true;
446446
}
447447

448-
// Hash both the preamble text AND compile arguments so that different
449-
// compilation contexts (e.g. after switchContext) produce different PCHs.
448+
// Hash only the preamble text. This allows files with identical preambles
449+
// to share the same PCH file (content-addressed). Compile flags are NOT
450+
// included because preamble content is what determines the PCH output.
451+
// TODO: consider hashing flags that affect preprocessing (e.g. -D, -I)
452+
// for correctness when files have same preamble text but different flags.
450453
auto preamble_text = llvm::StringRef(text).substr(0, bound);
451454
auto preamble_hash = llvm::xxh3_64bits(preamble_text);
452-
for(auto& arg: arguments) {
453-
preamble_hash ^= llvm::xxh3_64bits(arg);
454-
}
455-
preamble_hash ^= llvm::xxh3_64bits(directory);
456455

457456
// Deterministic content-addressed PCH path.
458457
auto pch_path = path::join(workspace.config.cache_dir,

0 commit comments

Comments
 (0)