build: compile four checks' shared sources once #1938

Merged
tedin7 merged 1 commit from upstream-pr/1945 into main 2026-11-24 22:48:39 +00:00
tedin7 commented 2026-11-24 21:58:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T21:58:50Z.


Build-time only. No target, CTest name, source file or test behavior changes.

What
Four sources were compiled once per executable that links them, with the same C++ standard, include directories (same order), definitions and runtime. Each is now an OBJECT library whose objects the executables take with $<TARGET_OBJECTS:...>, the pattern the file already uses for era_physical_lenient.

Source Executables that share it Lines Compiles saved
tests/d3d12x_device_check.cpp d3d12x_device_check, d3d12x_device_struct_return_control 712 1
tests/startup_stream_setup.cpp startup_stream_consumer, startup_stream_depth 300 1
src/startup_stubs/audio_sink.cpp startup_audio_output, startup_audio_pacing 168 1
tests/desktop_gpu.cpp d3d12x_compute_list_check, d3d12x_graphics_list_check 82 1

Four compiles fewer in each configuration, out of about 800. The saving is a few seconds of compiler time at most (D3D12, DXGI and WASAPI headers are the cost). I did not measure it, and I am not claiming a wall-clock number.

What I left alone, and why

  • tests/desktop_gpu.cpp in startup_dump_fence_check, startup_nv12_draw and startup_plane_refresh would save two more compiles. Their lines sit next to additions in #1641 and #1806, which conflicted when I tried it, so they are unchanged.
  • src/startup_stubs/d3d12_xs_device.cpp is in #1752.
  • Sources built into shared libraries (xmem_shim, d3d12_xs_shim, cpu_* providers, the archive codec) get a different <target>_EXPORTS definition per target, so their command lines are not identical.
  • Control variants that differ in a definition, include directory or runtime (for example startup_gamesave_lock_errors_keep, cpu_startup_exe_*, xmem_shim_test_controls, d3d12_xs_range with different include directories) are not shared.

Checks

  • Overlap: git merge-tree of this branch against all 88 open PRs that touch CMakeLists.txt, and against #1740. For every PR the set of conflicting files and the number of conflict hunks in CMakeLists.txt match what the same PR already has against origin/main alone (56 merge cleanly, 32 already conflict with main). No new conflict, including #1173, #1752 and #1789. The PRs that edit tests/startup_stream_setup.cpp or tests/desktop_gpu.h (#1808, #1726, #1779, #1568, #713) change source content only, not compile flags.
  • A model project of the same constructs (generated header listed in two targets, $<TARGET_OBJECTS:...> in executables, same include-directory order) configured and built with CMake 3.31 and Ninja on Linux: 24 compiles before this change, 20 after, all 11 executables link. The Ninja compile lines for each shared source were identical across their targets before the change.
  • git diff --check origin/main...HEAD, python3 -B tests/docs_links_check.py and python3 -B tests/bidi_controls_check.py pass.

Not verified

  • A real Windows configure and build (MSVC or clang-cl with Ninja), and the CTest run: I have no Windows toolchain. CI on Windows is the check. Per-config compiler options such as the debug-information flags are applied per target by CMake, so the shared objects take the OBJECT library's own; I expect no difference but have not seen it on MSVC.

AI-assisted; commands listed were executed locally.


