Repository navigation
build: compile four checks' shared sources once - #1945
Conversation
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.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Built it: one compile per shared source, identical flags, tests unchangedWindows 11 build 26300.9974, MSVC 19.44, 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.objThree 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 Byte-for-byte the same, including the runtime ( Testsctest --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
One thing worth saying in the descriptionThe table lists three sources but four library names would be expected; I only verified three ( VerdictReviewed. Build-only, no behaviour change, one compile per source on a clean build, and the flag-identity that makes it safe is Notes
|
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
OBJECTlibrary whose objects the executables take with$<TARGET_OBJECTS:...>, the pattern the file already uses forera_physical_lenient.tests/d3d12x_device_check.cppd3d12x_device_check,d3d12x_device_struct_return_controltests/startup_stream_setup.cppstartup_stream_consumer,startup_stream_depthsrc/startup_stubs/audio_sink.cppstartup_audio_output,startup_audio_pacingtests/desktop_gpu.cppd3d12x_compute_list_check,d3d12x_graphics_list_checkFour 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.cppinstartup_dump_fence_check,startup_nv12_drawandstartup_plane_refreshwould save two more compiles. Their lines sit next to additions in startup: cache translated graphics pipelines #1641 and startup: clear depth and stencil views (command-list slot 51) #1806, which conflicted when I tried it, so they are unchanged.src/startup_stubs/d3d12_xs_device.cppis in build: share the D3D12 device object across two test targets #1752.xmem_shim,d3d12_xs_shim,cpu_*providers, the archive codec) get a different<target>_EXPORTSdefinition per target, so their command lines are not identical.startup_gamesave_lock_errors_keep,cpu_startup_exe_*,xmem_shim_test_controls,d3d12_xs_rangewith different include directories) are not shared.Checks
git merge-treeof this branch against all 88 open PRs that touchCMakeLists.txt, and against ci: save main sccache right after build; pull requests only read it #1740. For every PR the set of conflicting files and the number of conflict hunks inCMakeLists.txtmatch what the same PR already has againstorigin/mainalone (56 merge cleanly, 32 already conflict withmain). No new conflict, including ci: run the full Windows suites with CTest in parallel #1173, build: share the D3D12 device object across two test targets #1752 and build: write the variants of each x87 fixture in one Python process #1789. The PRs that edittests/startup_stream_setup.cpportests/desktop_gpu.h(startup: invalidate cached constants when the graphics root changes #1808, startup: record SetGraphicsRoot32BitConstant (slot 38) #1726, shader: translate mesh allocations with several vertices and triangles #1779, shader: lower gfx1030 comparison sample LOD and bias #1568, shader: lower paired 16-bit attr0 interpolation under round toward zero in pixel_aot (experiment) #713) change source content only, not compile flags.$<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.pyandpython3 -B tests/bidi_controls_check.pypass.Not verified
OBJECTlibrary'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.