feat(linker): TPC 支持 project.vpj 静态链接 .a/.obj
- Config.py 读取 linker.static_libs(相对 vpj 目录解析为绝对路径) - Phase2Translator 新增 static_libs 参数,并入 extra_link_files 参与链接(位于 -o 之后、-l 之前)
This commit is contained in:
1 parent
ca1e58f6fa
commit
e33792a9ad
2 files changed
+12
-2
No files matched your search
@@ -272,6 +272,10 @@ def main() -> None:
|
||||
linker_cmd: str | None = resolved.get('linker', {}).get('cmd')
|
||||
linker_flags: list[str] = resolved.get('linker', {}).get('flags', [])
|
||||
linker_output: str | None = resolved.get('linker', {}).get('output')
|
||||
# 显式静态链接文件列表(.a/.obj 等),相对 project.vpj 目录解析为绝对路径
|
||||
static_libs: list[str] = []
|
||||
for lib in resolved.get('linker', {}).get('static_libs', []) or []:
|
||||
static_libs.append(lib if os.path.isabs(lib) else os.path.normpath(os.path.join(project_dir, lib)))
|
||||
target_triple = resolved.get('target', {}).get('triple')
|
||||
target_datalayout = resolved.get('target', {}).get('datalayout')
|
||||
force_recompile_includes: bool = bool(resolved.get('options', {}).get('force_recompile_includes', False))
|
||||
@@ -300,7 +304,7 @@ def main() -> None:
|
||||
except:
|
||||
pass
|
||||
_vlog().info(f"includes.binary: 已清空 {precompiled_dir} ({cleared} 个文件)")
|
||||
trans: Phase2Translator = Phase2Translator(src, temp_dir, output_dir, compile_cmd=cc_cmd, compile_flags=cc_flags, linker_cmd=linker_cmd, linker_flags=linker_flags, linker_output=linker_output, include_dirs=project_include_dirs, target_triple=target_triple, target_datalayout=target_datalayout, force_recompile_includes=force_recompile_includes, asan_mode=args.asan)
|
||||
trans: Phase2Translator = Phase2Translator(src, temp_dir, output_dir, compile_cmd=cc_cmd, compile_flags=cc_flags, linker_cmd=linker_cmd, linker_flags=linker_flags, linker_output=linker_output, static_libs=static_libs, include_dirs=project_include_dirs, target_triple=target_triple, target_datalayout=target_datalayout, force_recompile_includes=force_recompile_includes, asan_mode=args.asan)
|
||||
trans.sha1_map = Load_sha1_map(temp_dir)
|
||||
trans.slice_level = slice_level
|
||||
trans.run()
|
||||
|
||||
@@ -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, 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, 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)
|
||||
@@ -556,6 +556,12 @@ class Phase2Translator:
|
||||
self.extra_link_files: list[str] = []
|
||||
self.extra_compile_files: list[str] = []
|
||||
self.extra_py_files: list[str] = []
|
||||
# project.vpj linker.static_libs:显式静态链接文件(.a/.obj),
|
||||
# 加入 extra_link_files 参与最终链接(位于 -o 之后、-l 库标志之前)。
|
||||
if static_libs:
|
||||
for lib in static_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 退出队列)
|
||||
|
||||
Reference in new issue
Block a user