fix(func): extern def 使用裸名并登记跨模块

extern def longjmp/_setjmp/GetEnvironmentVariableA 等不再加 SHA1 前缀;声明加入 _export_funcs 与 _export_extern_funcs,链接可解析到 C/系统符号。
This commit is contained in:
TermiNexus committed 2026-10-18 22:44:57 +08:00
1 parent 0beb8f5e55
commit c2dc9927ef
1 file changed
+5 -1
+5 -1
View File
@@ -1194,9 +1194,13 @@ class FunctionHandle(BaseHandle):
self.Trans.LogWarning(f"异常被忽略: {_e}")
# 装饰器形式的存储类标记(@CExport / @CExtern / @State 等)
deco_flags: dict[str, bool] = self._extract_decorator_storage_flags(Node)
if deco_flags['is_export'] or deco_flags['is_extern'] or deco_flags['is_state']:
_is_extern_node: bool = (bool(getattr(Node, 'Extern', False))
or 'extern' in (getattr(Node, 'Markers', None) or ()))
if deco_flags['is_export'] or deco_flags['is_extern'] or deco_flags['is_state'] or _is_extern_node:
Gen._export_funcs.add(FuncName)
IsUserMarkedExport = True
if _is_extern_node:
Gen._export_extern_funcs[FuncName] = getattr(Gen, 'module_sha1', '') or ''
# 注册当前模块定义的函数名,使 _mangle_func_name 跳过 _export_extern_funcs 检查
# (_export_extern_funcs 是跨模块共享集合,包含所有 CExtern 函数名;当前模块定义的
# 同名用户函数应使用 SHA1 前缀,而非被误判为外部 C 函数返回裸名)