fix(build): 统一 SHA1 口径消除符号前缀不一致(undefined reference)

- Phase2 App 源文件 SHA1 改用 IncludesScanner.compute_file_sha1(CRLF→LF 归一化), 与 StubMerger 对同一批文件口径一致; 此前用 Utils.compute_sha1(原始字节) 在 CRLF 文件上产生不同前缀
- compute_file_sha1 BUF_SIZE 128KB→1MB(与翻译侧 SRC_BUF_SIZE 一致), 消除大文件尾部变更不触发缓存失效
This commit is contained in:
TermiNexus committed 2026-08-09 22:54:32 +08:00
1 parent f63dcd7fed
commit 695699f01e
2 files changed
+8 -2

No files matched your search

+3 -1
View File
@@ -155,7 +155,9 @@ def compute_file_sha1(pool: memhub.MemBuddy | t.CPtr,
return None
# 读取文件内容(stdlib.malloc 分配,避免 mbuddy 池耗尽)
BUF_SIZE: t.CSizeT = 131072
# BUF_SIZE 与翻译侧 SRC_BUF_SIZE(1MB)一致:若截断到 128KB,
# 超过 128KB 的文件尾部内容变更不会改变 SHA1 → 增量缓存永不失效。
BUF_SIZE: t.CSizeT = 1048576
buf: bytes = Utils.read_file_to_buf(file_path, BUF_SIZE)
if buf is None:
return None
+5 -1
View File
@@ -124,7 +124,11 @@ def _ScanDirForPyFiles(mb: memhub.MemBuddy | t.CPtr,
if full_path is not None:
sbuf: bytes = Utils.read_file_to_buf(full_path, SRC_BUF_SIZE)
if sbuf is not None:
sha1_val: str = Utils.compute_sha1(mb, sbuf)
# 统一用 IncludesScanner.compute_file_sha1(CRLF→LF 归一化),
# 与 StubMerger.vp:1510 对同一批 App 源文件的口径一致;
# 此前用 Utils.compute_sha1(原始字节)会导致 stub/define
# 符号前缀不一致 → 链接报 undefined reference。
sha1_val: str = IncludesScanner.compute_file_sha1(mb, full_path)
if sha1_val is not None:
ea: t.CUInt64T = t.CUInt64T(entries) + file_count * entry_size
ent: SrcFileEntry | t.CPtr = (SrcFileEntry | t.CPtr)(t.CVoid(ea, t.CPtr))