Sema: fix @extern decls

Closes #18550
This commit is contained in:
Jacob Young
2024-01-14 14:53:29 +01:00
committed by Jakub Konka
parent 3dddb881bf
commit 03ed3f56cf
3 changed files with 47 additions and 26 deletions

View File

@@ -2941,9 +2941,13 @@ pub const Object = struct {
const target = owner_mod.resolved_target.result;
const sret = firstParamSRet(fn_info, zcu);
const is_extern = decl.isExtern(zcu);
const function_index = try o.builder.addFunction(
try o.lowerType(zig_fn_type),
try o.builder.string(ip.stringToSlice(try decl.getFullyQualifiedName(zcu))),
try o.builder.string(ip.stringToSlice(if (is_extern)
decl.name
else
try decl.getFullyQualifiedName(zcu))),
toLlvmAddressSpace(decl.@"addrspace", target),
);
gop.value_ptr.* = function_index.ptrConst(&o.builder).global;
@@ -2951,7 +2955,6 @@ pub const Object = struct {
var attributes: Builder.FunctionAttributes.Wip = .{};
defer attributes.deinit(&o.builder);
const is_extern = decl.isExtern(zcu);
if (!is_extern) {
function_index.setLinkage(.internal, &o.builder);
function_index.setUnnamedAddr(.unnamed_addr, &o.builder);