zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 9262b6076f38eb614fb45c1f69f125665f0fa8d9 (tree)
parent c597ba32d930df0c2d5be846f3b14a19a5c440c5
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Tue, 18 Jul 2023 21:46:30 -0700

Sema: fix generic function instances not respecting linksection

Diffstat:
Msrc/InternPool.zig | 6+++++-
Msrc/Sema.zig | 5+++++
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/InternPool.zig b/src/InternPool.zig @@ -4705,6 +4705,7 @@ pub const GetFuncInstanceKey = struct { bare_return_type: Index, cc: std.builtin.CallingConvention, alignment: Alignment, + section: OptionalNullTerminatedString, is_noinline: bool, generic_owner: Index, inferred_error_set: bool, @@ -4782,6 +4783,7 @@ pub fn getFuncInstance(ip: *InternPool, gpa: Allocator, arg: GetFuncInstanceKey) func_extra_index, arg.generation, func_ty, + arg.section, ); } @@ -4911,6 +4913,7 @@ pub fn getFuncInstanceIes( func_extra_index, arg.generation, func_ty, + arg.section, ); } @@ -4922,6 +4925,7 @@ fn finishFuncInstance( func_extra_index: u32, generation: u32, func_ty: Index, + section: OptionalNullTerminatedString, ) Allocator.Error!Index { const fn_owner_decl = ip.declPtr(ip.funcDeclOwner(generic_owner)); const decl_index = try ip.createDecl(gpa, .{ @@ -4934,7 +4938,7 @@ fn finishFuncInstance( .ty = func_ty.toType(), .val = func_index.toValue(), .alignment = .none, - .@"linksection" = fn_owner_decl.@"linksection", + .@"linksection" = section, .@"addrspace" = fn_owner_decl.@"addrspace", .analysis = .complete, .deletion_flag = false, diff --git a/src/Sema.zig b/src/Sema.zig @@ -8846,6 +8846,11 @@ fn funcCommon( .bare_return_type = bare_return_type.toIntern(), .cc = cc_resolved, .alignment = alignment.?, + .section = switch (section) { + .generic => unreachable, + .default => .none, + .explicit => |x| x.toOptional(), + }, .is_noinline = is_noinline, .inferred_error_set = inferred_error_set, .generic_owner = sema.generic_owner,