From 456f3b7f921cba65a40372e48eb68015469a361b Mon Sep 17 00:00:00 2001 From: Valiantsin Dzerakh Date: Wed, 28 Oct 2026 19:08:44 +0300 Subject: [PATCH] Compile ov_zstd.c per install with patches.c: it includes the player's patches.h for the patch page its host functions sit on, so in the prebuilt runtime library of a release it compiled to nothing and the patched zstd calls would have reached no host function Co-Authored-By: Claude Opus 5.5 --- docs/installer.md | 2 +- installer/layout.py | 2 +- tools/build_game.py | 7 ++++--- tools/make_release.py | 6 +++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/installer.md b/docs/installer.md index 7fb188e1..5b5a1ee3 100644 --- a/docs/installer.md +++ b/docs/installer.md @@ -45,7 +45,7 @@ keeps `profile/`. Saves carry over both ways: 1.4.3 converts a 1.2.1 save on loa 2. **Extract** ExeFS and RomFS into the install folder and verify the hashes. 3. **Lift** the ExeFS to C (`recomp/gen.py`, `recomp/patches-v121.txt` or `patches-v143.txt`) into a temp folder next to the installer. -4. **Compile** the generated C, `modules.c`, `romfs.c` and `patches.c` (they bake the per-install layout, RomFS +4. **Compile** the generated C, `modules.c`, `romfs.c`, `patches.c` and `ov_zstd.c` (they bake the per-install layout, RomFS hashes and the game version's patch page) and link them with the prebuilt runtime library into `totk.exe` (`build_game.py --runtime-lib`; about 3 min on 24 cores). 5. **Prepare** the RomFS patches and the shaders (`tools/make_romfs_patches.py`, `tools/prepare_shaders.py`, diff --git a/installer/layout.py b/installer/layout.py index 34a30422..c36250c0 100644 --- a/installer/layout.py +++ b/installer/layout.py @@ -7,7 +7,7 @@ Release (docs/installer.md "Release layout"), root = the unpacked folder: recomp/, tools/ the lifter and the scripts; recomp/patches-.txt, tools/data/expected-v.json for each supported update (SUPPORTED) llvm/ llvm-mingw (bin/clang.exe) - runtime/ libtotkrt.a, the headers, install-side sources (romfs.c, patches.c) and totk.ico; runtime/deps/ holds + runtime/ libtotkrt.a, the headers, install-side sources (romfs.c, patches.c, ov_zstd.c) and totk.ico; runtime/deps/ holds include/ + lib/ of Vulkan, SDL3, Opus, libvpx and VMA (build_game.py --deps) bin/ totk_xlate.exe (+ totk_xlate.id), hactool.exe, ninja.exe, SDL3.dll, libopus-0.dll data/shader_list.tsv the MacNativeGames shader list diff --git a/tools/build_game.py b/tools/build_game.py index c127af8c..ec488c23 100644 --- a/tools/build_game.py +++ b/tools/build_game.py @@ -84,9 +84,10 @@ VMA_INCLUDE = UCRT.parent / 'include' / 'vma' # vk_mem_alloc.h; MSYS2 package LLVM_LINK_LIBS = ['-lpsapi', '-lbcrypt', '-luser32', '-lgdi32', '-ldwmapi', '-lwinmm', '-lvulkan-1', '-lSDL3', '-lopus', '-l:libvpx.a', '-l:libzstd.a', '-l:libc++.a', '-l:libc++abi.a', '-l:libunwind.a', '-l:libwinpthread.a'] DEFAULT_DEPS = ROOT / 'toolchain' / 'deps-mingw' -# Runtime sources compiled per install, not in the library: romfs.c includes romfs_config.h, patches.c the patches.h -# of the player's game version (its patch page is the page after that version's main). -INSTALL_SIDE = {'romfs.c', 'patches.c'} +# Runtime sources compiled per install, not in the library: romfs.c includes romfs_config.h, patches.c and ov_zstd.c +# the patches.h of the player's game version (its patch page is the page after that version's main; ov_zstd.c's host +# functions sit on it). +INSTALL_SIDE = {'romfs.c', 'patches.c', 'ov_zstd.c'} LIB_NAME = 'libtotkrt.a' AR = UCRT / 'llvm-ar.exe' WINDRES = UCRT / 'windres.exe' # runtime/totk.rc: the manifest of totk.exe diff --git a/tools/make_release.py b/tools/make_release.py index 2aeaf93a..9e8442d2 100644 --- a/tools/make_release.py +++ b/tools/make_release.py @@ -10,8 +10,8 @@ cached in toolchain/release-dl/ and checked against the sha256 in PINS; a mismat files come out of the python.org installer's own component MSI, unpacked with msiexec /a and expand.exe; the installer is never run) llvm/ llvm-mingw, x86_64 only, the files clang and lld need to compile and link totk.exe - runtime/ libtotkrt.a (build_game.py --make-runtime-lib with llvm/), the runtime headers, romfs.c and patches.c - (compiled per install), deps/ (headers and import libraries of SDL3, Opus, libvpx, Vulkan and VMA) + runtime/ libtotkrt.a (build_game.py --make-runtime-lib with llvm/), the runtime headers, romfs.c, patches.c and + ov_zstd.c (compiled per install), deps/ (headers and import libraries of SDL3, Opus, libvpx, Vulkan and VMA) bin/ totk_xlate.exe (+ .id), hactool.exe, SDL3.dll (upstream), libopus-0.dll, ninja.exe recomp/, tools/, data/, installer/, licenses/, THIRD_PARTY_NOTICES.md, totk.ini.example VERSION git describe of the checkout (else the short hash); the installer's release string @@ -341,7 +341,7 @@ def runtime_lib(out, llvm): if p.suffix in RUNTIME_SUFFIXES and p.is_file(): (rt / p.relative_to(ROOT / 'runtime')).parent.mkdir(parents=True, exist_ok=True) shutil.copy2(p, rt / p.relative_to(ROOT / 'runtime')) - for name in ('romfs.c', 'patches.c'): # build_game.py INSTALL_SIDE + for name in ('romfs.c', 'patches.c', 'ov_zstd.c'): # build_game.py INSTALL_SIDE shutil.copy2(ROOT / 'runtime' / name, rt / name)