From 36bfa4e061f6f6752216db86a8a8052274985b48 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Sat, 24 Oct 2026 22:31:10 +0800 Subject: [PATCH] =?UTF-8?q?fix(ffilib):=20runtime=3DTrue=20=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E6=8A=8A=E5=BA=93=E8=B7=AF=E5=BE=84=E5=86=99=E8=BF=9B?= =?UTF-8?q?=20dynamic=5Flibs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit runtime=True 的库由 thunk 在运行期按绝对路径 LoadLibraryA,若同时进 dynamic_libs 会成为链接输入、生成 PE 导入表依赖,既与 thunk 重复又会重新带回 exe 同目录/PATH 的限制。改为只登记句柄与路径。 --- App/lib/core/builtin/ViperBuild.vp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/App/lib/core/builtin/ViperBuild.vp b/App/lib/core/builtin/ViperBuild.vp index aec2135..829f855 100644 --- a/App/lib/core/builtin/ViperBuild.vp +++ b/App/lib/core/builtin/ViperBuild.vp @@ -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")