Repository navigation
Conversation
build.rs took the source root from env!("CARGO_MANIFEST_DIR"), fixed when the
script is compiled. Worktrees that share a CARGO_TARGET_DIR share that binary
(cargo names it by the package's path relative to its workspace), so the
XCL_*_SOURCE_ID values hashed the first tree's sources, and a cached
translation of one tree could load in another. Read CARGO_MANIFEST_DIR at run
time instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent Windows check of all three source IDs on I compiled each revision’s
All four controls passed. The PR executable still produced the original IDs when invoked against the first tree while the markers were present in the second. This covers the build script’s source-root selection, all three hash families, and the test-file exclusion. Cargo’s decision to rerun the script, GPU tests, and retail smoke were outside this probe. OpenAI Codex assisted with the probe and report. The exact model identifier was unavailable in this session. |
|
@ettehn thank you. Running the build script against a second tree is a cleaner check than my Cargo repro, and it covers all three ids plus the test-file exclusion. It is under Tested by others now. Cargo rerunning the script is covered by the repro in Tested, and the title run by Regression run. AI use: Claude Code, Claude Opus 5.5 wrote this reply. |
|
I found a concrete translated-cache identity mismatch in one archived retail replay built before this fix. The release build based on I recomputed the source IDs from the archived source revision and patch, then derived the translated-cache namespace using the recorded DXC toolchain and direct-compute mode. The archived executable and its cache growth show the two identities below.
The runtime added 220 files to the second namespace and zero to the expected one. This establishes a mismatched cache identity in that replay. Individual shader-cache hits and rendering impact remain unresolved. As a control, I checked a different historical pair that also used a shared Cargo target. The e877812 base and the same tree plus the b59d263 texture-placement change both embedded the expected HLSL, per-lane and direct DXIL IDs, and both used the expected namespace AI use — OpenAI Codex (GPT-6 family) audited preserved source patches, executables and cache metadata and prepared this report. |
|
Independent Windows 11 / Cargo 1.100 & RTX 4060 (8 GB) release verification of PR #2789 at Setup
End-to-end Cargo 1.100 shared-
|
| Revision & step | build-script-build fresh |
Cargo status | XCL_TRANSLATOR_SOURCE_ID |
XCL_PER_LANE_SOURCE_ID |
XCL_DIRECT_DXIL_SOURCE_ID |
|---|---|---|---|---|---|
Base b49be183 — Tree A |
False |
Dirty (build.rs) |
699c1853e347d9bb |
39cdba116441e869 |
f0d04875e42b84d5 |
Base b49be183 — Tree B (edited) |
True |
Dirty (dxbc.rs) |
699c1853e347d9bb (stale) |
39cdba116441e869 (stale) |
f0d04875e42b84d5 (stale) |
PR #2789 ed13531a — Tree A |
False |
Dirty (build.rs) |
699c1853e347d9bb |
39cdba116441e869 |
f0d04875e42b84d5 |
PR #2789 ed13531a — Tree B (edited) |
True |
Dirty (dxbc.rs) |
a053e0d91b599a57 |
ada8bcf9eadbcc95 |
456b729fc3a9dc5d |
PR #2789 ed13531a — back to Tree A (older mtime) |
True |
Fresh (see note) |
a053e0d91b599a57 |
ada8bcf9eadbcc95 |
456b729fc3a9dc5d |
- Bug reproduced & fixed: On
b49be183, reusingTree A's build-script binary inTree Bkept all threeXCL_*_SOURCE_IDvalues frozen atTree A's hashes despiteTree B's edited translator sources. Oned13531a,Tree Akeeps exact hash parity withb49be183, and reusing the same compiled binary inTree Brecomputes all three IDs fromTree B. - Observed Cargo shared-
CARGO_TARGET_DIRfingerprint caveat (FYI, outsideenv!fix): Immediately switching back to untouchedTree A(whose file mtimes were older thanTree B's build) under the sameCARGO_TARGET_DIRcaused Cargo1.100.0to reportFresh xcl v0.1.0on the sharedbuild/xcl/f34613a8fd345a29fingerprint, skip re-runningbuild.rs, and replayTree B's cached IDs intoTree A. A quick empirical check addingcargo:rerun-if-env-changed=CARGO_MANIFEST_DIRdid not change this (Cargo checks its own inherited process environment rather than the per-crateCARGO_MANIFEST_DIRit injects into the build script). That remaining case is a Cargo-level shared-target-dir mtime/fingerprint limitation when switching back to an older-mtime worktree without triggering a rebuild, not a flaw in this PR's runtimeCARGO_MANIFEST_DIRread.
Targeted release unit tests & build (ed13531a)
cargo test --release -p xcl --lib source_hash: 2 passed, 0 failed, 0 ignored (0.00 s, exit0).cargo build --release -p xcl --bin xcl: clean release build (exit 0).
Paired 60 s RTX 4060 smoke (b49be183 vs ed13531a)
Both runs held steady 60/2 s pacing with 0 device removals and 0 crashes (ed13531a telemetry: 6,175 MB peak / 6,114 MB end local VRAM, 4,650 MB end non-local VRAM).
Base origin/main (b49be183):
xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1518 (PresentX 1518)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14018 MB
PR #2789 head (ed13531a):
xcl-smoke v1
commit: ed13531a2869626a89d0b4b8755fa15c33b0d928
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1557 (PresentX 1557)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13969 MB
Limits of coverage
- Tested only on native Windows 11 with
rustc 1.100.0/cargo 1.100.0MSVC and a single NVIDIA RTX 4060 (8 GB); no Linux/GNU toolchain or cross-compilation test on this host. - Full workspace test suite was not re-run (only
source_hash, the live Cargo two-worktree repro, release build, and 60 s retail smoke).
AI use
Ran the Cargo two-worktree repro, source_hash unit tests, release build, and paired 60 s smoke runs with assistance from Google Antigravity (Gemini 4 Neon); all hashes, Cargo -vv statuses, test counts, and smoke blocks were extracted directly from cargo, xcl.log, and scripts/smoke.ps1 outputs.
|
Two contributors checked independently and found that this PR makes the same change as #2411: #1607, group D130. They suggest keeping #2411. If you agree, closing this PR or joining the other one would save the maintainers a review. If the two differ in a way the checks missed, a note in #1607 helps. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table. |
|
Closing this in favour of #2411, which was opened first and makes the same change: AI use: Claude Code, Claude Opus 5.5 compared the two diffs and wrote this comment. |
…v#2705 (manifest-dir runtime read, FSPX precompile, workers_for_commit)
crates/xcl/build.rshashes the translator sources intoXCL_TRANSLATOR_SOURCE_ID,XCL_PER_LANE_SOURCE_IDandXCL_DIRECT_DXIL_SOURCE_ID, which key the translation cache. It took their root fromenv!("CARGO_MANIFEST_DIR"), the path of the tree that compiled the build script. Cargo names a path package's artifacts by its path relative to the workspace, so worktrees of the repo that share aCARGO_TARGET_DIRshare one build-script binary. When the binary was compiled in tree A and then reran for tree B, it hashed A's sources: B's code got A's ids, and B could load A's cached translations. The script now readsCARGO_MANIFEST_DIRat run time, which Cargo sets to the package being built. Thererun-if-changedpaths were already relative to the package. Found during frame-rate A/B runs, where two worktrees on one target dir shared a DXIL cache.What is in it
Build: hash the translator sources of the tree being built:crates/xcl/build.rsreadsCARGO_MANIFEST_DIRwithstd::env::var_osinstead ofenv!(3 comment lines, 2 changed).Tested
Repro,
cargo check -p xcl --lib: two worktrees of mainb49be18, where B adds one comment line tosrc/gpu/dxil/kernel.rs. A is checked first in a fresh shared target dir, then B; B's own target dir is the reference.XCL_DIRECT_DXIL_SOURCE_IDfrom the build script's output:f0d04875e42b84d5f0d04875e42b84d5gpu/dxil/kernel.rs, shared target dir (Cargo reruns the script)f0d04875e42b84d5(A's)869ae4235dcd0787869ae4235dcd0787869ae4235dcd0787Windows suite at
ed13531, debug,cargo test --workspace --no-fail-fast -- --test-threads=4: 1,431 passed, 4 failed, 47 ignored, 25 SKIPPED notices (21 no wave64, 3 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 refusals, 1 no heap windows). The threee2efailures were a missingxcl_testtitle.exe(nocargo build --workspacefirst); after the build all three passed.hle::d3d12x::cpu_writes::tests::writes_land_after_the_queuefailed once withleft: [7, 9] right: [7, 9]and passed 3 of 3 on rerun: it waits only for the first word to read 7 before comparing both, so the second word can still be in flight. This change does not touch it.Windows 11 Pro 26200, RTX 5070 Ti (NVIDIA 610.74), rustc 1.99.0, DXC 1.9.2609.
Tested by others
build.rscompiled once withrustcand run withCARGO_MANIFEST_DIRpointing at a second tree, as when Cargo reuses the build-script binary. With this PR, a comment marker inrecomp/emit.rs,recomp/ssa.rsordxil/kernel.rsof the second tree changed onlyXCL_TRANSLATOR_SOURCE_ID,XCL_PER_LANE_SOURCE_IDorXCL_DIRECT_DXIL_SOURCE_IDrespectively, and one indxil/ops_tests.rschanged none; main's binary changed no id for any marker; run against the first tree, the PR's binary kept the first tree's ids. Not covered by that probe: whether Cargo reruns the script, GPU tests, a title run.Regression run
Title smoke pair, 60 s each, RTX 5070 Ti, NVIDIA 610.74, release builds, beside other jobs on the same machine. Because this change gives every
XCL_*_SOURCE_IDa new value, the PR's build starts with an empty translation cache, so one untimed 60 s run of the PR's build came first, then the usual warm-up run of main, then the pair. Frames 1,250 against 1,281 (98 %), peak commit 23,013 against 20,842 MB (110 %), no crash or device removal.main,
b49be18:This PR,
ed13531:An earlier pair without the PR warm-up failed the commit check: 20,517 against 14,280 MB (144 %), frames 1,394 against 1,549. Its logs show the two sides took different paths, not a slower PR: main stayed on a static screen after about 20 s (no file reads, flat commit), while the PR side went on loading the world (4,688 DirectStorage requests in its last 2 s, 19,215 shader creations against 8,750). Compute pipeline time was similar (1,184 ms against 1,465 ms).
Not tested
xclasFreshand rebuilds nothing, so B's build is A's code and ids (seen in the same repro, before B was touched). That comes from Cargo's mtime check, which no build script can change; a separateCARGO_TARGET_DIRper worktree avoids both.AI use
🤖 Generated with Claude Code