Recompiler: CRLF and LF checkouts of one commit get the same translated-cache identity #2031
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2031
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2031/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@einfachama on GitHub · 2026-11-25 01:19 UTC · original
einfachama:recompiler/source-id-ignores-crlf→main· +63 −9 · 3 files · 1 commits · merged 2026-11-25 01:53 UTCThe translated cache's identity (
XCL_TRANSLATOR_SOURCE_ID,XCL_PER_LANE_SOURCE_IDand, since #1947,XCL_DIRECT_DXIL_SOURCE_ID, all frombuild.rs) hashes the translators' source files as bytes, line endings included. rustc reads CRLF and LF the same, but a Windows checkout withcore.autocrlf=truehas CRLF and one without it (or a Linux one) has LF. So the same commit builds with different identities, and none finds the others' translations. The same goes for a tree where one file was rewritten with LF by an editor: here a build had one translator file in LF and the rest in CRLF. A later build of the same commit plus a change outside the translator came out with another identity. A check withxcl shaders <pack> --precompile --only cson that build then found none of the translations of my retail title's 2 689 compute programs and made all of them again under the new identity. That took 20 s here, because every DXC result came from the DXIL cache, which is keyed by the HLSL text; driver blobs, keyed by the DXIL, would still have applied. In a title run each program would have been translated again at its first use. I rebuilt that binary with the old line endings instead of running the title on it.build.rsnow hashes each source with every CRLF taken as LF, for all three source lists (the translator's, the per-lane form's and the direct DXIL translator's), so CRLF and LF checkouts of one commit get the same identity.This changes identities once, for CRLF checkouts only. A build from a CRLF checkout gets the identity an LF checkout of the same commit has (and had before); its earlier translations stay on disk under the old identity and are made again once. LF checkouts keep their identity.
What is in it
crates/xcl/src/source_hash.rs(new):add(the FNV-1a stepbuild.rshad) andadd_source, which skips the CR of each CRLF. Two unit tests.build.rsincludes the file with#[path]; the crate compiles it only for its tests (#[cfg(test)] mod source_hashinlib.rs).crates/xcl/build.rs: the translator, per-lane and direct DXIL sources go throughadd_source(paths and fixed strings stay onadd); the localaddis gone.Tested
core.autocrlf=true(CRLF). Debug for the tests, release for the smoke runs.cargo test --workspace -- --test-threads=4atda8c047, the same tree as the head8c1faf1(only the commit message differs), onmain99e4743: 1101 passed, 0 failed, 46 ignored, on the first run. SKIPPED: 19 "no wave64" (thelower/lower_dxilwave64 cases,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware), 3 per-lane f16 / f32 conversion cases refused by the per-lane form,heap_window_out_of_memory_falls_back_to_the_switch_form, andpso_measurement_compiles_an_exact_synthetic_record(no Developer Mode).cargo test -p xcl --lib source_hashatda8c047(same tree): 2 passed. Withadd_sourcemade to hash the bytes as they are (asbuild.rsdid), both fail.build.rs's hash recomputed outside the build for one commit. Before the change, the three line-ending states give three source ids: all LF, all CRLF (anautocrlfcheckout), and all CRLF butrecomp/mod.rsin LF. Two release builds of one local commit (notmain) carry its CRLF id and its mixed id (found in the binaries). For the head's sources (translator / per-lane / direct DXIL), LF gives99925f3f5611513f/3f9230b8f3ee81f0/3136abeaa4427e59and CRLF5819f3be6fcb959f/9e05c7d1e5eb9c90/fb156622b4673e1f. From this CRLF checkout, the release build ofmain99e4743carries the three CRLF ids, and the release builds ofda8c047and8c1faf1the three LF ids and none of the CRLF ones.Regression run
My retail title at its first menu, 60 s, both runs from the same restored shader caches with 49.4 and 49.5 GB of free system commit. Neither build had translations of its own identity in them, so both translated at start (the DXC cache, keyed by the HLSL, was the same).
Not tested
autocrlfafter the change (by construction its id is unchanged: LF text hashes as before, checked in the unit test).AI use
build.rs, wrote the change, the tests and this description, and ran the tests and the smoke runs. Claude Fable 5.2 (in the Claude app) suggested turning it into a fix and reviews the text. I checked it before posting.🤖 Generated with Claude Code
@raylitebull on GitHub · 2026-11-25 01:21 UTC · original
Heads-up:
#1947just merged intomainand updatedcrates/xcl/build.rswithXCL_DIRECT_DXIL_SOURCE_ID(which hashessrc/gpu/dxilfiles as raw bytes too). Please rebase#2031ontomainsosource_hash.rscovers all three source-ID hashes uniformly (XCL_TRANSLATOR_SOURCE_ID,XCL_PER_LANE_SOURCE_ID, andXCL_DIRECT_DXIL_SOURCE_ID) and letBuild and testrun cleanly.@einfachama on GitHub · 2026-11-25 01:37 UTC · original
Rebased onto
main99e4743(new head8c1faf1). Since6567c5f, #1947 added a third source list tobuild.rs, the direct DXIL translator's files forXCL_DIRECT_DXIL_SOURCE_ID, next to theaddthis PR replaces. That was the only conflict. I kept #1947'sdirect_sourcesand moved its file contents toadd_sourceas well, so all three identities ignore line endings; paths and fixed strings are still hashed withadd. The description has the new suite numbers (1101 passed, 0 failed, 46 ignored), the identity check for all three ids, and both smoke blocks (main99e47431 512 frames,8c1faf11 510).AI use: Claude Code (Claude Opus 5.5) did the rebase, resolved the conflict, reran the checks and wrote this comment. I checked it before posting.
@raylitebull on GitHub · 2026-11-25 01:39 UTC · original
Diff audit passed on rebased head
8c1faf1(source_hash::{add, add_source}stripping CR fromuniformly acrossXCL_TRANSLATOR_SOURCE_ID,XCL_PER_LANE_SOURCE_ID, and#1947'sXCL_DIRECT_DXIL_SOURCE_ID, plus unit tests). CI has been approved.Remaining before merge:
Build and test (Windows, no GPU)completion plus one independent reviewer verification pass (no GPU path touched, though our merge gate checks dual-vendor/independent verification).@WebIdentity1 on GitHub · 2026-11-25 01:40 UTC · original · edited 2026-11-25 01:41 UTC
Independent native Windows identity verification completed on exact head
8c1faf1dc35388941a52cb8b8ab768f2637f3560.Tested — Windows 10 Home 19045, Ryzen 7 7800X3D, Rust/Cargo 1.98.1 MSVC, dev profile. No GPU used. A dependency-free Cargo probe used the unchanged build.rs and source_hash.rs, plus the actual source files in all three hashed lists from this revision (not placeholder text). Its binary prints the three compiled-in environment values.
Eight isolated builds used
cargo build --offline --target x86_64-pc-windows-msvc, then ran the probe. All eight builds and eight executions exited 0:99925f3f5611513f,3f9230b8f3ee81f0,3136abeaa4427e59.99e474352fbaa0d94b318e1932dcf7939824f471build script with the same LF inputs produced those same IDs. With CRLF it produced5819f3be6fcb959f,9e05c7d1e5eb9c90,fb156622b4673e1f: all three differ, reproducing the old behavior.emit.rs,recomp/lower.rs, ordxil/kernel.rsin separate LF fixtures changed only the expected translator, per-lane or direct ID respectively. Source changes still invalidate the appropriate identity.source_hash.rsunit tests compiled withrustc --test src/source_hash.rsand passed 2/0/0, zero skips, including lone-CR/text-change controls. All 368 fixture-file SHA256 hashes matched before/after.Not tested — Full XCL workspace build/tests, incremental file-add/delete behavior (#2033), GPU, translated-cache I/O/hit counts, retail smoke or gameplay. This verifies build-script identities and the hashing helper; it does not replace runtime tests. No repository source changes or new PR.
AI use — Codex (GPT-6) prepared the isolated fixtures, ran native builds, verified all identities/change controls/manifests, and wrote this report.