From d4fc66fe3c06c1d2aa7f8c1ed0fbd49573af1c91 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Sun, 18 Oct 2026 22:13:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(link):=20=5Fmerged.obj=20=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E6=97=B6=E4=BB=8D=E9=93=BE=E6=8E=A5=20include=20=E7=9A=84=20.o?= =?UTF-8?q?bj?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _merged.obj 只合并非 include 模块;此前命中该分支后跳过 include 的 .obj,导致 argparse.print_help 等符号未链接进 exe。 --- lib/Projectrans/Phase2Translator.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/Projectrans/Phase2Translator.py b/lib/Projectrans/Phase2Translator.py index 6971b1e..dcff7a9 100644 --- a/lib/Projectrans/Phase2Translator.py +++ b/lib/Projectrans/Phase2Translator.py @@ -4913,15 +4913,21 @@ class Phase2Translator: """将 active_sha1s 对应的 .obj 文件和 includes 库文件链接为可执行文件""" obj_files = [] merged_obj = os.path.join(self.output_dir, '_merged.obj') - if _CachedIsFile(merged_obj): + has_merged: bool = _CachedIsFile(merged_obj) + if has_merged: + # _merged.obj 只合并了非 include 模块,include 的 .obj 仍需单独链接 obj_files.append(merged_obj) - else: - for root, dirs, files in os.walk(self.output_dir): - for file in files: - if file.endswith('.obj'): - sha1 = file[:-4] - if sha1 in active_sha1s and sha1 not in self._include_sha1s: - obj_files.append(os.path.join(root, file)) + for root, dirs, files in os.walk(self.output_dir): + for file in files: + if file.endswith('.obj'): + sha1 = file[:-4] + if sha1 not in active_sha1s: + continue + if has_merged and sha1 not in self._include_sha1s: + continue + if not has_merged and sha1 in self._include_sha1s: + continue + obj_files.append(os.path.join(root, file)) if not obj_files and not self.extra_link_files: _vlog().info("[链接] 无文件可链接")