Recompiler: the build script reads its sources from the checkout being built #2411

Open
github-bot wants to merge 1 commit from github-bot/gh-2411 into main AGit
Owner

@⁠Anon64 on GitHub · 2026-11-25 18:07 UTC · original
Anon64:build/manifest-dir-at-run → main · +5 −1 · 1 files · 1 commits · open

crates/xcl/build.rs took the crate's directory from env!("CARGO_MANIFEST_DIR"), which is fixed when the build script is compiled. Cargo reuses a compiled build script in another checkout that shares the target directory: the script's dep-info lists only workspace-relative paths, so a git worktree with the same build.rs gets the same script binary. That script then reads and hashes the first checkout's translator sources. While both checkouts exist, XCL_TRANSLATOR_SOURCE_ID is made from the wrong tree. Once the first one is removed, every build of the other that reruns the script fails:

thread 'main' panicked at crates\xcl\build.rs:70:64:
read shader translator source: Os { code: 3, kind: NotFound, message: "The system cannot find the path specified." }

The script now reads CARGO_MANIFEST_DIR when it runs, as Cargo documents for build scripts.

What is in it

  • crates/xcl/build.rs: root comes from std::env::var_os("CARGO_MANIFEST_DIR") at run time instead of env!. Nothing else changes.

Tested

  • RTX 3060 12 GB (driver 581.80), Windows 11 26200, Rust 1.100.0, DXC 1.8.2502.11, debug and release.
  • Reproduction on main 68a284a: worktree A builds -p xcl with CARGO_TARGET_DIR set to checkout B's target. Worktree A is moved away (git worktree move). In B, touch crates/xcl/src/gpu/dxbc.rs and cargo build -p xcl fail with the panic above. The script binary in target/debug/build/xcl/<hash>/out/ contains worktree A's path.
  • On this branch, the same steps build; the compiled script contains no checkout path.
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1289 passed, 1 failed, 46 ignored. The failure is gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, which fails on main 68a284a too (1219 passed, 1 failed, 26 ignored in the lib tests on both) and was fixed on main by #2420 after this run.
  • SKIPPED on this adapter (no wave64, no heap windows): 16 GPU tests, among them f16_programs_on_the_gpu, f32_programs_on_the_gpu, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu and heap_window_out_of_memory_falls_back_to_the_switch_form.
  • In one earlier full run on this branch, the lib test binary ended with STATUS_ACCESS_VIOLATION after that failure. It did not recur in two lib-only reruns or the full run above, and does not involve the build script.

Regression run

scripts/smoke.ps1 of a retail title, 60 s each, main and this branch's head:

xcl-smoke v1
commit: 68a284a596bd558b6bd9db6eedda6d6aa178c360
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1442 (PresentX 1442)
presents per 2 s (last 3): 47 8 0
device removals: 0
crashes: 0
peak commit: 20951 MB
xcl-smoke v1
commit: c9dccc9a1e64b58e3b6accf03727efc4aed9fe43
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1514 (PresentX 1514)
presents per 2 s (last 3): 52 12 2
device removals: 0
crashes: 0
peak commit: 21327 MB

Not tested

  • AMD; Linux / Wine (a gnu target).
  • cargo with --remap-path-prefix or a vendored build.

AI use

  • Claude Code (Claude Opus 5.5) found the failure, made the change, ran the reproduction, tests and smoke runs, and wrote this description.

🤖 Generated with Claude Code

**@⁠Anon64** on GitHub · 2026-11-25 18:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/2411) `Anon64:build/manifest-dir-at-run` → `main` · +5 −1 · 1 files · 1 commits · open `crates/xcl/build.rs` took the crate's directory from `env!("CARGO_MANIFEST_DIR")`, which is fixed when the build script is compiled. Cargo reuses a compiled build script in another checkout that shares the target directory: the script's dep-info lists only workspace-relative paths, so a git worktree with the same `build.rs` gets the same script binary. That script then reads and hashes the first checkout's translator sources. While both checkouts exist, `XCL_TRANSLATOR_SOURCE_ID` is made from the wrong tree. Once the first one is removed, every build of the other that reruns the script fails: ``` thread 'main' panicked at crates\xcl\build.rs:70:64: read shader translator source: Os { code: 3, kind: NotFound, message: "The system cannot find the path specified." } ``` The script now reads `CARGO_MANIFEST_DIR` when it runs, as Cargo documents for build scripts. **What is in it** - `crates/xcl/build.rs`: `root` comes from `std::env::var_os("CARGO_MANIFEST_DIR")` at run time instead of `env!`. Nothing else changes. **Tested** - RTX 3060 12 GB (driver 581.80), Windows 11 26200, Rust 1.100.0, DXC 1.8.2502.11, debug and release. - Reproduction on `main` `68a284a`: worktree A builds `-p xcl` with `CARGO_TARGET_DIR` set to checkout B's target. Worktree A is moved away (`git worktree move`). In B, `touch crates/xcl/src/gpu/dxbc.rs` and `cargo build -p xcl` fail with the panic above. The script binary in `target/debug/build/xcl/<hash>/out/` contains worktree A's path. - On this branch, the same steps build; the compiled script contains no checkout path. - `cargo test --workspace --no-fail-fast -- --test-threads=4`: 1289 passed, 1 failed, 46 ignored. The failure is `gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier`, which fails on `main` `68a284a` too (1219 passed, 1 failed, 26 ignored in the lib tests on both) and was fixed on `main` by #2420 after this run. - SKIPPED on this adapter (no wave64, no heap windows): 16 GPU tests, among them `f16_programs_on_the_gpu`, `f32_programs_on_the_gpu`, `the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu` and `heap_window_out_of_memory_falls_back_to_the_switch_form`. - In one earlier full run on this branch, the lib test binary ended with `STATUS_ACCESS_VIOLATION` after that failure. It did not recur in two lib-only reruns or the full run above, and does not involve the build script. **Regression run** `scripts/smoke.ps1` of a retail title, 60 s each, `main` and this branch's head: ``` xcl-smoke v1 commit: 68a284a596bd558b6bd9db6eedda6d6aa178c360 gpu: NVIDIA GeForce RTX 3060 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1442 (PresentX 1442) presents per 2 s (last 3): 47 8 0 device removals: 0 crashes: 0 peak commit: 20951 MB ``` ``` xcl-smoke v1 commit: c9dccc9a1e64b58e3b6accf03727efc4aed9fe43 gpu: NVIDIA GeForce RTX 3060 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1514 (PresentX 1514) presents per 2 s (last 3): 52 12 2 device removals: 0 crashes: 0 peak commit: 21327 MB ``` **Not tested** - AMD; Linux / Wine (a `gnu` target). - `cargo` with `--remap-path-prefix` or a vendored build. **AI use** - Claude Code (Claude Opus 5.5) found the failure, made the change, ran the reproduction, tests and smoke runs, and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
build.rs took the crate's directory from env!("CARGO_MANIFEST_DIR"), which
is fixed when the script is compiled. Cargo reuses a compiled build script
in another checkout that shares the target directory: its dep-info records
only workspace-relative paths, so a git worktree with the same sources
gets the same script. That script then hashes (and reads) the first
checkout's files. Once that checkout is removed, every build of the other
one fails with "read shader translator source: ... cannot find the path
specified", and while both exist the translator source id is made from
the wrong tree.

The script now reads CARGO_MANIFEST_DIR when it runs, as Cargo documents
for build scripts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:30:11 +00:00
Author
Owner

@⁠emirduran707 on GitHub · 2026-11-25 18:22 UTC · original

Independent AMD RDNA4 (native wave64) test report on exact head c9dccc9a1e64b58e3b6accf03727efc4aed9fe43 (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • Built and tested from a separate git worktree (D:\xcl-verify) sharing CARGO_TARGET_DIR (D:\xcl\target) with the main checkout: cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1287 passed, 3 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record).
    • The 3 failures are pre-existing on unmodified main 68a284a: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722) and fuzz_validate_and_gpu_3 (seed 1599) on this GPU, plus gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier (from 50a9fde / #2074).

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: c9dccc9a1e64b58e3b6accf03727efc4aed9fe43
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1612 (PresentX 1612)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13920 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer; Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.
**@⁠emirduran707** on GitHub · 2026-11-25 18:22 UTC · [original](https://github.com/xcl-dev/xcl/pull/2411#issuecomment-7170815071) Independent AMD RDNA4 (native wave64) test report on exact head `c9dccc9a1e64b58e3b6accf03727efc4aed9fe43` (clean detached checkout, no local changes). **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2602.17; tests debug, smoke release. - Built and tested from a separate git worktree (`D:\xcl-verify`) sharing `CARGO_TARGET_DIR` (`D:\xcl\target`) with the main checkout: `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`: **1287 passed, 3 failed, 46 ignored; 8 SKIPPED** (6 in `lower_dxil::tests::{f16,f32}_programs_on_the_gpu` refused by per-lane form; `heap_window_out_of_memory_falls_back_to_the_switch_form`; `pso_measurement_compiles_an_exact_synthetic_record`). - The 3 failures are pre-existing on unmodified `main` `68a284a`: `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` (seed 722) and `fuzz_validate_and_gpu_3` (seed 1599) on this GPU, plus `gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier` (from `50a9fde` / #2074). **Regression run** (60 s retail-title smoke, `XCL_NETWORK=0`, release) ``` xcl-smoke v1 commit: c9dccc9a1e64b58e3b6accf03727efc4aed9fe43 gpu: AMD Radeon RX 9060 XT title: 21222967 seconds: 60 exit: 0x0 frames shown: 1612 (PresentX 1612) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 13920 MB ``` (Matched `main` `68a284a` baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.) **Not tested** - D3D12 debug layer; Intel GPUs. **AI use** - Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2411/head:github-bot/gh-2411'
git switch 'github-bot/gh-2411'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2411'
git switch 'github-bot/gh-2411'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2411'
git switch 'github-bot/gh-2411'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2411'
git switch 'main'
git merge --squash 'github-bot/gh-2411'
git switch 'main'
git merge --ff-only 'github-bot/gh-2411'
git switch 'main'
git merge 'github-bot/gh-2411'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.