Skip to content

build: compile four checks' shared sources once - #1945

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
tedin7:x2w-cmake-shared-objs
Nov 24, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
tedin7:x2w-cmake-shared-objs

Conversation

@tedin7

@tedin7 tedin7 commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

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

Checks

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.

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.
@tedin7
tedin7 marked this pull request as ready for review November 24, 2026 22:01
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
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.

@ChazY11

ChazY11 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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.

@R0Y00
R0Y00 merged commit 82c0700 into R0Y00:main Nov 24, 2026
5 checks passed
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.

3 participants