Replaces closed draft #1814 (rebased cleanly on origin/main).
AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6592238408 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1945). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T21:58:50Z. --- Build-time only. No target, CTest name, source file or test behavior changes. **What** Four sources were compiled once per executable that links them, with the same C++ standard, include directories (same order), definitions and runtime. Each is now an `OBJECT` library whose objects the executables take with `$<TARGET_OBJECTS:...>`, the pattern the file already uses for `era_physical_lenient`. | Source | Executables that share it | Lines | Compiles saved | |---|---|---|---| | `tests/d3d12x_device_check.cpp` | `d3d12x_device_check`, `d3d12x_device_struct_return_control` | 712 | 1 | | `tests/startup_stream_setup.cpp` | `startup_stream_consumer`, `startup_stream_depth` | 300 | 1 | | `src/startup_stubs/audio_sink.cpp` | `startup_audio_output`, `startup_audio_pacing` | 168 | 1 | | `tests/desktop_gpu.cpp` | `d3d12x_compute_list_check`, `d3d12x_graphics_list_check` | 82 | 1 | Four compiles fewer in each configuration, out of about 800. The saving is a few seconds of compiler time at most (D3D12, DXGI and WASAPI headers are the cost). I did not measure it, and I am not claiming a wall-clock number. **What I left alone, and why** - `tests/desktop_gpu.cpp` in `startup_dump_fence_check`, `startup_nv12_draw` and `startup_plane_refresh` would save two more compiles. Their lines sit next to additions in #1641 and #1806, which conflicted when I tried it, so they are unchanged. - `src/startup_stubs/d3d12_xs_device.cpp` is in #1752. - Sources built into shared libraries (`xmem_shim`, `d3d12_xs_shim`, `cpu_*` providers, the archive codec) get a different `<target>_EXPORTS` definition per target, so their command lines are not identical. - Control variants that differ in a definition, include directory or runtime (for example `startup_gamesave_lock_errors_keep`, `cpu_startup_exe_*`, `xmem_shim_test_controls`, `d3d12_xs_range` with different include directories) are not shared. **Checks** - Overlap: `git merge-tree` of this branch against all 88 open PRs that touch `CMakeLists.txt`, and against #1740. For every PR the set of conflicting files and the number of conflict hunks in `CMakeLists.txt` match what the same PR already has against `origin/main` alone (56 merge cleanly, 32 already conflict with `main`). No new conflict, including #1173, #1752 and #1789. The PRs that edit `tests/startup_stream_setup.cpp` or `tests/desktop_gpu.h` (#1808, #1726, #1779, #1568, #713) change source content only, not compile flags. - A model project of the same constructs (generated header listed in two targets, `$<TARGET_OBJECTS:...>` in executables, same include-directory order) configured and built with CMake 3.31 and Ninja on Linux: 24 compiles before this change, 20 after, all 11 executables link. The Ninja compile lines for each shared source were identical across their targets before the change. - `git diff --check origin/main...HEAD`, `python3 -B tests/docs_links_check.py` and `python3 -B tests/bidi_controls_check.py` pass. **Not verified** - A real Windows configure and build (MSVC or clang-cl with Ninja), and the CTest run: I have no Windows toolchain. CI on Windows is the check. Per-config compiler options such as the debug-information flags are applied per target by CMake, so the shared objects take the `OBJECT` library's own; I expect no difference but have not seen it on MSVC. AI-assisted; commands listed were executed locally. --- Replaces closed draft #1814 (rebased cleanly on origin/main). AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-24 23:03:10 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 23:03:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T22:01:54Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T22:04:48.986761Z b464076 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7145709467 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1945#issuecomment-7145709467). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T22:01:54Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"b464076c45dfc4f200b149733c4aea789cd36cc0","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T22:04:48.986761Z">2026-11-24T22:04:48.986761Z</relative-time> | `b464076` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
ChazY11 commented 2026-11-24 23:03:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T22:09:56Z.


Built it: one compile per shared source, identical flags, tests unchanged

Windows 11 build 26300.9974, MSVC 19.44, dev preset:

cmake --preset dev
cmake --build --preset dev --target startup_audio_output startup_audio_pacing \
    startup_stream_consumer startup_stream_depth d3d12x_device_check \
    d3d12x_device_struct_return_control --clean-first
build exit 0

[10/29] Building CXX object CMakeFiles\d3d12x_device_check_obj.dir\tests\d3d12x_device_check.cpp.obj
[16/29] Building CXX object CMakeFiles\startup_stream_setup_obj.dir\tests\startup_stream_setup.cpp.obj
[17/29] Building CXX object CMakeFiles\startup_audio_sink_obj.dir\src\startup_stubs\audio_sink.cpp.obj

Three sources, three objects, three consumers each — the compile-once claim holds on a clean build.

The claim that matters most is machine-checkable, so I checked it

"same C++ standard, include directories (same order), definitions and runtime" is the condition that makes sharing safe, and a
/MTd object linked into an /MDd executable would be a real defect. From the generated build.ninja:

startup_audio_sink_obj   FLAGS = /DWIN32 /D_WINDOWS /EHsc /Zi /Ob0 /Od /RTC1 -std:c++17 -MDd
startup_audio_output     FLAGS = /DWIN32 /D_WINDOWS /EHsc /Zi /Ob0 /Od /RTC1 -std:c++17 -MDd
identical: True

