Skip to content

runtime: compile the shim registry once for compatible Windows targets - #973

Open
Kadamitas wants to merge 1 commit into
ProjectLeonida:mainfrom
Kadamitas:build/reuse-registry-object
Open

Kadamitas wants to merge 1 commit into
ProjectLeonida:mainfrom
Kadamitas:build/reuse-registry-object

Conversation

@Kadamitas

@Kadamitas Kadamitas commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: compile the shim registry once for compatible Windows targets (unlisted build work).

What and why

Many Windows runtime, test, and tool targets each list the same shims/registry.cpp. This change compiles the common implementation in a CMake object library. Each executable links its own copy, so process-local state and static shim registrations keep their original ownership.

The Nov 27 rebase shares this object across 37 matching target definitions. The XMem test keeps a private compilation because clang-cl enables asynchronous exception handling there. The loader fuzzer keeps a private compilation for its AddressSanitizer and STL annotation settings. The number of targets enabled depends on the installed libraries and generator options.

Tested

  • On the Nov 27 base 43a9d562d, MSVC built the shared registry and linked the DirectStorage and XG tests. Both passed with the static CRT.

Earlier verification:

  • Windows x64, Visual Studio 2022 MSVC 19.36, SDK 10.0.26100, RelWithDebInfo. In the generated CPU-only build, 36 executables referenced one shared object. The registry source compiled separately for the object library, XMem test and fuzzer.
  • Built and ran five cases with the static CRT: startup_trace, xmem, process_cmdline, bcrypt_rng, and bcrypt_rng_seeded. All five passed.
  • Generated a second configuration with the default dynamic CRT and LEONIDA_LOADER_FUZZ_ASAN=ON. Built the shared registry object and compiled the fuzzer's private registry source with /fsanitize=address and both STL annotation disables. The complete dynamic-CRT test build on this older toolset stops in main's separate crt_timed_wait.cpp; those full binaries were not tested in that configuration. clang-cl was not run.
  • git diff --check and the repository's no-game-data checker passed.

GPUs tested: N/A, CPU-only build change. No frame-rate claim.

AI-assisted: yes, OpenAI Codex.

Checklist

  • Based on current main.
  • One build-system change.
  • No game files, keys, or decryption content.

@Kadamitas
Kadamitas force-pushed the build/reuse-registry-object branch from d21a3f4 to 24ab90c Compare November 24, 2026 20:17
@Kadamitas
Kadamitas marked this pull request as ready for review November 24, 2026 20:17
@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
@PierreEbele

Copy link
Copy Markdown
Contributor

Reviewed 24ab90c: 39 targets now share a gta6rt_shim_registry OBJECT library; xmem_test (/EHa under clang-cl) and pe_loader_fuzz (ASan) keep their own copies, now with comments saying why. I ran the 8 stdlib tests that parse runtime/CMakeLists.txt on both trees (identical results; test_runtime_paths fails on both only because git was unavailable here). My probe found no double compilation, no guard leak and no EH/CRT mismatch among converted targets; registry.cpp has no #if gates, so per-target define deltas cannot change the object. One finding: the comments above xgameruntime_test (line 433) and d3d12_xmem_placed_test (line 2080) still say those targets compile their own registry.cpp like xmem_test; on this branch both consume the shared objects. I could not run the Windows build here, so CI is the remaining proof. AI-assisted review.

Recommendation: Fix first

@Kadamitas
Kadamitas force-pushed the build/reuse-registry-object branch from 24ab90c to 8bb734a Compare November 27, 2026 18:56
@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Nov 27, 2026
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.

2 participants