fix(build): ASan includes 缓存独立目录隔离
- Config: get_includes_binary_dir 支持可配置后缀(_inc_bin_suffix) - main: --asan 用 .binary_asan 独立缓存并清理,非 asan 复位 .binary - 修复 asan 插桩 obj 与非 asan obj 混链 → __asan_init undefined reference
This commit is contained in:
1 parent
b232c9266c
commit
1c7e8c2056
3 files changed
+38
-15
No files matched your search
@@ -40,6 +40,17 @@ StrictMode: t.CInt = 0
|
||||
IncludesDir: str = None # includes 目录路径(从 includes 数组首元素,兼容单目录场景)
|
||||
IncludesDirs: str = None # 全部 includes 目录(空格分隔,多 includes 目录支持)
|
||||
|
||||
# includes 预编译缓存目录后缀(asan 模式用 .binary_asan 隔离,避免
|
||||
# asan 插桩 obj 与非 asan obj 混链:asan obj 引用 __asan_init 等符号,
|
||||
# 非 asan 链接不提供 asan 库 → undefined reference)
|
||||
_inc_bin_suffix: str = ".binary"
|
||||
|
||||
|
||||
def set_inc_bin_suffix(suffix: str) -> None:
|
||||
"""设置 includes.binary 缓存目录后缀(如 ".binary_asan")"""
|
||||
global _inc_bin_suffix
|
||||
_inc_bin_suffix = suffix
|
||||
|
||||
|
||||
def Load_project_config(path: str) -> int:
|
||||
"""加载工程配置文件(project.vpj)
|
||||
@@ -451,17 +462,20 @@ def resolve_paths(project_dir: str) -> int:
|
||||
|
||||
|
||||
def get_includes_binary_dir() -> str:
|
||||
"""获取 includes.binary 目录路径(includes 目录 + .binary 后缀)
|
||||
"""获取 includes.binary 目录路径(includes 目录 + 缓存后缀)
|
||||
|
||||
includes 目录如 ../includes,则 includes.binary 为 ../includes.binary
|
||||
includes 目录如 ../includes,默认返回 ../includes.binary;
|
||||
asan 模式(set_inc_bin_suffix(".binary_asan"))返回 ../includes.binary_asan,
|
||||
隔离 asan 插桩 obj,避免与非 asan obj 混链。
|
||||
"""
|
||||
if IncludesDir is None:
|
||||
return None
|
||||
inc_len: t.CSizeT = string.strlen(IncludesDir)
|
||||
buf: str = _mbuddy.alloc(inc_len + 8)
|
||||
suf_len: t.CSizeT = string.strlen(_inc_bin_suffix)
|
||||
buf: str = _mbuddy.alloc(inc_len + suf_len + 1)
|
||||
if buf is None:
|
||||
return None
|
||||
viperlib.snprintf(buf, inc_len + 8, "%s.binary", IncludesDir)
|
||||
viperlib.snprintf(buf, inc_len + suf_len + 1, "%s%s", IncludesDir, _inc_bin_suffix)
|
||||
return buf
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user