Compile ov_ability.c per install, so 1.4.3 starts from a release again

The ability target guard registers its host function on the game version's patch page (patches.h), but it was left
out of INSTALL_SIDE and went into libtotkrt.a, which make_release builds once from 1.2.1's generated headers. On a
1.4.3 install that address lies inside sdk and dispatch stops at start ("host function at 0x700472bf60 lies inside
module sdk"). The library build now also stops when a library source includes a per-version header. (#1005)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-11-13 18:06:37 +03:00
1 parent 00baa18d14
commit bdba6ba83f
3 files changed
+20 -5

No files matched your search

+18 -3
View File
@@ -187,8 +187,10 @@ LLVM_LINK_LIBS = ['-lpsapi', '-lbcrypt', '-luser32', '-lgdi32', '-ldwmapi', '-li
DEFAULT_DEPS = ROOT / 'toolchain' / 'deps-mingw'
# 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). mouse_direct.c also registers host callbacks relative to that version's patch page.
INSTALL_SIDE = {'romfs.c', 'patches.c', 'ov_zstd.c', 'mouse_direct.c'}
# functions sit on it). mouse_direct.c and ov_ability.c also register host callbacks relative to that version's patch
# page. A library source that includes one of PER_VERSION_HEADERS stops the library build (library_sources).
INSTALL_SIDE = {'romfs.c', 'patches.c', 'ov_zstd.c', 'mouse_direct.c', 'ov_ability.c'}
PER_VERSION_HEADERS = ('"patches.h"', '"romfs_config.h"')
LIB_NAME = 'libtotkrt.a'
AR = UCRT / 'llvm-ar.exe' if WIN else on_path('llvm-ar')
WINDRES = UCRT / 'windres.exe' # runtime/totk.rc: the manifest of totk.exe
@@ -324,6 +326,19 @@ def runtime_sources(skip=()):
return sorted(p for pat in pats for p in RUNTIME.glob(pat) if p.name not in skip and not other_os(p.name))
def library_sources(sources):
"""The runtime sources of libtotkrt.a: all but INSTALL_SIDE. The library is built once per release from one game
version's generated headers, so a source that includes a per-version header there bakes that version's addresses
into every install: a host function on the 1.2.1 patch page lies inside 1.4.3's sdk and the game stops at start."""
lib = [p for p in sources if p.name not in INSTALL_SIDE]
baked = [p.name for p in lib if p.suffix in ('.c', '.cpp')
and any(h in p.read_text(encoding='utf-8', errors='replace') for h in PER_VERSION_HEADERS)]
if baked:
sys.exit(f'build_game: library sources with a per-version header ({", ".join(PER_VERSION_HEADERS)}): {", ".join(baked)}; '
'add them to INSTALL_SIDE')
return lib
def install_stamp(out, runtime_lib):
"""Write obj/runtime/inputs.sha256, one hash over the runtime library, the INSTALL_SIDE sources and every runtime
header, and return its path. The release zip dates every file 1980-01-01 (make_release.py write_zip), so a new
@@ -451,7 +466,7 @@ def ninja_file(gen, out, mods, pool_depth, skip=(), prebuilt=False, runtime_lib=
rt = []
sources = runtime_sources(skip)
if make_lib:
sources = [p for p in sources if p.name not in INSTALL_SIDE]
sources = library_sources(sources)
elif runtime_lib:
sources = [p for p in sources if p.name in INSTALL_SIDE] + [out / 'modules.c']
else:
+1 -1
View File
@@ -11,7 +11,7 @@ cached in toolchain/release-dl/ and checked against the sha256 in PINS; a mismat
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 and libtotkrt-v2.a (build_game.py --make-runtime-lib with llvm/, x86-64-v3 and v2), the
runtime headers, romfs.c, patches.c and ov_zstd.c (compiled per install), deps/ (headers and import
runtime headers, the INSTALL_SIDE sources of build_game.py (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
+1 -1
View File
@@ -15,7 +15,7 @@ the .NET 10 SDK and Python 3.12+ with Pillow (.venv). The folder holds:
llvm/ LLVM 23 (clang, lld, llvm-ar, the clang resource headers) and llvm/sysroot: the files of the sniper SDK
sysroot the game's compile and link read, nothing else (recorded while building the runtime library)
runtime/ libtotkrt.a and libtotkrt-v2.a (build_game.py --make-runtime-lib --sysroot, x86-64-v3 and v2), the
runtime headers, romfs.c, patches.c and ov_zstd.c (compiled per install), totk.png (the window icon),
runtime headers, the INSTALL_SIDE sources of build_game.py (compiled per install), totk.png (the window icon),
deps/ (Vulkan headers 1.4.363, VMA, zstd built static; SDL3, Opus and libvpx come from the sysroot)
bin/ totk_xlate (+ .id), hactool, ninja, libSDL3.so.0 (the sysroot's; the game finds it beside itself)
recomp/, tools/, data/, installer/, licenses/, THIRD_PARTY_NOTICES.md, totk.ini.example, VERSION