| ... | @@ -25675,6 +25675,7 @@ fn zirBuiltinExtern( | ... | @@ -25675,6 +25675,7 @@ fn zirBuiltinExtern( |
| 25675 | extended: Zir.Inst.Extended.InstData, | 25675 | extended: Zir.Inst.Extended.InstData, |
| 25676 | ) CompileError!Air.Inst.Ref { | 25676 | ) CompileError!Air.Inst.Ref { |
| 25677 | const mod = sema.mod; | 25677 | const mod = sema.mod; |
| | 25678 | const ip = &mod.intern_pool; |
| 25678 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; | 25679 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| 25679 | const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node }; | 25680 | const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node }; |
| 25680 | const options_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node }; | 25681 | const options_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node }; |
| ... | @@ -25714,34 +25715,38 @@ fn zirBuiltinExtern( | ... | @@ -25714,34 +25715,38 @@ fn zirBuiltinExtern( |
| 25714 | const new_decl = mod.declPtr(new_decl_index); | 25715 | const new_decl = mod.declPtr(new_decl_index); |
| 25715 | new_decl.name = options.name; | 25716 | new_decl.name = options.name; |
| 25716 | | 25717 | |
| 25717 | { | 25718 | new_decl.src_line = sema.owner_decl.src_line; |
| 25718 | const new_var = try mod.intern(.{ .variable = .{ | 25719 | new_decl.ty = Type.fromInterned(ptr_info.child); |
| 25719 | .ty = ptr_info.child, | 25720 | new_decl.val = Value.fromInterned( |
| 25720 | .init = .none, | 25721 | if (Type.fromInterned(ptr_info.child).zigTypeTag(mod) == .Fn) |
| 25721 | .decl = sema.owner_decl_index, | 25722 | try ip.getExternFunc(sema.gpa, .{ |
| 25722 | .lib_name = options.library_name, | 25723 | .ty = ptr_info.child, |
| 25723 | .is_extern = true, | 25724 | .decl = new_decl_index, |
| 25724 | .is_const = ptr_info.flags.is_const, | 25725 | .lib_name = options.library_name, |
| 25725 | .is_threadlocal = options.is_thread_local, | 25726 | }) |
| 25726 | .is_weak_linkage = options.linkage == .Weak, | 25727 | else |
| 25727 | } }); | 25728 | try mod.intern(.{ .variable = .{ |
| 25728 | | 25729 | .ty = ptr_info.child, |
| 25729 | new_decl.src_line = sema.owner_decl.src_line; | 25730 | .init = .none, |
| 25730 | // We only access this decl through the decl_ref with the correct type created | 25731 | .decl = new_decl_index, |
| 25731 | // below, so this type doesn't matter | 25732 | .lib_name = options.library_name, |
| 25732 | new_decl.ty = Type.fromInterned(ptr_info.child); | 25733 | .is_extern = true, |
| 25733 | new_decl.val = Value.fromInterned(new_var); | 25734 | .is_const = ptr_info.flags.is_const, |
| 25734 | new_decl.alignment = .none; | 25735 | .is_threadlocal = options.is_thread_local, |
| 25735 | new_decl.@"linksection" = .none; | 25736 | .is_weak_linkage = options.linkage == .Weak, |
| 25736 | new_decl.has_tv = true; | 25737 | } }), |
| 25737 | new_decl.analysis = .complete; | 25738 | ); |
| 25738 | new_decl.generation = mod.generation; | 25739 | new_decl.alignment = .none; |
| 25739 | } | 25740 | new_decl.@"linksection" = .none; |
| | 25741 | new_decl.has_tv = true; |
| | 25742 | new_decl.owns_tv = true; |
| | 25743 | new_decl.analysis = .complete; |
| | 25744 | new_decl.generation = mod.generation; |
| 25740 | | 25745 | |
| 25741 | try sema.ensureDeclAnalyzed(new_decl_index); | 25746 | try sema.ensureDeclAnalyzed(new_decl_index); |
| 25742 | | 25747 | |
| 25743 | return Air.internedToRef((try mod.getCoerced(Value.fromInterned((try mod.intern(.{ .ptr = .{ | 25748 | return Air.internedToRef((try mod.getCoerced(Value.fromInterned((try mod.intern(.{ .ptr = .{ |
| 25744 | .ty = switch (mod.intern_pool.indexToKey(ty.toIntern())) { | 25749 | .ty = switch (ip.indexToKey(ty.toIntern())) { |
| 25745 | .ptr_type => ty.toIntern(), | 25750 | .ptr_type => ty.toIntern(), |
| 25746 | .opt_type => |child_type| child_type, | 25751 | .opt_type => |child_type| child_type, |
| 25747 | else => unreachable, | 25752 | else => unreachable, |