feat(linker): TPC 支持 project.vpj linker.dynamic_libs 动态链接 .dll/.so(解析为绝对路径,作为链接输入文件)

This commit is contained in:
TermiNexus committed 2026-09-01 22:01:18 +08:00
1 parent af432b445a
commit 49631ccf9b
2 files changed
+14 -2

No files matched your search

+8 -1
View File
@@ -516,7 +516,7 @@ class Phase2Translator:
_include_sha1_cache: dict[str, str] = {}
_include_exist_cache: dict[str, bool] = {}
def __init__(self, src_root: str, temp_dir: str, output_dir: str, compile_cmd: str = 'llc', compile_flags: list[str] | None = None, linker_cmd: str | None = None, linker_flags: list[str] | None = None, linker_output: str | None = None, static_libs: list[str] | None = None, include_dirs: list[str] | None = None, entry_files: list[str] | None = None, target_triple: str | None = None, target_datalayout: str | None = None, force_recompile_includes: bool = False, build_pyi_cache: bool = True, asan_mode: bool = False) -> None:
def __init__(self, src_root: str, temp_dir: str, output_dir: str, compile_cmd: str = 'llc', compile_flags: list[str] | None = None, linker_cmd: str | None = None, linker_flags: list[str] | None = None, linker_output: str | None = None, static_libs: list[str] | None = None, dynamic_libs: list[str] | None = None, include_dirs: list[str] | None = None, entry_files: list[str] | None = None, target_triple: str | None = None, target_datalayout: str | None = None, force_recompile_includes: bool = False, build_pyi_cache: bool = True, asan_mode: bool = False) -> None:
self.src_root = os.path.abspath(src_root)
self.temp_dir = os.path.abspath(temp_dir)
self.output_dir = os.path.abspath(output_dir)
@@ -562,6 +562,13 @@ class Phase2Translator:
for lib in static_libs:
if lib not in self.extra_link_files:
self.extra_link_files.append(lib)
# project.vpj linker.dynamic_libs:显式动态链接文件(.dll/.so),
# 同样作为链接输入(GNU ld 从 DLL/SO 提取导入符号);运行时需
# DLL/SO 位于 exe 同目录 / PATH / LD_LIBRARY_PATH。
if dynamic_libs:
for lib in dynamic_libs:
if lib not in self.extra_link_files:
self.extra_link_files.append(lib)
self._include_sha1s: set[str] = set()
# 持有 ProcessPoolExecutor 引用,避免局部变量 GC 时 finalizer 阻塞 ~99s
# (join_executor_internals 在 GC 时同步等待 worker 退出队列)