| ... | @@ -9069,7 +9069,7 @@ fn handleExternLibName( | ... | @@ -9069,7 +9069,7 @@ fn handleExternLibName( |
| 9069 | block: *Block, | 9069 | block: *Block, |
| 9070 | src_loc: LazySrcLoc, | 9070 | src_loc: LazySrcLoc, |
| 9071 | lib_name: []const u8, | 9071 | lib_name: []const u8, |
| 9072 | ) CompileError![:0]u8 { | 9072 | ) CompileError!void { |
| 9073 | blk: { | 9073 | blk: { |
| 9074 | const mod = sema.mod; | 9074 | const mod = sema.mod; |
| 9075 | const comp = mod.comp; | 9075 | const comp = mod.comp; |
| ... | @@ -9117,7 +9117,6 @@ fn handleExternLibName( | ... | @@ -9117,7 +9117,6 @@ fn handleExternLibName( |
| 9117 | }); | 9117 | }); |
| 9118 | }; | 9118 | }; |
| 9119 | } | 9119 | } |
| 9120 | return sema.gpa.dupeZ(u8, lib_name); | | |
| 9121 | } | 9120 | } |
| 9122 | | 9121 | |
| 9123 | /// These are calling conventions that are confirmed to work with variadic functions. | 9122 | /// These are calling conventions that are confirmed to work with variadic functions. |
| ... | @@ -9422,15 +9421,13 @@ fn funcCommon( | ... | @@ -9422,15 +9421,13 @@ fn funcCommon( |
| 9422 | assert(section != .generic); | 9421 | assert(section != .generic); |
| 9423 | assert(address_space != null); | 9422 | assert(address_space != null); |
| 9424 | assert(!is_generic); | 9423 | assert(!is_generic); |
| | 9424 | if (opt_lib_name) |lib_name| try sema.handleExternLibName(block, .{ |
| | 9425 | .node_offset_lib_name = src_node_offset, |
| | 9426 | }, lib_name); |
| 9425 | const func_index = try ip.getExternFunc(gpa, .{ | 9427 | const func_index = try ip.getExternFunc(gpa, .{ |
| 9426 | .ty = func_ty, | 9428 | .ty = func_ty, |
| 9427 | .decl = sema.owner_decl_index, | 9429 | .decl = sema.owner_decl_index, |
| 9428 | .lib_name = if (opt_lib_name) |lib_name| (try mod.intern_pool.getOrPutString( | 9430 | .lib_name = try mod.intern_pool.getOrPutStringOpt(gpa, opt_lib_name), |
| 9429 | gpa, | | |
| 9430 | try sema.handleExternLibName(block, .{ | | |
| 9431 | .node_offset_lib_name = src_node_offset, | | |
| 9432 | }, lib_name), | | |
| 9433 | )).toOptional() else .none, | | |
| 9434 | }); | 9431 | }); |
| 9435 | return finishFunc( | 9432 | return finishFunc( |
| 9436 | sema, | 9433 | sema, |
| ... | @@ -24688,10 +24685,11 @@ fn zirVarExtended( | ... | @@ -24688,10 +24685,11 @@ fn zirVarExtended( |
| 24688 | | 24685 | |
| 24689 | var extra_index: usize = extra.end; | 24686 | var extra_index: usize = extra.end; |
| 24690 | | 24687 | |
| 24691 | const lib_name: ?[]const u8 = if (small.has_lib_name) blk: { | 24688 | const lib_name = if (small.has_lib_name) lib_name: { |
| 24692 | const lib_name = sema.code.nullTerminatedString(sema.code.extra[extra_index]); | 24689 | const lib_name = sema.code.nullTerminatedString(sema.code.extra[extra_index]); |
| 24693 | extra_index += 1; | 24690 | extra_index += 1; |
| 24694 | break :blk lib_name; | 24691 | try sema.handleExternLibName(block, ty_src, lib_name); |
| | 24692 | break :lib_name lib_name; |
| 24695 | } else null; | 24693 | } else null; |
| 24696 | | 24694 | |
| 24697 | // ZIR supports encoding this information but it is not used; the information | 24695 | // ZIR supports encoding this information but it is not used; the information |
| ... | @@ -24729,10 +24727,7 @@ fn zirVarExtended( | ... | @@ -24729,10 +24727,7 @@ fn zirVarExtended( |
| 24729 | .ty = var_ty.toIntern(), | 24727 | .ty = var_ty.toIntern(), |
| 24730 | .init = init_val, | 24728 | .init = init_val, |
| 24731 | .decl = sema.owner_decl_index, | 24729 | .decl = sema.owner_decl_index, |
| 24732 | .lib_name = if (lib_name) |lname| (try mod.intern_pool.getOrPutString( | 24730 | .lib_name = try mod.intern_pool.getOrPutStringOpt(sema.gpa, lib_name), |
| 24733 | sema.gpa, | | |
| 24734 | try sema.handleExternLibName(block, ty_src, lname), | | |
| 24735 | )).toOptional() else .none, | | |
| 24736 | .is_extern = small.is_extern, | 24731 | .is_extern = small.is_extern, |
| 24737 | .is_threadlocal = small.is_threadlocal, | 24732 | .is_threadlocal = small.is_threadlocal, |
| 24738 | } }))); | 24733 | } }))); |
| ... | @@ -25177,12 +25172,13 @@ fn resolveExternOptions( | ... | @@ -25177,12 +25172,13 @@ fn resolveExternOptions( |
| 25177 | .needed_comptime_reason = "threadlocality of the extern symbol must be comptime-known", | 25172 | .needed_comptime_reason = "threadlocality of the extern symbol must be comptime-known", |
| 25178 | }); | 25173 | }); |
| 25179 | | 25174 | |
| 25180 | const library_name = if (library_name_val.optionalValue(mod)) |payload| blk: { | 25175 | const library_name = if (library_name_val.optionalValue(mod)) |library_name_payload| library_name: { |
| 25181 | const library_name = try payload.toAllocatedBytes(Type.slice_const_u8, sema.arena, mod); | 25176 | const library_name = try library_name_payload.toAllocatedBytes(Type.slice_const_u8, sema.arena, mod); |
| 25182 | if (library_name.len == 0) { | 25177 | if (library_name.len == 0) { |
| 25183 | return sema.fail(block, library_src, "library name cannot be empty", .{}); | 25178 | return sema.fail(block, library_src, "library name cannot be empty", .{}); |
| 25184 | } | 25179 | } |
| 25185 | break :blk try sema.handleExternLibName(block, library_src, library_name); | 25180 | try sema.handleExternLibName(block, library_src, library_name); |
| | 25181 | break :library_name library_name; |
| 25186 | } else null; | 25182 | } else null; |
| 25187 | | 25183 | |
| 25188 | if (name.len == 0) { | 25184 | if (name.len == 0) { |