From ecfa47bd3c8e1df9219512f1728202f91f521d3f Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Wed, 26 Aug 2026 22:44:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(callgen):=20=E8=B7=A8=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E8=A3=B8=E5=90=8D=20CExport=20=E8=B0=83=E7=94=A8=E7=B2=BE?= =?UTF-8?q?=E7=A1=AE=E8=A7=A3=E6=9E=90=E8=BF=94=E5=9B=9E=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=EF=BC=8C=E4=BE=9D=E8=B5=96=E6=9C=AA=E7=BC=96=E8=AF=91=E6=97=B6?= =?UTF-8?q?=20=5Fdeps=5Fpending=20=E9=87=8D=E8=AF=95=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=20malloc=20=E8=BF=94=E5=9B=9E=E6=88=AA=E6=96=AD=20i32?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/lib/core/Gen/CallGenMixin.vp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/App/lib/core/Gen/CallGenMixin.vp b/App/lib/core/Gen/CallGenMixin.vp index 9c4a418..9f51677 100644 --- a/App/lib/core/Gen/CallGenMixin.vp +++ b/App/lib/core/Gen/CallGenMixin.vp @@ -746,6 +746,27 @@ class CallGenMixin(CallGenBase.CallGenBase): llvmlite.Ptr(pool, llvmlite.Int8(pool))) if vpi_ret_ty is not None: call_ret_ty = vpi_ret_ty + elif mod_ret_sha1 is not None: + # 跨模块裸名 CExport 函数(如 mm.malloc → @malloc):found_func=None + # 且 vpi 返回注解缓存未命中时,仍从依赖模块 text.ll/vpi 精确解析 + # 返回类型(对齐 mangled 路径),避免静默默认 i32 截断指针/i64 + # (uhci.vp mm.malloc 根因:call i32 @malloc 截断 0xbb69000 → null)。 + # 依赖模块尚未编译(text.ll/vpi 均未生成)→ 标记 _deps_pending=1 + # 下遍重试,本遍保持默认类型(Phase A 多遍收敛)。 + cross_ret: llvmlite.LLVMType | t.CPtr = None + if trans is not None and trans._declare_only == 0: + cross_ret = self._LookupMethodRetTyFromTextLL( + pool, mod_ret_sha1, None, func_name, 1) + if cross_ret is None: + cross_ret = self._lookup_method_ret_ty_via_vpi( + pool, mod_ret_sha1, None, func_name) + if cross_ret is not None: + call_ret_ty = cross_ret + else: + if trans is not None and trans._declare_only == 0: + if self._dep_text_ll_exists(pool, mod_ret_sha1) == 0: + trans._deps_pending = 1 + call_ret_ty = self.Gen.CallGenLib._infer_external_func_ret_ty(pool, func_name) else: call_ret_ty = self.Gen.CallGenLib._infer_external_func_ret_ty(pool, func_name)