fix(ffilib): runtime=True 不再把库路径写进 dynamic_libs

runtime=True 的库由 thunk 在运行期按绝对路径 LoadLibraryA,若同时进 dynamic_libs 会成为链接输入、生成 PE 导入表依赖,既与 thunk 重复又会重新带回 exe 同目录/PATH 的限制。改为只登记句柄与路径。
This commit is contained in:
TermiNexus committed 2026-10-24 22:31:10 +08:00
1 parent 0acbefafd8
commit 36bfa4e061
1 file changed
+5 -4
+5 -4
View File
@@ -1056,9 +1056,10 @@ def _HandleCDLL(node: ast.AST*, handle: str) -> int:
VLogger.error("ffilib: CDLL(path) needs a constant runtime=True/False, or use Project.StaticLib/DynamicLib", "ffilib")
return 1
if rt == 1:
rc_d: int = _AppendLibPath(1, c1.str_val)
if rc_d == 0: _RegisterFfiHandle(handle, 1, c1.str_val)
return rc_d
# runtime=True:不进链接输入(运行期由 thunk 用绝对路径 LoadLibraryA),
# 只登记句柄与路径;否则会同时生成导入表依赖,与 thunk 重复。
_RegisterFfiHandle(handle, 1, c1.str_val)
return 0
rc_s: int = _AppendLibPath(0, c1.str_val)
if rc_s == 0: _RegisterFfiHandle(handle, 0, c1.str_val)
return rc_s
@@ -1443,7 +1444,7 @@ def DiscoverAndApply(mb: memhub.MemBuddy*, entry_path: str) -> int:
"""Pass 0 for --src: discover and apply viperbuild config; 0=success, else failed."""
global _scratch, _work, _visited, _pending, _proj_vars, _entry_dir, _applied
global _search_dirs
global _ffi_handles_names, _ffi_handles_rt
global _ffi_handles_path, _ffi_handles_names, _ffi_handles_rt
if mb is None or entry_path is None:
VLogger.error("viperbuild: argument is null", "viperbuild")