Skip to content

Recompiler: CRLF and LF checkouts of one commit get the same translated-cache identity - #2031

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
einfachama:recompiler/source-id-ignores-crlf
Nov 25, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
einfachama:recompiler/source-id-ignores-crlf

Conversation

@einfachama

@einfachama einfachama commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

The translated cache's identity (XCL_TRANSLATOR_SOURCE_ID, XCL_PER_LANE_SOURCE_ID and, since #1947, XCL_DIRECT_DXIL_SOURCE_ID, all from build.rs) hashes the translators' source files as bytes, line endings included. rustc reads CRLF and LF the same, but a Windows checkout with core.autocrlf=true has 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 with xcl shaders <pack> --precompile --only cs on 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.rs now 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 step build.rs had) and add_source, which skips the CR of each CRLF. Two unit tests. build.rs includes the file with #[path]; the crate compiles it only for its tests (#[cfg(test)] mod source_hash in lib.rs).
  • crates/xcl/build.rs: the translator, per-lane and direct DXIL sources go through add_source (paths and fixed strings stay on add); the local add is gone.

Tested

  • NVIDIA GeForce RTX 4060 8 GB (Ada, 32-lane waves), driver 621.24; Ryzen 7 5800X; 32 GB RAM; Windows 11 Pro 26300; Rust 1.100.0 MSVC; DXC 1.9.2602.17; a checkout with core.autocrlf=true (CRLF). Debug for the tests, release for the smoke runs.
  • cargo test --workspace -- --test-threads=4 at da8c047, the same tree as the head 8c1faf1 (only the commit message differs), on main 99e4743: 1101 passed, 0 failed, 46 ignored, on the first run. SKIPPED: 19 "no wave64" (the lower / lower_dxil wave64 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, and pso_measurement_compiles_an_exact_synthetic_record (no Developer Mode).
  • cargo test -p xcl --lib source_hash at da8c047 (same tree): 2 passed. With add_source made to hash the bytes as they are (as build.rs did), both fail.
  • Identities, by 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 (an autocrlf checkout), and all CRLF but recomp/mod.rs in LF. Two release builds of one local commit (not main) carry its CRLF id and its mixed id (found in the binaries). For the head's sources (translator / per-lane / direct DXIL), LF gives 99925f3f5611513f / 3f9230b8f3ee81f0 / 3136abeaa4427e59 and CRLF 5819f3be6fcb959f / 9e05c7d1e5eb9c90 / fb156622b4673e1f. From this CRLF checkout, the release build of main 99e4743 carries the three CRLF ids, and the release builds of da8c047 and 8c1faf1 the three LF ids and none of the CRLF ones.

Regression run

xcl-smoke v1
commit: 99e474352fbaa0d94b318e1932dcf7939824f471
gpu: NVIDIA GeForce RTX 4060
title: aaf23206
seconds: 60
exit: 0x0
frames shown: 1512 (PresentX 1512)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16168 MB
xcl-smoke v1
commit: 8c1faf1dc35388941a52cb8b8ab768f2637f3560
gpu: NVIDIA GeForce RTX 4060
title: aaf23206
seconds: 60
exit: 0x0
frames shown: 1510 (PresentX 1510)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16296 MB

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

  • A build on Linux or from a checkout without autocrlf after the change (by construction its id is unchanged: LF text hashes as before, checked in the unit test).
  • AMD / Intel GPUs (the change has no GPU path).

AI use

  • Claude Code (Claude Opus 5.5) found this while building a test binary, traced it to 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

Copy link
Copy Markdown
Member

Heads-up: #1947 just merged into main and updated crates/xcl/build.rs with XCL_DIRECT_DXIL_SOURCE_ID (which hashes src/gpu/dxil files as raw bytes too). Please rebase #2031 onto main so source_hash.rs covers all three source-ID hashes uniformly (XCL_TRANSLATOR_SOURCE_ID, XCL_PER_LANE_SOURCE_ID, and XCL_DIRECT_DXIL_SOURCE_ID) and let Build and test run cleanly.

…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>
@einfachama
einfachama force-pushed the recompiler/source-id-ignores-crlf branch from 8c9378d to 8c1faf1 Compare November 25, 2026 01:37
@einfachama

Copy link
Copy Markdown
Contributor Author

Rebased onto main 99e4743 (new head 8c1faf1). Since 6567c5f, #1947 added a third source list to build.rs, the direct DXIL translator's files for XCL_DIRECT_DXIL_SOURCE_ID, next to the add this PR replaces. That was the only conflict. I kept #1947's direct_sources and moved its file contents to add_source as well, so all three identities ignore line endings; paths and fixed strings are still hashed with add. The description has the new suite numbers (1101 passed, 0 failed, 46 ignored), the identity check for all three ids, and both smoke blocks (main 99e4743 1 512 frames, 8c1faf1 1 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

Copy link
Copy Markdown
Member

Diff audit passed on rebased head 8c1faf1 (source_hash::{add, add_source} stripping CR from uniformly across XCL_TRANSLATOR_SOURCE_ID, XCL_PER_LANE_SOURCE_ID, and #1947's XCL_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

WebIdentity1 commented Nov 25, 2026 •

Copy link
Copy Markdown

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:

  • LF, CRLF and alternating-file mixed endings produced identical IDs, in translator / per-lane / direct order: 99925f3f5611513f, 3f9230b8f3ee81f0, 3136abeaa4427e59.
  • The parent 99e474352fbaa0d94b318e1932dcf7939824f471 build script with the same LF inputs produced those same IDs. With CRLF it produced 5819f3be6fcb959f, 9e05c7d1e5eb9c90, fb156622b4673e1f: all three differ, reproducing the old behavior.
  • Appending a comment to emit.rs, recomp/lower.rs, or dxil/kernel.rs in separate LF fixtures changed only the expected translator, per-lane or direct ID respectively. Source changes still invalidate the appropriate identity.
  • The unmodified source_hash.rs unit tests compiled with rustc --test src/source_hash.rs and 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.

@raylitebull
raylitebull merged commit 2a7031a into xcl-dev:main Nov 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants