Skip to content

stale_build: follow includes through the CMake include directories (STALE-BUILD-INCLUDE-DIRS) - #620

Merged
QemmHD merged 2 commits into
ProjectLeonida:mainfrom
TuroYT:fix/stale-build-include-dirs
Nov 24, 2026
Merged

QemmHD merged 2 commits into
ProjectLeonida:mainfrom
TuroYT:fix/stale-build-include-dirs

Conversation

@TuroYT

@TuroYT TuroYT commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: STALE-BUILD-INCLUDE-DIRS (#14 (comment))

What was wrong

tools/stale_build.py, program_sources(): a quoted #include "..." was resolved only relative to the including
file's directory (os.path.join(os.path.dirname(path), inc)). The build also finds headers through the include
directories of runtime/CMakeLists.txt.

Reproduction on main (d7576d5):

python3 -I -c "import sys; sys.path.insert(0,'tools'); import stale_build as s; print(s.program_sources('.', 'pe_loader_test'))"
['runtime/test/pe_loader_test.cpp']

runtime/test/pe_loader_test.cpp line 25 includes "pe_loader.h", which is runtime/src/pe_loader.h. The
pe_loader_test target gets src and shims at runtime/CMakeLists.txt lines 657-660. Editing pe_loader.h did
not make the built program stale, so make_game.py and tools/first_light.py could reuse an old binary, against the
module docstring.

What changed

  • tools/stale_build.py: a new _resolve_include() looks an include up next to the including file first (unchanged),
    then in _INCLUDE_DIRS. The constant lists runtime/src, runtime/shims, then the xtaskqueue directories
    (runtime/shims/xtaskqueue, third_party/xtaskqueue/Source/Task, Source/Common, Include) that
    runtime/CMakeLists.txt gives its test programs at lines 90-92, 1206-1210 and 1227-1229. Every copy found in those
    directories counts as a source, not only the first: CMake orders the directories per target, so a header present in
    two of them could be the copy a given program compiles. No header name exists in two of them today. An include
    found nowhere is skipped, as before. The seen set still stops cycles.
  • tests/test_stale_build_include_dirs.py (new): 11 tests: ten on temporary trees and one smoke test on the real tree.
    It does not touch tests/test_stale_build.py, which belongs to tests: cover tools/stale_build.py (TEST-STALE-BUILD) #611.

Corpus numbers (every runtime/test/*.cpp)

Quoted includes counted with the same regex as the tool.

before after
files 240 240
quoted includes 665 665
resolve next to the including file 589 589
resolve through the new directories 0 76
resolve nowhere 76 0

The 76 that were not next to their file: 53 are in runtime/src or runtime/shims, and 23 are xtaskqueue headers
(TaskQueueImpl.h, TaskQueueP.h, XTaskQueue.h, XTaskQueuePriv.h, pch.h, referenced_ptr.h). All 665 now
resolve, and none is a system or generated header.

Note: 368 includes have no / in their name, but most of those sit next to their file. The 76 is the count that
matters here.

Tested

python3 -m compileall -q tools tests                          # ok
python3 -I tests/test_stale_build_include_dirs.py             # Ran 11 tests ... OK
python3 -I tests/test_text_write_line_endings.py              # Ran 3 tests ... OK
python3 -I scripts/check_no_game_data.py tools/stale_build.py tests/test_stale_build_include_dirs.py   # rc 0
python3 -I make_game.py --help                                # rc 0
python3 -I tests/test_first_light_stale_mesh.py               # OK
python3 -I tests/test_make_game_dry_run.py                    # OK

Against the unfixed tool (tools/stale_build.py taken from main, test file unchanged): 7 of 11 tests fail, including
the header-in-runtime/src case, the exe-marked-stale case, the xtaskqueue cycle and the real-tree smoke test. The
four that pass on both (next-to-program wins, unresolved header skipped, relative resolution unchanged, missing
program) pin behaviour that must not change.

PR #611 (tests/test_stale_build.py, 15 tests) copied into the worktree and run against the fixed tool: 15 tests OK.
The copy was deleted afterwards.

Review follow-up

Dezmonius checked this on Windows 10 and pointed out that the first revision took the first match in a fixed order
(src before shims), which can differ from one CMake target's order: with target_include_directories(prog PRIVATE shims src) the compiler takes the shims copy, and editing only that copy left newer_sources() empty. The second
commit follows every copy instead, and test_editing_only_the_shims_copy_marks_the_exe_stale covers that case.

Not tested

  • Windows paths (the os.path.join and normpath handling was not exercised with backslashes).
  • An end-to-end make_game.py run that rebuilds a stale program. Only --help and the existing dry-run and
    first_light tests were run.
  • The xtaskqueue directories are added for every program, not only the ones CMake gives them. That can only mark a
    program stale that did not need it (an extra rebuild), never miss one.

AI-assisted (Claude Code).

…TALE-BUILD-INCLUDE-DIRS)

A quoted #include was resolved only next to the including file, so a header the build finds through
target_include_directories (runtime/src, runtime/shims, the xtaskqueue directories) was never a source of the
program and editing it did not mark the built program stale. Measured over runtime/test/*.cpp: 76 of 665 quoted
includes are not next to their file; all 665 now resolve.
@Dezmonius

Copy link
Copy Markdown
Contributor

Independent Windows 10 check of a92dd6a against 21625bc, CPython 3.14.7. All 10 include-directory tests passed on the PR. Six fail when the same tests run against the old implementation, including the pe_loader.h smoke check.

A scope issue with the docstring: the fallback is a fixed directory order, and can differ from an individual CMake target. I verified this with a tiny CMake/MSVC fixture:

add_executable(prog test/prog.cpp)
target_include_directories(prog PRIVATE shims src)

test/prog.cpp includes "selection.h", present in both directories. MSVC's include trace shows shims/selection.h. The PR records src/selection.h instead. After editing only the selected shim header, newer_sources() returned [], even though that header was newer than the binary. A clean rebuild changed the executable's result from 7 to 8.

I would document the fixed fallback as an approximation for the covered layout, or use target-specific include order if the intention is to track CMake's actual selection. The fixture is synthetic and demonstrates the limit of the fallback.

AI-assisted (Codex).

The fallback took the first match in a fixed order (runtime/src, then
runtime/shims). CMake orders the directories per target, so a program built
with `shims src` takes the shims copy: editing it left the program looking
current. Now every match counts as a source. That can add a rebuild, never
miss one. No header name exists in two of these directories today, so the
result on the current tree is unchanged (665 quoted includes: 589 next to
their file, 76 through the directories, 0 unresolved).

STALE-BUILD-INCLUDE-DIRS
@TuroYT

TuroYT commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Confirmed, and the fixture is a good catch. The first revision took the first match in a fixed order (src, then shims), so with target_include_directories(prog PRIVATE shims src) an edit to the shims copy was missed.

378fcbc follows every copy found in the include directories instead of the first, so which one a target compiles no longer matters. The cost is an occasional extra rebuild, never a missed one. Your case is now a test, test_editing_only_the_shims_copy_marks_the_exe_stale: it fails on the previous revision and passes on this one.

No header name exists in two of these directories on main today (138 names), so the result on the current tree is unchanged: 665 quoted includes, 589 next to their file, 76 through the directories, 0 unresolved. I did not try to follow each target's own order, since that would mean parsing the CMake files.

@madvillain91 madvillain91 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent Windows 11 26H2 (26300.9711) check at 378fcbc against main 21625bc, using CPython 3.12.3 and Git for Windows 2.56.0.windows.2. All 36 tests across test_stale_build_include_dirs.py, test_first_light_stale_mesh.py, and test_make_game_dry_run.py passed (32.442s), confirming Windows path handling and os.utime behavior. Following every matching copy across _INCLUDE_DIRS is a clean fix for per-target CMake include ordering. LGTM.

@Dezmonius

Copy link
Copy Markdown
Contributor

Confirmed at 378fcbc on Windows 10 with CPython 3.14.7. All 11 include-directory tests pass. I reused the original MSVC-built fixture with shims src: when only the compiler-selected runtime/shims/selection.h was newer than the existing binary, the previous revision returned [] and this revision returned ["runtime/shims/selection.h"]. Thanks for adding the case to the suite.

Synthetic fixture only. AI-assisted (Codex).

QemmHD added a commit that referenced this pull request Nov 24, 2026
Merging.

**Why merged:** Indexes the DXBC identities the Xbox native graphics pipelines use, which the native-PSO path needs. The earlier hold (new tool not listed as a translator input) is fixed in 62a9588: native_pso_hashes is now in translator_deps.cmake, make_game.py's translation sources and runtime.yml.

**Why it's good:** Security read of the three-dot diff: tools and tests only, no binaries, downloads or network calls. The PR's own tests: 129 passed. The consistency set, which caught the missing input registration last time, is clean now.

Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones).

AI-assisted (Claude Code, Claude Opus 5.5).
QemmHD added a commit that referenced this pull request Nov 24, 2026
Merging.

**Why merged:** Adds the named NonSemantic.Shader.DebugInfo.100 instruction table so SPIR-V debug instructions disassemble by name. Oliwettoo checked that the table matches SPIRV-Headers' grammar exactly (44 names).

**Why it's good:** Data table plus tests only. Its tests: 47 passed. No behaviour change for shaders without debug info.

Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones).

AI-assisted (Claude Code, Claude Opus 5.5).
QemmHD added a commit that referenced this pull request Nov 24, 2026
Merging.

**Why merged:** manifest_verifier refuses a --cache path that aliases the input manifest (another spelling, a hard link, a symlink or a case alias), which would otherwise overwrite the manifest: a real data-loss guard. Reviewed as good by Oliwettoo.

**Why it's good:** Its tests: 82 passed, 4 skipped. It merges cleanly together with #346, which touches the same tool; the cumulative run includes both. Note from Oliwettoo: this conflicts with #344, which will need a rebase.

Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones).

AI-assisted (Claude Code, Claude Opus 5.5).
QemmHD added a commit that referenced this pull request Nov 24, 2026
Merging.

**Why merged:** manifest_verifier also protects every file the manifest lists from being overwritten by cache writes (the companion to #334). Reviewed as good by Oliwettoo.

**Why it's good:** Its tests: 83 passed, 4 skipped, on its own and stacked with #334.

Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones).

AI-assisted (Claude Code, Claude Opus 5.5).
QemmHD added a commit that referenced this pull request Nov 24, 2026
Merging.

**Why merged:** CI-only: a hung Windows runtime test now fails on its own (per-test ctest --timeout 300, TIMEOUT 180 on the loader test) instead of cancelling the whole job, and the job limit goes from 20 to 35 minutes. Each value is explained in a comment. Reviewed as good by Oliwettoo.

**Why it's good:** Workflow change with no new permissions, actions or downloads. The local tests it touches: 87 passed, 9 skipped. The runner-side effect can only be seen in CI, but there's nothing risky in it: the timeouts only turn hangs into failures.

Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones).

AI-assisted (Claude Code, Claude Opus 5.5).
QemmHD added a commit that referenced this pull request Nov 24, 2026
Merging.

**Why merged:** d3d12_xs_surface SDK discovery skips a Windows Kits version folder that lacks um/d3d12.h (a WDK-only folder), while an explicit WINDOWS_SDK_INCLUDE/SDK_INCLUDE is still taken as given. Reviewed as good by Oliwettoo.

**Why it's good:** Its tests: 18 passed, 1 skipped. The runtime build on this machine is unaffected (same ctest).

Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones).

AI-assisted (Claude Code, Claude Opus 5.5).
@QemmHD

QemmHD commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Merging.

Why merged: stale_build follows includes through the CMake include directories, so a header change in another include dir correctly marks a target stale. Dezmonius independently re-checked the fixed head; the "six failures" he first reported were the new tests running against the old implementation, which is expected.

Why it's good: Its tests: 55 passed, 8 skipped, and on current main with main's new tests/test_stale_build.py: 26/26.

Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones).

AI-assisted (Claude Code, Claude Opus 5.5).

@QemmHD
QemmHD merged commit 5435a76 into ProjectLeonida:main Nov 24, 2026
1 check passed
QemmHD added a commit that referenced this pull request Nov 24, 2026
Merging.

**Why merged:** Fixes the mesh half of #506: the statistics pool active during vkCmdDrawMeshTasksEXT no longer enables the two clipping counters that VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076 forbids. Verified on an RTX 5070 Ti (sodove), RTX 4080 (quartz-heron-58) and RX 7900 XTX (bvtterbroot), all with validation on; the rebase to 916dbc6 is byte-identical (range-diff checked). Merged on its own first because #577 is stacked on it.

**Why it's good:** On the 4070 SUPER with LEONIDA_VK_VALIDATION=1: plain main fails d3d12_mesh with 3x VUID-...-07076; main + #540 + #577 passes d3d12_mesh, replay_query_edges and replay_query_predication with 0 validation errors, and the counters match sodove's numbers (mesh-only C 8/0, PS 1024).

Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones).

AI-assisted (Claude Code, Claude Opus 5.5).
QemmHD added a commit that referenced this pull request Nov 24, 2026
Merging.

**Why merged:** Stacked on #540: the clipping invocations of a mesh segment now come from a mesh-pipeline query, so CInvocations/CPrimitives stay correct for mixed vertex + mesh work. sodove verified the exact head, including the disconnected-feature negative control that found (and now proves fixed) a gap in the test.

**Why it's good:** The embedded SPIR-V in statistics_sum_spirv.h was recompiled from the PR's .comp: all 431 words are identical and spirv-val passes. d3d12_mesh with validation: 0 errors, mixed C 12 vs vertex-only C 2, so the mesh share is 10, as expected.

Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones).

AI-assisted (Claude Code, Claude Opus 5.5).
@madvillain91

Copy link
Copy Markdown

madvillain8099

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.

4 participants