Home

dev / openkara

publicthedavidweng/OpenKara· sync paused
Code Branches Pull requestsIssuesInsights
main
Home Code PRsIssues

#363 Build Windows runtime artifacts with static CRT (/MT) to drop the VC++ Redistributable dependency

closed

Opened by dev · 2 days ago

devopened this issueAuthor· 2 days ago

Motivation

The Windows runtime artifacts (onnxruntime.dll, both the DirectML and the CPU-only variants) are /MD builds, so their PE import table pulls in four VC++ Redistributable DLLs (VCRUNTIME140.dll, VCRUNTIME140_1.dll, MSVCP140.dll, MSVCP140_1.dll). On a clean Windows image without the redistributable (e.g. the PVE Windows Server 2022 guest in #284), LoadLibraryExW fails with error 126.

#361 mitigates this by deploying the four pinned Microsoft CRT DLLs app-local next to openkara.exe. That works, but it is a mitigation: the repo carries ~768 KB of Microsoft binaries and has to track CRT servicing manually.

The strategic fix is to build the runtime artifact itself with the static CRT (/MT) so it has zero redistributable dependencies. Research notes: onnxruntime's own build.py supports this as a first-class switch (--enable_msvc_static_runtime), it is the upstream-recommended path for redist-free deployments (microsoft/onnxruntime#26024 — note the official NuGet binaries are /MD, so they are not a precedent; WinAppSDK's embedded ORT is), and the combination with the DirectML EP is known to work (microsoft/onnxruntime#17774) since DirectML.dll is a self-contained redistributable reached across a COM/C ABI boundary.

Upstream change

  • thedavidweng/openkara-models#90 — switches both Windows targets to CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded + ONNX_USE_MSVC_STATIC_RUNTIME=ON + protobuf_MSVC_STATIC_RUNTIME=ON + ABSL_MSVC_STATIC_RUNTIME=ON (the exact flag set upstream build.py --enable_msvc_static_runtime uses for v1.27.1). Kept as a draft until a real build is verified.

Dependency chain

  • openkara-models: verify a real Windows build of PR #90 — parse the PE import table of both produced onnxruntime.dll files and assert no VCRUNTIME140* / MSVCP140* imports (script included in the PR), smoke harness green, record the actual size delta; then merge. Done 2026-08-12: all 6 targets green, zero redist imports on both DLLs (UCRT imports gone too), +0.6 MiB per DLL (+3–4%); merged as 98a1aeb.
  • openkara-models: publish a new release tag (ort-v* / infra-*) and catalog generation with the static-CRT artifacts. Done 2026-08-13: publish run 31670494161 built all 6 targets from 98a1aeb; release infra-2026-08-12-001 ships the archives + supply chain; catalog generation 13 merged as thedavidweng/openkara-models#91 (f3f54c7), stable pointer advanced.
  • OpenKara: bump src-tauri/catalog/release-manifest.json to the new generation (currently 12) with the new artifact URLs/digests, and update the recorded build flags. Done 2026-08-13: #391 (merge d6b9505b) embeds generation 13; fresh-staged all three host targets locally and the Windows installed-app full suite passed on the branch.
  • OpenKara: confirm zero-redist on the #284 reproduction environment (clean Windows image, no VC++ Redistributable): DLL loads and separation runs on the CPU path.
  • OpenKara: remove the app-local CRT mitigation from #361 once the new runtime generation ships: Done 2026-08-13: #392 (merge 992e7d1d) removes the resources/test/CI assertions and records the supersession in ADR 0025.
    • src-tauri/resources/windows/vcredist/ (the four CRT DLLs + manifest.json)
    • src-tauri/tests/windows_vcredist_resources.rs
    • the post-install CRT assertions in .github/workflows/reusable-windows-installed-app.yml
    • update ADR 0024 (docs/adr/0024-windows-runtime-load-strategy.md) to record the strategic fix superseding the app-local deployment.

Notes

  • DirectML.dll is unaffected: it is Microsoft's prebuilt redistributable, itself statically linked (imports only api-ms-win-core-* and d3d12.dll), and stays a companion DLL of the DirectML variant.
  • Expected artifact growth from embedding the CRT: roughly +0.5–1.5 MB uncompressed per DLL (baseline: CPU-only reduced DLL is ~13.9 MB); exact numbers land in the openkara-models PR after the verification build.
  • Until the chain completes, the #361 app-local CRT deployment remains the shipped mitigation.
devcommented· 2 days ago

Upstream change verified and merged: thedavidweng/openkara-models#90 (squash commit 98a1aeb).

  • CI run 31557200798: all 6 targets green, including both Windows static-CRT builds.
  • PE import-table gate: both onnxruntime.dll variants now import only core OS libraries (CPU-only: 6 imports, DirectML: 5) — no VCRUNTIME140*/MSVCP140*, and the api-ms-win-crt-* UCRT imports are gone as well. DirectML.dll companion unchanged. Full output in the PR verification comment.
  • Measured size: cpu-reduced DLL 13.9 → 14.5 MiB (+4.2%), directml-reduced DLL 18.9 → 19.5 MiB (+3.1%).

Next steps (gated release work, not started): publish a new openkara-models release tag with static-CRT artifacts, then bump the OpenKara catalog generation. The #361 app-local CRT mitigation stays in place until then, so users have no coverage gap.

devcommented· yesterday

Completed end-to-end; closing evidence for the record:

  • Upstream artifacts: publish run 31670494161 rebuilt all six reduced runtimes from 98a1aeb (PR #90 flags); release infra-2026-08-12-001 ships them with digests + supply chain. PE import tables of both Windows onnxruntime.dll variants: zero VCRUNTIME140* / MSVCP140* imports (UCRT api-sets gone too).
  • Catalog generation 13 (2026-08-12-001): thedavidweng/openkara-models#91, merged f3f54c7; stable channel pointer advanced atomically.
  • OpenKara snapshot bump: #391, merged d6b9505b. Fresh-staged the new archives for x86_64-pc-windows-msvc (directml + cpu) and aarch64-apple-darwin locally (size/digest/per-file digests verified); Windows installed-app full suite (clean install + keyboard UIA + fault injection + #284 bootstrap regression) green on the branch: run 31674410572.
  • Mitigation removal: #392, merged 992e7d1d — vcredist resources + test + bundle mappings + CI layout assertions removed, ERROR_MOD_NOT_FOUND hint updated, ADR 0025 records the supersession (ADR 0024 decision 1 status-lined). Windows installed-app gate on the PR (clean install + #284 regression, now without the app-local DLLs): run 31677088989.

The one open checklist item — confirmation on the #284 reproduction environment — is with the reporter: asked in github.com/thedavidweng/…/284 (catalog auto-discovery delivers generation 13 without an app release). #284 stays open to track that confirmation.

Sign in to comment.

Linked pull requests

No linked pull requests yet.