修复了一些问题
This commit is contained in:
1 parent
cb0836de8a
commit
eb01a45024
7 files changed
+31
-37
No files matched your search
@@ -1343,8 +1343,6 @@ def RunMultiFileProject(mb: rawptr[memhub.MemBuddy],
|
||||
temp_dir, td_len_pb, store_sha1_arr_mi, store_mod_arr_mi)
|
||||
store_rel_arr_mi: bytes = StubMergerStore.GetSha1StoreRelArrPtr()
|
||||
store_incdir_arr_mi: bytes = StubMergerStore.GetSha1StoreIncdirArrPtr()
|
||||
# 诊断:_BuildIncludesSha1Map 复制的条目数(PhaseB+ 循环执行前提)
|
||||
VLogger.debug(f"诊断 store_count_mi={store_count_mi}", "PhaseB+")
|
||||
if store_count_mi > 0:
|
||||
|
||||
# 拓扑排序可达 includes:被依赖模块先完整翻译。跨模块 vtable 生成
|
||||
@@ -1359,15 +1357,6 @@ def RunMultiFileProject(mb: rawptr[memhub.MemBuddy],
|
||||
store_count_mi, store_sha1_arr_mi, store_mod_arr_mi,
|
||||
reachable_set, reachable_count, topo_idx)
|
||||
|
||||
# 诊断:拓扑排序条数(0 则循环不执行)
|
||||
VLogger.debug(f"诊断 topo_count={topo_count} reachable_count={reachable_count}", "PhaseB+")
|
||||
|
||||
# 诊断:dump reachable_set 内容(验证 BFS 写入的 sha1 是否有效)
|
||||
ri_dbg: int = 0
|
||||
for ri_dbg in range(reachable_count):
|
||||
rsha1_dbg: str = reachable_set + sizet(ri_dbg) * 17
|
||||
VLogger.debug(f"诊断 reachable[{ri_dbg}]={rsha1_dbg}", "PhaseB+")
|
||||
|
||||
for si_mi in range(topo_count):
|
||||
# 当前条目(拓扑序索引,仅含可达模块)
|
||||
ti: int = topo_idx[si_mi]
|
||||
@@ -1403,9 +1392,6 @@ def RunMultiFileProject(mb: rawptr[memhub.MemBuddy],
|
||||
stdlib.free(check_fd_mi)
|
||||
continue
|
||||
|
||||
# 诊断:obj 不存在,进入 is_decl 判定
|
||||
VLogger.debug(f"诊断 循环 si={si_mi} ti={ti} sha1={inc_sha1_mi} obj_exists={obj_exists_mi}", "PhaseB+")
|
||||
|
||||
# .obj 不存在,需要编译
|
||||
# 构造源文件路径: {所属 includes 根目录}/{rel_path}(多目录逐条取 IncDir,空串回退 includes_dir)
|
||||
rel_path_len_mi: sizet = string.strlen(inc_rel_mi)
|
||||
@@ -1419,8 +1405,7 @@ def RunMultiFileProject(mb: rawptr[memhub.MemBuddy],
|
||||
if check_fd_mi is not None:
|
||||
stdlib.free(check_fd_mi)
|
||||
VLogger.error("includes 源路径分配失败,终止编译", "PhaseB+")
|
||||
viperlib.snprintf(src_fp_mi, inc_dir_len_mi + 1 + rel_path_len_mi + 1,
|
||||
"%s/%s", incdir_mi, inc_rel_mi)
|
||||
viperlib.snprintf(src_fp_mi, inc_dir_len_mi + 1 + rel_path_len_mi + 1, "%s/%s", incdir_mi, inc_rel_mi)
|
||||
|
||||
# 检查是否为声明文件(只有 declare 没有实质 define)
|
||||
# 判断方法: text.ll 中若有混淆函数 define(含 @")则为实现文件
|
||||
@@ -1456,8 +1441,7 @@ def RunMultiFileProject(mb: rawptr[memhub.MemBuddy],
|
||||
stdlib.free(tbuf_mi)
|
||||
tf_mi.close()
|
||||
stdlib.free(tpath_mi)
|
||||
# 诊断:is_decl 判定结果
|
||||
VLogger.debug(f"诊断 is_decl={is_decl_mi} src={src_fp_mi}", "PhaseB+")
|
||||
|
||||
# is_decl_mi == -1: text.ll 不存在(Phase1 未翻译此文件)
|
||||
# is_decl_mi == 1: 声明文件(仅 declare 无 define)
|
||||
# is_decl_mi == 0: 实现文件(有 define)
|
||||
|
||||
@@ -752,6 +752,7 @@ def _AppendDepsToWorklist(worklist: bytes, wl_len: sizet,
|
||||
return -1
|
||||
stdlib.free(dmod)
|
||||
return int(cur_len)
|
||||
|
||||
# ============================================================
|
||||
# _BuildReachableSha1Set - 构建可达 SHA1 集合(依赖图按需扫描;未引用的 includes 从不读取)
|
||||
#
|
||||
@@ -886,8 +887,6 @@ def _BuildReachableSha1Set(mb: rawptr[memhub.MemBuddy], source_dir: str,
|
||||
worklist[wl_len - 1] = '\0'
|
||||
wl_len -= 1
|
||||
|
||||
VLogger.debug(f"源文件直接依赖: '{worklist}'", "Reachable")
|
||||
|
||||
# 2. 预加入基础模块(builtins)
|
||||
# builtins(内置函数模块)始终纳入编译链。_list/_dict 仅在显式
|
||||
# list/dict 注解/构造时经 _inject_auto_container_visibility 注入
|
||||
@@ -898,8 +897,6 @@ def _BuildReachableSha1Set(mb: rawptr[memhub.MemBuddy], source_dir: str,
|
||||
stdlib.free(worklist)
|
||||
return -1
|
||||
|
||||
VLogger.debug(f"预加入容器模块后: '{worklist}'", "Reachable")
|
||||
|
||||
# 3. 工作列表 BFS:模块名 → 文件系统解析 → 读+hash+parse import
|
||||
processed: bytes = stdlib.malloc(StubMerger.REACH_WORKLIST_BUF)
|
||||
if processed is None:
|
||||
@@ -986,7 +983,9 @@ def _BuildReachableSha1Set(mb: rawptr[memhub.MemBuddy], source_dir: str,
|
||||
# 输出槽防御性初始化(成功路径必全写;未找到/未命中时仅 free 槽本身)
|
||||
# 槽联合必须用 (sizet | t.CPtr):t.CPtr|t.CPtr 会被折叠成 t.CPtr,
|
||||
# [0] 变成 1 字节访问 → 指针被截断(0x2e 崩溃根因)。CSizeT 成员为
|
||||
# 8 字节,经 t\.CVoid 显式做 u64↔指针转换。
|
||||
# 8 字节:写侧 sizet(ptr),读侧必须用 (str | t.CPtr)(slot[0]) 做 u64→
|
||||
# 指针转换;str(slot[0]) 是内置"数字转字符串"(snprintf 到栈缓冲并返回
|
||||
# 该栈地址),拿到的是十进制文本+栈指针 → free 即 bad-free。
|
||||
abs_slot: sizet | t.CPtr = (sizet | t.CPtr)(out_abs)
|
||||
rel_slot: sizet | t.CPtr = (sizet | t.CPtr)(out_rel)
|
||||
inc_slot: sizet | t.CPtr = (sizet | t.CPtr)(out_inc)
|
||||
@@ -1002,9 +1001,9 @@ def _BuildReachableSha1Set(mb: rawptr[memhub.MemBuddy], source_dir: str,
|
||||
stdlib.free(out_inc)
|
||||
stdlib.free(mod_buf)
|
||||
continue
|
||||
abs_path: str = str(abs_slot[0])
|
||||
rel_path: str = str(rel_slot[0])
|
||||
inc_dir: str = str(inc_slot[0])
|
||||
abs_path: str = (str | t.CPtr)(abs_slot[0])
|
||||
rel_path: str = (str | t.CPtr)(rel_slot[0])
|
||||
inc_dir: str = (str | t.CPtr)(inc_slot[0])
|
||||
|
||||
# 读文件 + 计算 SHA1(CRLF→LF,与 IncludesScanner 一致)
|
||||
sha1_r2: str = IncludesScanner.compute_file_sha1(mb, abs_path)
|
||||
@@ -1183,8 +1182,6 @@ def _BuildReachableSha1Set(mb: rawptr[memhub.MemBuddy], source_dir: str,
|
||||
stdlib.free(worklist)
|
||||
stdlib.free(processed)
|
||||
stdlib.free(wl_pos)
|
||||
|
||||
VLogger.debug(f"可达 SHA1: {reachable_count} 个", "Reachable")
|
||||
return reachable_count
|
||||
|
||||
# ============================================================
|
||||
|
||||
@@ -77,10 +77,8 @@ def BuildTopoSortedIndices(store_count: int, store_sha1_arr: bytes,
|
||||
if StubMergerCollect._is_in_sha1_set(store_sha1_arr + sizet(i_t) * 17, reachable_set, reachable_count) != 0:
|
||||
rel_idx[rel_count] = i_t
|
||||
rel_count += 1
|
||||
# 诊断:可达 store 索引数(rel_count=0 → topo_count=0 → PhaseB+ 循环不执行)
|
||||
VLogger.debug(f"诊断 topo rel_count={rel_count}", "StubMergerTopo")
|
||||
|
||||
# 计算入度:m 在可达集合内的直接依赖数
|
||||
i_r: int
|
||||
for i_r in range(rel_count):
|
||||
si: int = rel_idx[i_r]
|
||||
deps_si: str = StubMergerStore.LookupIncludesDeps(store_sha1_arr + sizet(si) * 17)
|
||||
|
||||
@@ -2637,7 +2637,7 @@ class AssignGenMixin:
|
||||
mro_ptr: sizet | t.CPtr = self.Gen.StructGen.get_mro_chain(pool, class_name)
|
||||
mi: int = 1
|
||||
while mro_ptr is not None and mro_ptr[mi] != 0:
|
||||
anc: str = (str | t.CPtr)(t.CVoid(mro_ptr[mi], t.CPtr))
|
||||
anc: str = (str | t.CPtr)(mro_ptr[mi])
|
||||
if anc is not None:
|
||||
anc_lookup: str = pool.alloc(128)
|
||||
if anc_lookup is not None:
|
||||
|
||||
@@ -62,10 +62,10 @@ class CallGenBase:
|
||||
CexportFuncArr: bytes
|
||||
CexportCount: int
|
||||
|
||||
# --- LLVMIR 寄存器序号(原 _g_llvmir_reg_seq) ---
|
||||
# --- LLVMIR 寄存器序号 ---
|
||||
LLVMIRRegSeq: int
|
||||
|
||||
# --- temp 目录(原 _g_temp_dir/_g_temp_dir_len) ---
|
||||
# --- temp 目录 ---
|
||||
TempDir: str
|
||||
TempDirLen: sizet
|
||||
|
||||
|
||||
@@ -641,7 +641,7 @@ class StructGenMixin:
|
||||
return None
|
||||
string.memset(dst_c, 0, ast.Constant.__sizeof__())
|
||||
# 拷贝 vtable 指针(AST 是 @t.CVTable,kind() 虚调用依赖首字段 vptr)
|
||||
vt_ptr: t.CPtr = c.Deref((uint64 | t.CPtr)(default_val))
|
||||
vt_ptr: t.CPtr = t.CPtr(c.Deref((uint64 | t.CPtr)(default_val)))
|
||||
c.DerefAs(dst_c, vt_ptr)
|
||||
# 拷贝位置字段(报错定位用)
|
||||
dst_c.lineno = src_c.lineno
|
||||
|
||||
+17
-2
@@ -6,11 +6,26 @@
|
||||
"build_dir": "./.tpv_build",
|
||||
"compiler": {
|
||||
"cmd": "llc",
|
||||
"flags": ["-filetype=obj", "-relocation-model=pic"]
|
||||
"flags": [
|
||||
"-filetype=obj",
|
||||
"-relocation-model=pic",
|
||||
"-O0"
|
||||
]
|
||||
},
|
||||
"linker": {
|
||||
"cmd": "D:/msys64/mingw64/bin/clang++.exe",
|
||||
"flags": ["-fuse-ld=lld", "-lmsvcrt", "-lucrt", "-lpthread", "-lmingwex", "-lkernel32", "-Wl,--allow-multiple-definition", "-Wl,--stack,0x1000000", "-Wl,--no-insert-timestamp"],
|
||||
"flags": [
|
||||
"-fuse-ld=lld",
|
||||
"-lmsvcrt",
|
||||
"-lucrt",
|
||||
"-lpthread",
|
||||
"-lmingwex",
|
||||
"-lkernel32",
|
||||
"-Wl,--allow-multiple-definition",
|
||||
"-Wl,--stack,0x1000000",
|
||||
"-Wl,--no-insert-timestamp",
|
||||
"-g"
|
||||
],
|
||||
"static_libs": [
|
||||
"D:/msys64/clang64/lib/clang/22/lib/windows/libclang_rt.asan_dynamic-x86_64.dll.a",
|
||||
"D:/msys64/clang64/lib/clang/22/lib/windows/libclang_rt.asan_dynamic_runtime_thunk-x86_64.a"
|
||||
|
||||
Reference in new issue
Block a user