| ... | ... | @@ -25989,41 +25989,35 @@ fn zirBuiltinExtern( |
| 25989 | 25989 | } |
| 25990 | 25990 | const ptr_info = ty.ptrInfo(mod); |
| 25991 | 25991 | |
| 25992 | | // TODO check duplicate extern |
| 25993 | | |
| 25994 | 25992 | const new_decl_index = try mod.allocateNewDecl(sema.owner_decl.src_namespace, sema.owner_decl.src_node); |
| 25995 | 25993 | errdefer mod.destroyDecl(new_decl_index); |
| 25996 | 25994 | const new_decl = mod.declPtr(new_decl_index); |
| 25997 | | new_decl.name = options.name; |
| 25998 | | |
| 25999 | | new_decl.src_line = sema.owner_decl.src_line; |
| 26000 | | new_decl.ty = Type.fromInterned(ptr_info.child); |
| 26001 | | new_decl.val = Value.fromInterned( |
| 26002 | | if (Type.fromInterned(ptr_info.child).zigTypeTag(mod) == .Fn) |
| 26003 | | try ip.getExternFunc(sema.gpa, .{ |
| 26004 | | .ty = ptr_info.child, |
| 26005 | | .decl = new_decl_index, |
| 26006 | | .lib_name = options.library_name, |
| 26007 | | }) |
| 26008 | | else |
| 26009 | | try mod.intern(.{ .variable = .{ |
| 26010 | | .ty = ptr_info.child, |
| 26011 | | .init = .none, |
| 26012 | | .decl = new_decl_index, |
| 26013 | | .lib_name = options.library_name, |
| 26014 | | .is_extern = true, |
| 26015 | | .is_const = ptr_info.flags.is_const, |
| 26016 | | .is_threadlocal = options.is_thread_local, |
| 26017 | | .is_weak_linkage = options.linkage == .Weak, |
| 26018 | | } }), |
| 26019 | | ); |
| 26020 | | new_decl.alignment = .none; |
| 26021 | | new_decl.@"linksection" = .none; |
| 26022 | | new_decl.has_tv = true; |
| 25995 | try mod.initNewAnonDecl(new_decl_index, sema.owner_decl.src_line, .{ |
| 25996 | .ty = Type.fromInterned(ptr_info.child), |
| 25997 | .val = Value.fromInterned( |
| 25998 | if (Type.fromInterned(ptr_info.child).zigTypeTag(mod) == .Fn) |
| 25999 | try ip.getExternFunc(sema.gpa, .{ |
| 26000 | .ty = ptr_info.child, |
| 26001 | .decl = new_decl_index, |
| 26002 | .lib_name = options.library_name, |
| 26003 | }) |
| 26004 | else |
| 26005 | try mod.intern(.{ .variable = .{ |
| 26006 | .ty = ptr_info.child, |
| 26007 | .init = .none, |
| 26008 | .decl = new_decl_index, |
| 26009 | .lib_name = options.library_name, |
| 26010 | .is_extern = true, |
| 26011 | .is_const = ptr_info.flags.is_const, |
| 26012 | .is_threadlocal = options.is_thread_local, |
| 26013 | .is_weak_linkage = options.linkage == .Weak, |
| 26014 | } }), |
| 26015 | ), |
| 26016 | }, options.name); |
| 26023 | 26017 | new_decl.owns_tv = true; |
| 26024 | | new_decl.analysis = .complete; |
| 26025 | | |
| 26026 | | try sema.ensureDeclAnalyzed(new_decl_index); |
| 26018 | // Note that this will queue the anon decl for codegen, so that the backend can |
| 26019 | // correctly handle the extern, including duplicate detection. |
| 26020 | try mod.finalizeAnonDecl(new_decl_index); |
| 26027 | 26021 | |
| 26028 | 26022 | return Air.internedToRef((try mod.getCoerced(Value.fromInterned((try mod.intern(.{ .ptr = .{ |
| 26029 | 26023 | .ty = switch (ip.indexToKey(ty.toIntern())) { |