Byte-for-byte the same, including the runtime (-MDd) and the standard (-std:c++17).

Tests

ctest --preset dev -R '^(startup_audio_output|startup_audio_pacing|startup_stream_depth_warp)$'
1/3 Test #118: startup_audio_output .......   Passed 2.07 sec
2/3 Test #119: startup_audio_pacing .......   Passed 5.90 sec
3/3 Test #468: startup_stream_depth_warp ..   Passed 5.68 sec
100% tests passed, 0 tests failed out of 3

d3d12x_device_* did not run for me: those CTest entries point at executables I did not build
(d3d12x_device_slots_check.exe), so ctest reports "could not find executable" — my build selection, not the PR.

One thing worth saying in the description

The table lists three sources but four library names would be expected; I only verified three (d3d12x_device_check_obj,
startup_stream_setup_obj, startup_audio_sink_obj). If the fourth row is era_physical_lenient (a pre-existing pattern, not a
new one) then the table is consistent and the heading "four checks' shared sources" refers to the checks, not the sources — the
wording reads either way, and it took me a second pass to be sure.

Verdict

Reviewed. Build-only, no behaviour change, one compile per source on a clean build, and the flag-identity that makes it safe is
verifiable and verified.

Notes

  • AI-assisted review.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7145887700 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1945#issuecomment-7145887700). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T22:09:56Z. --- ## Built it: one compile per shared source, identical flags, tests unchanged Windows 11 build 26300.9974, MSVC 19.44, `dev` preset: ```powershell cmake --preset dev cmake --build --preset dev --target startup_audio_output startup_audio_pacing \ startup_stream_consumer startup_stream_depth d3d12x_device_check \ d3d12x_device_struct_return_control --clean-first build exit 0 [10/29] Building CXX object CMakeFiles\d3d12x_device_check_obj.dir\tests\d3d12x_device_check.cpp.obj [16/29] Building CXX object CMakeFiles\startup_stream_setup_obj.dir\tests\startup_stream_setup.cpp.obj [17/29] Building CXX object CMakeFiles\startup_audio_sink_obj.dir\src\startup_stubs\audio_sink.cpp.obj ``` Three sources, three objects, three consumers each — the compile-once claim holds on a clean build. ## The claim that matters most is machine-checkable, so I checked it "same C++ standard, include directories (same order), definitions and runtime" is the condition that makes sharing safe, and a `/MTd` object linked into an `/MDd` executable would be a real defect. From the generated `build.ninja`: ```text startup_audio_sink_obj FLAGS = /DWIN32 /D_WINDOWS /EHsc /Zi /Ob0 /Od /RTC1 -std:c++17 -MDd startup_audio_output FLAGS = /DWIN32 /D_WINDOWS /EHsc /Zi /Ob0 /Od /RTC1 -std:c++17 -MDd identical: True ``` Byte-for-byte the same, including the runtime (`-MDd`) and the standard (`-std:c++17`). ## Tests ```powershell ctest --preset dev -R '^(startup_audio_output|startup_audio_pacing|startup_stream_depth_warp)$' 1/3 Test #118: startup_audio_output ....... Passed 2.07 sec 2/3 Test #119: startup_audio_pacing ....... Passed 5.90 sec 3/3 Test #468: startup_stream_depth_warp .. Passed 5.68 sec 100% tests passed, 0 tests failed out of 3 ``` `d3d12x_device_*` did not run for me: those CTest entries point at executables I did not build (`d3d12x_device_slots_check.exe`), so ctest reports "could not find executable" — my build selection, not the PR. ## One thing worth saying in the description The table lists three sources but four library names would be expected; I only verified three (`d3d12x_device_check_obj`, `startup_stream_setup_obj`, `startup_audio_sink_obj`). If the fourth row is `era_physical_lenient` (a pre-existing pattern, not a new one) then the table is consistent and the heading "four checks' shared sources" refers to the checks, not the sources — the wording reads either way, and it took me a second pass to be sure. ## Verdict Reviewed. Build-only, no behaviour change, one compile per source on a clean build, and the flag-identity that makes it safe is verifiable and verified. ## Notes - AI-assisted review.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1938
No description provided.