From 50626565ba9dcf15d992ae9c23dd5c1a5ae000c7 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 22 Dec 2024 14:22:05 -0800 Subject: [PATCH] wasm linker: fix missing function type entry for import --- src/link/Wasm.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index 735d5ace54..39fe65f2e9 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -2449,6 +2449,7 @@ pub fn updateNav(wasm: *Wasm, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index const comp = wasm.base.comp; const gpa = comp.gpa; const is_obj = comp.config.output_mode == .Obj; + const target = &comp.root_mod.resolved_target.result; const nav_init, const chased_nav_index = switch (ip.indexToKey(nav.status.resolved.val)) { .func => return, // global const which is a function alias @@ -2465,6 +2466,9 @@ pub fn updateNav(wasm: *Wasm, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index try wasm.function_imports.ensureUnusedCapacity(gpa, 1); const zcu_import = wasm.addZcuImportReserved(ext.owner_nav); wasm.function_imports.putAssumeCapacity(name, .fromZcuImport(zcu_import, wasm)); + // Ensure there is a corresponding function type table entry. + const fn_info = zcu.typeToFunc(.fromInterned(ext.ty)).?; + _ = try internFunctionType(wasm, fn_info.cc, fn_info.param_types.get(ip), .fromInterned(fn_info.return_type), target); } else { @panic("TODO extern data"); }