build: compile four checks' shared sources once #1814

Closed
github-bot wants to merge 1 commit from gh-pr/1814/head into gh-pr/1814/base
Owner

@⁠tedin7 on GitHub · 2026-11-24 19:05 UTC · original
tedin7:x2w-cmake-shared-objs → main · +25 −9 · 1 files · 1 commits · closed without merging

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.

**@⁠tedin7** on GitHub · 2026-11-24 19:05 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1814) `tedin7:x2w-cmake-shared-objs` → `main` · +25 −9 · 1 files · 1 commits · closed without merging 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.
tests/desktop_gpu.cpp (the two d3d12x list checks), src/startup_stubs/audio_sink.cpp,
tests/startup_stream_setup.cpp and tests/d3d12x_device_check.cpp were each compiled once per executable
that links them, with the same standard, include directories and definitions. They are now OBJECT
libraries whose objects the executables take with $<TARGET_OBJECTS:...>. No target, test or file name
changes; the shared-library and control variants that differ in definitions or runtime are left as
they are.

Four compiles fewer per configuration.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:34:58 +00:00
github-bot closed this pull request 2026-11-26 23:34:58 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 19:14 UTC · original

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.

**@⁠tedin7** on GitHub · 2026-11-24 19:14 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1814#issuecomment-7141818874) 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

This discussion has been locked. Commenting is limited to contributors.
No description provided.