修复了一些问题

This commit is contained in:
TermiNexus committed 2026-09-17 14:52:37 +08:00
1 parent 43e7cdd2cc
commit 6af2dea917
16 files changed
+387 -288

No files matched your search

+16 -1
View File
@@ -2309,6 +2309,12 @@ class Phase2Translator:
break
final_lines2 = ll_content_no_types.splitlines(True)
ll_content = ''.join(final_lines2[:header_end]) + '\n'.join(final_type_defs) + '\n' + ''.join(final_lines2[header_end:])
# 写盘前先规整元数据:本文件的 IR 是「本模块 + 各依赖 .stub.ll/
# .text.ll 片段」拼接而成,每份片段都自带从 !0 起编号的 DI 元数据,
# 未规整直接落盘的话,任何读该文件的 opt/llc(含另一并发构建进程)
# 都会报 "Metadata id is already used"。规整后盘上产物本身即合法 IR,
# _llc_compile 内的规整随之成为幂等 no-op。
ll_content = SanitizeIRMetadata(ll_content)
dso_ll_path = ll_path[:-3] + '_dso.ll'
with open(dso_ll_path, 'w', encoding='utf-8') as f:
f.write(ll_content)
@@ -3127,6 +3133,9 @@ class Phase2Translator:
insert_pos = len(other_lines)
ll_content = ''.join(other_lines[:insert_pos]) + ''.join(type_def_lines) + ''.join(other_lines[insert_pos:])
# 同 App 路径:写盘前规整元数据(拼接片段各自带 !0..!N 的 DI 元数据),
# 让盘上产物本身即合法 IR,不依赖 _llc_compile 里那次事后规整。
ll_content = SanitizeIRMetadata(ll_content)
dso_ll_path = ll_path[:-3] + '_dso.ll'
with open(dso_ll_path, 'w', encoding='utf-8') as f:
f.write(ll_content)
@@ -3883,7 +3892,13 @@ SECTIONS {
_vlog().success(f" 生成: {exe_path}")
file_size = os.path.getsize(exe_path)
_vlog().info(f" [大小] {file_size} 字节")
if not is_binary:
# --dwarf 构建(含 --asan 自动开启)必须保留 DWARF:
# 该模式存在的唯一意义是崩溃时反查 ".vp:行",
# 而 _strip_debug_sections 会 llvm-strip --strip-debug 掉全部
# .debug_* 段(实测 exe 体积 13378048 → 11895296,
# llvm-symbolizer 对含 main 在内的所有地址返回 ??:0:0)。
# 非 dwarf 构建保持原有剥离行为(产物零变化)。
if not is_binary and not self.dwarf_enabled:
self._strip_debug_sections(exe_path)
else:
_vlog().error(f" 链接失败: {result.stderr.strip()}")