| ... | @@ -249,6 +249,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { | ... | @@ -249,6 +249,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { |
| 249 | }; | 249 | }; |
| 250 | const is_obj = comp.config.output_mode == .Obj; | 250 | const is_obj = comp.config.output_mode == .Obj; |
| 251 | const allow_undefined = is_obj or wasm.import_symbols; | 251 | const allow_undefined = is_obj or wasm.import_symbols; |
| | 252 | const zcu_references = if (comp.zcu) |zcu| try zcu.resolveReferences() else null; |
| 252 | | 253 | |
| 253 | const entry_name = if (wasm.entry_resolution.isNavOrUnresolved(wasm)) wasm.entry_name else .none; | 254 | const entry_name = if (wasm.entry_resolution.isNavOrUnresolved(wasm)) wasm.entry_name else .none; |
| 254 | | 255 | |
| ... | @@ -1223,6 +1224,14 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { | ... | @@ -1223,6 +1224,14 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { |
| 1223 | try emitTagIndexFunction(wasm, binary_bytes, ip_index); | 1224 | try emitTagIndexFunction(wasm, binary_bytes, ip_index); |
| 1224 | }, | 1225 | }, |
| 1225 | else => { | 1226 | else => { |
| | 1227 | if (!zcu_references.?.contains(.wrap(.{ .func = ip_index }))) { |
| | 1228 | try binary_bytes.appendSlice(gpa, &.{ |
| | 1229 | 0, // no locals |
| | 1230 | @backingInt(std.wasm.Opcode.@"unreachable"), |
| | 1231 | @backingInt(std.wasm.Opcode.end), |
| | 1232 | }); |
| | 1233 | continue; |
| | 1234 | } |
| 1226 | const func = i.value(wasm).function; | 1235 | const func = i.value(wasm).function; |
| 1227 | const mir: Mir = .{ | 1236 | const mir: Mir = .{ |
| 1228 | .instructions = wasm.mir_instructions.slice().subslice(func.instructions_off, func.instructions_len), | 1237 | .instructions = wasm.mir_instructions.slice().subslice(func.instructions_off, func.instructions_len), |