Name the other program that holds totk.exe when the setup cannot link it

When ld.lld cannot write the totk.exe it links in the setup's temp build folder (Permission denied), the setup
showed only "Compiling totk.exe failed". In #1122 the holder was an antivirus that flagged the new exe, not a
running game. The compile step now recognises that failure in the build log and says what to do: close the game,
exclude the setup's and the install folder from the antivirus, restart Windows and run the setup again. Texts in
en, ru, pt-BR and zh-Hans; build_game.py's own line names the antivirus too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
itaskaev2andClaude Opus 5.5 committed 2026-11-12 11:17:51 +01:00
1 parent b6c5d37fb7
commit f854d67e6f
7 files changed
+70 -1

No files matched your search

+13
View File
@@ -140,6 +140,17 @@ def linux_kernel():
return (int(m.group(1)), int(m.group(2))) if m else None
def link_output_locked(log):
"""Whether a build failed because another program holds the exe the linker writes: ld.lld cannot write it and clang
cannot remove it (Permission denied). A game started from the temp build folder does that, and so does an
antivirus that flagged or quarantined the new totk.exe there (#1122)."""
try:
text = Path(log).read_text(encoding='utf-8', errors='replace')
except OSError:
return False
return 'failed to write output' in text and 'Permission denied' in text
def run_tool(ctx, step, script, args, parse=None, cwd=None):
"""Run a tool script with the bundled Python. Its output goes to <temp>/logs/<step>-<script>.log and, line by line,
to parse(line). Returns (exit code, log path)."""
@@ -1009,6 +1020,8 @@ class Compile(Step):
'--exefs', dest / 'exefs', '--romfs', dest / 'romfs',
'--profile', dest / 'profile'], parse)
exe = build / ('totk' + EXE)
if code and link_output_locked(log):
raise InstallError('compile.exe_locked', path=str(exe), log=str(log))
if code or not exe.is_file():
raise InstallError('compile.failed', code=code, log=str(log))
try:
+1
View File
@@ -93,6 +93,7 @@
"lift.failed": "Translating the game code failed (exit code {code}). Details: {log}",
"compile.failed": "Compiling {game_exe} failed (exit code {code}). Details: {log}",
"compile.exe_in_use": "{path} is in use. Close the game and run the installer again.",
"compile.exe_locked": "{path} cannot be written: another program holds it, a game started from that folder or an antivirus that flagged the file. Close the game, add the setup's folder and the install folder to the antivirus exclusions, restart Windows, then run the installer again. Details: {log}",
"prepare.xlate_in_use": "{path} is in use. Close the game, end any totk_xlate process left from an earlier run, then run the installer again.",
"prepare.shader_list_missing": "The shader list is missing.",
"prepare.romfs_patches_failed": "Writing the game data patches failed (exit code {code}). Details: {log}",
+1
View File
@@ -93,6 +93,7 @@
"lift.failed": "Falha ao traduzir o código do jogo (código de saída {code}). Detalhes: {log}",
"compile.failed": "Falha ao compilar o {game_exe} (código de saída {code}). Detalhes: {log}",
"compile.exe_in_use": "{path} está em uso. Feche o jogo e execute o instalador de novo.",
"compile.exe_locked": "Não é possível gravar {path}: outro programa o está usando, um jogo aberto dessa pasta ou um antivírus que marcou o arquivo. Feche o jogo, adicione a pasta do instalador e a pasta de instalação às exceções do antivírus, reinicie o Windows e execute o instalador de novo. Detalhes: {log}",
"prepare.xlate_in_use": "{path} está em uso. Feche o jogo, encerre qualquer processo totk_xlate que tenha sobrado de uma execução anterior e execute o instalador de novo.",
"prepare.shader_list_missing": "A lista de shaders está faltando.",
"prepare.romfs_patches_failed": "Falha ao gravar os patches nos dados do jogo (código de saída {code}). Detalhes: {log}",
+1
View File
@@ -93,6 +93,7 @@
"lift.failed": "Не удалось перевести код игры (код выхода {code}). Подробности: {log}",
"compile.failed": "Не удалось собрать {game_exe} (код выхода {code}). Подробности: {log}",
"compile.exe_in_use": "Файл {path} занят. Закройте игру и запустите установку снова.",
"compile.exe_locked": "Файл {path} не удаётся записать: его держит другая программа — игра, запущенная из этой папки, или антивирус, который пометил файл. Закройте игру, добавьте папку установщика и папку установки в исключения антивируса, перезагрузите Windows и запустите установку снова. Подробности: {log}",
"prepare.xlate_in_use": "Файл {path} занят. Закройте игру, завершите процесс totk_xlate, оставшийся от прошлого запуска, и запустите установку снова.",
"prepare.shader_list_missing": "Нет списка шейдеров.",
"prepare.romfs_patches_failed": "Не удалось записать патчи данных игры (код выхода {code}). Подробности: {log}",
+1
View File
@@ -93,6 +93,7 @@
"lift.failed": "游戏代码转换失败(退出代码 {code})。详情:{log}",
"compile.failed": "编译 {game_exe} 失败(退出代码 {code})。详情:{log}",
"compile.exe_in_use": "{path} 正在使用中。请关闭游戏后重新运行安装程序。",
"compile.exe_locked": "无法写入 {path}:另一个程序正在占用它,可能是从该文件夹启动的游戏,或标记了该文件的杀毒软件。请关闭游戏,将安装程序文件夹和安装文件夹加入杀毒软件的排除项,重启 Windows,然后重新运行安装程序。详情:{log}",
"prepare.xlate_in_use": "{path} 正在被占用。请关闭游戏,结束上次残留的 totk_xlate 进程,再重新运行安装程序。",
"prepare.shader_list_missing": "缺少着色器列表。",
"prepare.romfs_patches_failed": "写入游戏数据补丁失败(退出代码 {code})。详情:{log}",
+51
View File
@@ -384,6 +384,57 @@ class LiftRunTest(unittest.TestCase):
self.assertIn('warn.exefs_skipped', self.ctx.reporter.out.getvalue())
class CompileLockedTest(unittest.TestCase):
"""Compile.run when the linker cannot write its totk.exe: another program holds the file (a game started from the
temp build folder, an antivirus that quarantined it), which gets its own message instead of the plain failure."""
LLD = ("ld.lld: error: failed to write output 'temp/totk-1/build/totk.exe': Permission denied\n"
"clang-23: error: unable to remove file: Permission denied\n")
def setUp(self):
tmp = tempfile.TemporaryDirectory()
self.addCleanup(tmp.cleanup)
base = Path(tmp.name)
dest, temp = base / 'install', base / 'temp'
dest.mkdir()
temp.mkdir()
layout = SimpleNamespace(tools=ROOT / 'tools', llvm=base / 'llvm', deps=None, sysroot=None, runtime=base,
ninja=base / 'ninja', dlls=[], runtime_lib_for=lambda cpu: None,
pgo=lambda version: None, expected=lambda version: base / 'expected.json')
self.ctx = SimpleNamespace(dest=dest, temp=temp, layout=layout, state={'version': '1.4.3'},
reporter=Reporter(out=io.StringIO()))
self.addCleanup(self.ctx.reporter.close)
self.log_text = ''
saved = steps.run_tool
self.addCleanup(lambda: setattr(steps, 'run_tool', saved))
steps.run_tool = self.run_tool
def run_tool(self, ctx, step, script, args, parse=None, cwd=None):
log = ctx.temp / 'compile.log'
log.write_text(self.log_text, encoding='utf-8')
return 1, log
def test_locked_link_output(self):
self.log_text = 'link: 0.8 s\n' + self.LLD
with self.assertRaises(steps.InstallError) as e:
steps.Compile().run(self.ctx)
self.assertEqual(e.exception.id, 'compile.exe_locked')
self.assertTrue(e.exception.params['path'].endswith('totk' + steps.EXE))
def test_other_failure(self):
self.log_text = 'runtime/x.c:1:1: error: expected expression\n'
with self.assertRaises(steps.InstallError) as e:
steps.Compile().run(self.ctx)
self.assertEqual(e.exception.id, 'compile.failed')
def test_message_in_every_language(self):
for path in sorted((ROOT / 'installer' / 'text').glob('*.json')):
text = json.loads(path.read_text(encoding='utf-8'))
self.assertIn('compile.exe_locked', text, path.name)
self.assertIn('{path}', text['compile.exe_locked'], path.name)
self.assertIn('{log}', text['compile.exe_locked'], path.name)
class IniTest(unittest.TestCase):
EXAMPLE = '[display]\n# vk_present = mailbox\n\n[language]\n# locale = en-US\n# lang = en-US\n# x = 1\n'
+2 -1
View File
@@ -982,7 +982,8 @@ def main():
code, dt, peak_one, _ = run_measured(base + [flag_path(exe)], env)
print(f'link: {dt:.1f} s, peak {mib(peak_one)}')
if code:
print(f'build_game: link failed, {flag_path(exe)} is the old one (a running totk.exe from this dir locks it)',
print(f'build_game: link failed, {flag_path(exe)} is the old one (a running totk.exe from this dir, or an '
f'antivirus that holds the file, locks it)',
file=sys.stderr)
sys.exit(code)
if args.make_runtime_lib: