From c02aa3a2eb7af7a726a31541ccd0bf23160fef3f Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Thu, 8 Oct 2026 21:43:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(gen):=20@life/@willFree=20=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E8=A2=AB=E5=BD=93=E4=BD=9C=E8=BF=90=E8=A1=8C=E6=97=B6?= =?UTF-8?q?=E8=A3=85=E9=A5=B0=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 自定义装饰器检测(__decor_wrap_ 生成路径)此前把 P2 的编译期标注当成 User 装饰器:会生成 wrapper 调用并不存在的 @life/@willFree,并把被装饰的 extern def(如 stdlib.free)变成本模块 internal 声明,llc 报 invalid linkage for function declaration。把 life/willFree 加入该处标记白名单。 --- App/lib/core/Gen/Func/FuncGenDef.vp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/App/lib/core/Gen/Func/FuncGenDef.vp b/App/lib/core/Gen/Func/FuncGenDef.vp index 0395551..8a836bd 100644 --- a/App/lib/core/Gen/Func/FuncGenDef.vp +++ b/App/lib/core/Gen/Func/FuncGenDef.vp @@ -367,7 +367,11 @@ novirtual class FuncGenDef(CallGenBase.CallGenBase): if string.strcmp(dname, "staticmethod") == 0 or string.strcmp(dname, "property") == 0 or string.strcmp(dname, "classmethod") == 0: continue # Skip t-module storage markers (@t.CExport/@t.CExtern/@t.State/@t.TLS/@t.CStatic/@t.CInline/@t.CVTable/ # @t.NoVTable/@t.Object/@t.CEnum/@t.CUnion/@t.REnum/@t.CDefine). Attribute-form @t.xxx is not handled here. - if string.strcmp(dname, "CExport") == 0 or string.strcmp(dname, "CExtern") == 0 or string.strcmp(dname, "State") == 0 or string.strcmp(dname, "TLS") == 0 or string.strcmp(dname, "CStatic") == 0 or string.strcmp(dname, "CInline") == 0 or string.strcmp(dname, "CVTable") == 0 or string.strcmp(dname, "NoVTable") == 0 or string.strcmp(dname, "Object") == 0 or string.strcmp(dname, "CEnum") == 0 or string.strcmp(dname, "CUnion") == 0 or string.strcmp(dname, "REnum") == 0 or string.strcmp(dname, "CDefine") == 0: + # 另跳过**编译期生命期标注**(P2:规范形式 @life(willFree(...)) 与兼容叠加形式 @willFree(...)): + # 它们是纯标注、没有运行时装饰器函数。漏在这里会让 TPV 生成 __decor_wrap_ wrapper, + # 去调用并不存在的 @life/@willFree,并把被装饰的 extern def(如 stdlib.free)变成 internal 声明 + # (现场:llc 报 "invalid linkage for function declaration")。 + if string.strcmp(dname, "CExport") == 0 or string.strcmp(dname, "CExtern") == 0 or string.strcmp(dname, "State") == 0 or string.strcmp(dname, "TLS") == 0 or string.strcmp(dname, "CStatic") == 0 or string.strcmp(dname, "CInline") == 0 or string.strcmp(dname, "CVTable") == 0 or string.strcmp(dname, "NoVTable") == 0 or string.strcmp(dname, "Object") == 0 or string.strcmp(dname, "CEnum") == 0 or string.strcmp(dname, "CUnion") == 0 or string.strcmp(dname, "REnum") == 0 or string.strcmp(dname, "CDefine") == 0 or string.strcmp(dname, "life") == 0 or string.strcmp(dname, "willFree") == 0: continue has_custom_decor = 1 decor_handler = dname