Builder: a warning for Linux before 6.7, compile jobs as many as the RAM holds, temporary files in the game folder

- hw_check.py kernel_old: below 6.7 the game has no write watch (userfaultfd WP_ASYNC, PAGEMAP_SCAN) and copies whole
  pools before each submission.
- build_game.py: jobs up to 80 % of the RAM at 768 MiB each (as totk-pc-recomp), within --cpus.
- setup.py on Linux: TMPDIR is temp/ of the game folder (a Steam Deck's /tmp is memory, /home small).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
kuraeowandClaude Opus 5.5 committed 2026-11-01 15:07:48 +03:00
1 parent d7eda2639b
commit 5c8589aee6
3 files changed
+32 -1

No files matched your search

+9 -1
View File
@@ -150,7 +150,7 @@ def main():
game_cflags = game_cflags.replace(' -gcodeview', '') + ' ' + linux_flags()
if arch != 'x86-64-v3':
print(f'code for {arch}: this CPU has no AVX2 / FMA / BMI2 (slower than x86-64-v3)', flush=True)
a.j = a.j or a.cpus
a.j = a.j or min(a.cpus, jobs_for_ram())
gen = ROOT / a.generated
bd = 'build-linux' if linux else 'build'
build = ROOT / bd
@@ -271,6 +271,14 @@ def main():
sys.exit(rc)
def jobs_for_ram():
"""As many clang processes as the memory holds: up to 768 MiB each, in 80 % of the RAM (as totk-pc-recomp's
build_game.py; the largest generated files take about that). 8 GB of RAM: 8, a Steam Deck's 16 GB: 16."""
import hw_check
ram = hw_check.ram_bytes()
return max(1, int(ram * 0.8) // (768 << 20)) if ram else 64
def run_limited(cmd, env, mask, on_line=None):
"""cmd at below-normal priority on the CPUs in mask; on_line(line): its output line by line instead of the console.
Linux: nice 10 and the CPUs set in the child before it starts, which every clang it starts inherits (as PR #42)."""
+18
View File
@@ -13,6 +13,7 @@ goes on; 'info': a remark. The launcher has the texts for the codes in its langu
vram_low gpu, gb warn less than 4 GB of video memory
ram_low gb warn less than 16 GB of RAM
cpu_no_avx2 warn the code is built for SSE4.2 (slower)
kernel_old version warn Linux below 6.7: no write watch for the game's memory (very slow)
disk_space need_gb, free_gb, drive block
amd_untested gpu info [temporary] AMD cards are not tested yet (dev-local/docs/issues.md, "#2, #16,
#23"): remove once players with RDNA report that the game runs
@@ -137,9 +138,25 @@ def cases(folder, platforms=('windows',)):
out.append({'code': 'ram_low', 'sev': 'warn', 'args': {'gb': round(ram / 2**30)}})
if not avx2():
out.append({'code': 'cpu_no_avx2', 'sev': 'warn', 'args': {}})
if os.name != 'nt' and kernel_version() < KERNEL_WRITE_WATCH: # the game is built where it runs
out.append({'code': 'kernel_old', 'sev': 'warn', 'args': {'version': os.uname().release}})
return out + disk_case(folder, 'linux' in platforms)
KERNEL_WRITE_WATCH = (6, 7) # userfaultfd write protection without faults (WP_ASYNC) and PAGEMAP_SCAN
def kernel_version():
"""Linux's version as numbers ((0, 0): unknown, as when not Linux). Below 6.7 the game has no write watch
(src/runtime/platform/linux.c): every pool the GPU uses is copied whole before each submission, very slow (as
totk-pc-recomp warns, installer/steps.py). SteamOS 3.8 and later have 6.11+."""
try:
parts = os.uname().release.split('-')[0].split('.')
return tuple(int(p) for p in parts[:2])
except (AttributeError, ValueError):
return (0, 0)
def text(case):
"""An English line for the console (the launcher has its own texts)."""
a = case['args']
@@ -153,6 +170,7 @@ def text(case):
'vram_low': f'{a.get("gpu")} has {a.get("gb")} GB of video memory; 4 GB or more is recommended',
'ram_low': f'this PC has {a.get("gb")} GB of RAM; 16 GB or more is recommended',
'cpu_no_avx2': 'the CPU lacks AVX2: the game is built for SSE4.2 and runs a little slower',
'kernel_old': f'Linux {a.get("version")}: 6.7 or newer is needed, else the game cannot track its memory writes and runs very slowly; update the system',
'disk_space': f'the build needs {a.get("need_gb")} GB on {a.get("drive")}, {a.get("free_gb")} GB is free',
'amd_untested': f'{a.get("gpu")}: AMD cards are not tested yet; please report how the game runs',
}.get(case['code'], case['code'])
+5
View File
@@ -657,6 +657,11 @@ def main():
state['platforms'] = PLATFORMS[a.platform]
state.setdefault('platforms', ['windows'])
if os.name != 'nt': # Linux builds the game for Linux, here
# The tools' temporary files in the game's folder (temp/): on a Steam Deck /tmp is memory and /home small
# (totk-pc-recomp's installer puts its temp folder beside the game for the same reason)
tmp = ROOT / 'temp'
tmp.mkdir(exist_ok=True)
os.environ['TMPDIR'] = str(tmp)
if a.platform and a.platform != 'linux':
fail_tools(deps_install.DepsError('on Linux UltraTears is built for Linux: --platform linux'))
state['platforms'] = ['linux']