Repository navigation
Recompiler: CRLF and LF checkouts of one commit get the same translated-cache identity - #2031
Conversation
|
Heads-up: |
…ed-cache identity build.rs hashed the translators' sources as bytes for XCL_TRANSLATOR_SOURCE_ID (and XCL_PER_LANE_SOURCE_ID, XCL_DIRECT_DXIL_SOURCE_ID), line endings included. rustc reads CRLF and LF the same, but a Windows checkout with core.autocrlf has CRLF and one without it has LF, so one commit built with different identities and none found the others' translations. A tree where one translator file had been rewritten with LF got a third: a later build of the same commit plus a change outside the translator found none of the 2 689 translations a precompile had left for a retail pack's compute programs, and made them all again under a new identity. The sources are now hashed with each CRLF taken as LF (source_hash.rs, which build.rs includes with #[path] and the crate compiles for its tests). LF checkouts keep their identity; CRLF ones change once, to the LF one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8c9378d to
8c1faf1
Compare
|
Rebased onto 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. |
|
Diff audit passed on rebased head Remaining before merge: |
|
Independent native Windows identity verification completed on exact head 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
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. |
The 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