From 7508469b6e78d927ce25445bc15dbb7377958bd6 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 31 Oct 2026 09:58:58 +0800 Subject: [PATCH] Take a compiler cache in front of clang from SCCACHE A lift rewrites every generated chunk with the same contents, so a local sccache hits all of their objects and the compile step costs seconds instead of minutes. build_game.py writes it into the ninja file ahead of cc when the environment names one; the build guide describes the setting. --- docs/building.md | 8 ++++++++ tools/build_game.py | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/building.md b/docs/building.md index 44216cc0..f16368b6 100644 --- a/docs/building.md +++ b/docs/building.md @@ -87,6 +87,14 @@ From the repository root, in PowerShell. Every step that depends on the game ver ``` Lifting takes about 15 s, a clean compile about 200 s on 24 threads; later builds recompile only what changed. + A compiler cache in front of clang shortens it further: with `SCCACHE` set to an sccache executable, `build_game.py` + writes it into the ninja file ahead of `cc`, and every lift rewrites the generated chunks with the same contents, so + a second build of the same version hits all of their objects: + + ```powershell + $env:SCCACHE = "path\to\sccache.exe" + .venv\Scripts\python tools\build_game.py --version + ``` `--patches` builds in the frame-rate, resolution and other patch sets, switchable at run time. The link copies `SDL3.dll`, `libiconv-2.dll` and `libopus-0.dll` next to the exe. For Xbox button prompts, run `make_romfs_patches.py` once more with `--xbox-prompts`: it writes diff --git a/tools/build_game.py b/tools/build_game.py index 22eb9581..46b2530f 100644 --- a/tools/build_game.py +++ b/tools/build_game.py @@ -257,11 +257,14 @@ def ninja_file(gen, out, mods, pool_depth, skip=(), prebuilt=False, runtime_lib= imgui = cmd_path(RUNTIME / 'third_party' / 'imgui') rt_inc = f'{inc} -I {cmd_path(out)} -I {vma} -I {imgui}' # romfs_config.h, vk_mem_alloc.h (+ deps headers), imgui.h libs = [f'-L {cmd_path(DEPS / "lib")}'] + LLVM_LINK_LIBS if DEPS else LINK_LIBS + # A compiler cache (sccache) may front clang: every lift rewrites the generated chunks with the same contents, so + # the cached objects save the compile step on the next build. + cache = f'{cmd_arg(os.environ["SCCACHE"])} ' if os.environ.get('SCCACHE') else '' lines = [ '# Written by tools/build_game.py; do not edit.', 'ninja_required_version = 1.10', f'builddir = {ninja_path(out)}', - f'cc = {cmd_arg(CLANG.as_posix())}', + f'cc = {cache}{cmd_arg(CLANG.as_posix())}', f'genflags = {" ".join(GEN_FLAGS)} {inc}', f'rtflags = {" ".join(RT_FLAGS)} {rt_inc}', f'ldflags = {" ".join(LINK_FLAGS)}',