chore(ffilib): 临时探针(CDLL 抽取 + extern 分支的 ffi_lib/runtime)

现象与"exe 已含最新提交"矛盾:add_c2 仍生成全局、@add 无 thunk、无 _ffilib 引用。加两处 printf 定位断点:_HandleCDLL 入口打印句柄名;translate_function_def 的 extern 分支打印 fd.ffi_lib 与 FfiHandleRuntime 结果。定位后立即移除。
This commit is contained in:
TermiNexus committed 2026-10-24 22:51:31 +08:00
1 parent c765cfa9d4
commit 1508563f1c
2 files changed
+6

No files matched your search

+4
View File
@@ -767,10 +767,14 @@ novirtual class FuncGenDef(CallGenBase.CallGenBase):
if (has_export != 0 or has_state != 0) and trans.ModuleSha1 is not None: self.Gen.CallGenBase.register_cexport_func(trans.ModuleSha1, fd.name)
if is_extern_decl != 0:
stdio.printf("[ffiprobe] extern branch '%s' ffi_lib=%s\n", fd.name, "nil" if fd.ffi_lib is None else fd.ffi_lib)
stdio.fflush(None)
# extern <lib> name(...):runtime=True 在这里也生成 thunk(Phase A 的 extern 往往不走
# forward_declare_functions,两处都挂才覆盖全部路径;另一处靠 find_func_in_module 去重)。
if fd.ffi_lib is not None:
ffi_rt_d: int = ViperBuild.FfiHandleRuntime(fd.ffi_lib)
stdio.printf("[ffiprobe] extern '%s' rt=%d\n", fd.name, ffi_rt_d)
stdio.fflush(None)
if ffi_rt_d < 0:
self.Gen.TypeGenErr.fatal_error(fd, f"extern library handle '{fd.ffi_lib}' is not a ffilib.CDLL binding (declare it with ffilib.CDLL(...) first)", "NameError")
return 0
+2
View File
@@ -988,6 +988,8 @@ def _AssignTargetName(asn: ast.Assign*) -> str:
# _HandleCDLL - 按实参形态写入静态/动态库表;list 回退形式本期 fail-fast
def _HandleCDLL(node: ast.AST*, handle: str) -> int:
"""抽取 ffilib.CDLL(...):0=成功"""
stdio.printf("[ffiprobe] _HandleCDLL enter handle=%s\n", "?" if handle is None else handle)
stdio.fflush(None)
if node is None or node.kind() != ast.ASTKind.Call: return 0
call: ast.Call* = ast.Call*(node)
args: list[ast.AST*]* = call.args