build: compile four checks' shared sources once #1807

Closed
tedin7 wants to merge 1 commit from upstream-pr/1814 into main
tedin7 commented 2026-11-24 19:05:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:05:18Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6589297058 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1814). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T19:05:18Z. --- 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.
upstream-sync closed this pull request 2026-11-24 20:00:44 +00:00
tedin7 commented 2026-11-24 20:01:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:14:54Z.


Closing this draft for now to help keep the open PR queue manageable; the branch stays preserved on the fork so it can be reopened once the queue clears.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7141818874 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1814#issuecomment-7141818874). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T19:14:54Z. --- Closing this draft for now to help keep the open PR queue manageable; the branch stays preserved on the fork so it can be reopened once the queue clears.

Pull request closed

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!1807
No description provided.