authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-09-02 07:38:17-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-09-03 12:59:38-04:00
logbac57b3d15b84b1e4d5365acde3a78d98f439de3
treef6ebfb619bec8703852c9580e44e9ec9d1437f38
parentbe38eff2c0723d995df56c97bc582c8403c6803d

dev: fix some missing checks


28 files changed, 269 insertions(+), 187 deletions(-)

src/Compilation.zig+1
......@@ -2384,6 +2384,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic,
23842384 comp.verbose_llvm_bc != null))
23852385 {
23862386 if (opt_zcu) |zcu| {
2387 dev.check(.llvm_backend);
23872388 zcu.llvm_object = try LlvmObject.create(arena, zcu);
23882389 }
23892390 }
src/Zcu.zig+99-62
......@@ -4572,13 +4572,17 @@ pub fn callconvSupported(zcu: *Zcu, cc: std.lang.CallingConvention) union(enum)
45724572 if (allowed_arch == target.cpu.arch) break;
45734573 } else return .{ .bad_arch = cc.archs() },
45744574 }
4575 const backend_ok = switch (backend) {
4575 const backend_ok = ok: switch (backend) {
45764576 .stage1 => unreachable,
45774577 .other => unreachable,
45784578 _ => unreachable,
45794579
4580 .stage2_llvm => @import("codegen/llvm.zig").toLlvmCallConv(cc, target) != null,
4581 .stage2_c => ok: {
4580 .stage2_llvm => {
4581 dev.check(.llvm_backend);
4582 break :ok @import("codegen/llvm.zig").toLlvmCallConv(cc, target) != null;
4583 },
4584 .stage2_c => {
4585 dev.check(.c_backend);
45824586 if (target.cCallingConvention()) |default_c| {
45834587 if (cc.eql(default_c)) {
45844588 break :ok true;
......@@ -4636,74 +4640,107 @@ pub fn callconvSupported(zcu: *Zcu, cc: std.lang.CallingConvention) union(enum)
46364640 else => false,
46374641 };
46384642 },
4639 .stage2_wasm => switch (cc) {
4640 .wasm_mvp => |opts| opts.incoming_stack_alignment == null,
4641 else => false,
4642 },
4643 .stage2_arm => switch (cc) {
4644 .arm_aapcs => |opts| opts.incoming_stack_alignment == null,
4645 .naked => true,
4646 else => false,
4647 },
4648 .stage2_x86_64 => switch (cc) {
4649 .x86_64_sysv, .x86_64_win, .naked => true, // incoming stack alignment supported
4650 else => false,
4643 .stage2_wasm => {
4644 dev.check(.wasm_backend);
4645 break :ok switch (cc) {
4646 .wasm_mvp => |opts| opts.incoming_stack_alignment == null,
4647 else => false,
4648 };
46514649 },
4652 .stage2_aarch64 => switch (cc) {
4653 .aarch64_aapcs, .aarch64_aapcs_darwin, .naked => true,
4654 else => false,
4650 .stage2_arm => {
4651 dev.check(.arm_backend);
4652 break :ok switch (cc) {
4653 .arm_aapcs => |opts| opts.incoming_stack_alignment == null,
4654 .naked => true,
4655 else => false,
4656 };
46554657 },
4656 .stage2_x86 => switch (cc) {
4657 .x86_sysv,
4658 .x86_win,
4659 .x86_mingw,
4660 => |opts| opts.incoming_stack_alignment == null and opts.register_params == 0,
4661 .naked => true,
4662 else => false,
4658 .stage2_x86_64 => {
4659 dev.check(.x86_64_backend);
4660 break :ok switch (cc) {
4661 .x86_64_sysv, .x86_64_win, .naked => true, // incoming stack alignment supported
4662 else => false,
4663 };
46634664 },
4664 .stage2_powerpc => switch (target.cpu.arch) {
4665 .powerpc, .powerpcle => switch (cc) {
4666 .powerpc_sysv,
4667 .powerpc_sysv_altivec,
4668 .powerpc_aix,
4669 .powerpc_aix_altivec,
4670 .naked,
4671 => true,
4665 .stage2_aarch64 => {
4666 dev.check(.aarch64_backend);
4667 break :ok switch (cc) {
4668 .aarch64_aapcs, .aarch64_aapcs_darwin, .naked => true,
46724669 else => false,
4673 },
4674 .powerpc64, .powerpc64le => switch (cc) {
4675 .powerpc64_elf,
4676 .powerpc64_elf_altivec,
4677 .powerpc64_elf_v2,
4678 .naked,
4679 => true,
4670 };
4671 },
4672 .stage2_x86 => {
4673 dev.check(.x86_backend);
4674 break :ok switch (cc) {
4675 .x86_sysv,
4676 .x86_win,
4677 .x86_mingw,
4678 => |opts| opts.incoming_stack_alignment == null and opts.register_params == 0,
4679 .naked => true,
46804680 else => false,
4681 },
4682 else => unreachable,
4681 };
46834682 },
4684 .stage2_riscv64 => switch (cc) {
4685 .riscv64_lp64 => |opts| opts.incoming_stack_alignment == null,
4686 .naked => true,
4687 else => false,
4683 .stage2_powerpc => {
4684 dev.check(.powerpc_backend);
4685 break :ok switch (target.cpu.arch) {
4686 .powerpc, .powerpcle => switch (cc) {
4687 .powerpc_sysv,
4688 .powerpc_sysv_altivec,
4689 .powerpc_aix,
4690 .powerpc_aix_altivec,
4691 .naked,
4692 => true,
4693 else => false,
4694 },
4695 .powerpc64, .powerpc64le => switch (cc) {
4696 .powerpc64_elf,
4697 .powerpc64_elf_altivec,
4698 .powerpc64_elf_v2,
4699 .naked,
4700 => true,
4701 else => false,
4702 },
4703 else => unreachable,
4704 };
46884705 },
4689 .stage2_sparc64 => switch (cc) {
4690 .sparc64_sysv => |opts| opts.incoming_stack_alignment == null,
4691 .naked => true,
4692 else => false,
4706 .stage2_riscv64 => {
4707 dev.check(.riscv64_backend);
4708 break :ok switch (cc) {
4709 .riscv64_lp64 => |opts| opts.incoming_stack_alignment == null,
4710 .naked => true,
4711 else => false,
4712 };
4713 },
4714 .stage2_sparc64 => {
4715 dev.check(.sparc64_backend);
4716 break :ok switch (cc) {
4717 .sparc64_sysv => |opts| opts.incoming_stack_alignment == null,
4718 .naked => true,
4719 else => false,
4720 };
46934721 },
4694 .stage2_spirv => switch (cc) {
4695 .spirv_device, .spirv_kernel => true,
4696 .spirv_fragment, .spirv_vertex => target.os.tag == .vulkan or target.os.tag == .opengl,
4697 .spirv_task, .spirv_mesh => target.os.tag == .vulkan,
4698 else => false,
4722 .stage2_spirv => {
4723 dev.check(.spirv_backend);
4724 break :ok switch (cc) {
4725 .spirv_device, .spirv_kernel => true,
4726 .spirv_fragment, .spirv_vertex => target.os.tag == .vulkan or target.os.tag == .opengl,
4727 .spirv_task, .spirv_mesh => target.os.tag == .vulkan,
4728 else => false,
4729 };
46994730 },
4700 .stage2_loongarch => switch (cc) {
4701 .loongarch64_lp64, .loongarch32_ilp32, .naked => true,
4702 else => false,
4731 .stage2_loongarch => {
4732 dev.check(.loongarch_backend);
4733 break :ok switch (cc) {
4734 .loongarch64_lp64, .loongarch32_ilp32, .naked => true,
4735 else => false,
4736 };
47034737 },
4704 .zsf_spork8 => switch (cc) {
4705 .spork8, .naked => true,
4706 else => false,
4738 .zsf_spork8 => {
4739 dev.check(.spork8_backend);
4740 break :ok switch (cc) {
4741 .spork8, .naked => true,
4742 else => false,
4743 };
47074744 },
47084745 };
47094746 if (!backend_ok) return .{ .bad_backend = backend };
......@@ -5243,7 +5280,7 @@ pub const CodegenTaskPool = struct {
52435280 /// memory on AIR/MIR, we see a limit of around 10 MiB of AIR in-flight.
52445281 const max_air_bytes_in_flight = 10 * 1024 * 1024;
52455282
5246 const max_funcs_in_flight = @import("link.zig").Queue.buffer_size;
5283 const max_funcs_in_flight = link.Queue.buffer_size;
52475284
52485285 available_air_bytes: u32,
52495286
src/Zcu/PerThread.zig+1-2
......@@ -4461,8 +4461,7 @@ pub fn runCodegen(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) Ru
44614461 comp.config.use_llvm,
44624462 )) {
44634463 else => unreachable, // assertion failure
4464 .stage2_llvm,
4465 => {},
4464 .stage2_llvm => {},
44664465 },
44674466 error.Canceled => |e| return e,
44684467 }
src/codegen.zig-2
......@@ -744,7 +744,6 @@ fn lowerUavRef(
744744 .c => unreachable,
745745 .spirv => unreachable,
746746 .wasm => {
747 dev.check(link.File.Tag.wasm.devFeature());
748747 const wasm = lf.cast(.wasm).?;
749748 assert(reloc_parent == .none);
750749 try wasm.addUavReloc(w.end, uav.val, uav.orig_ty, @intCast(offset));
......@@ -797,7 +796,6 @@ fn lowerNavRef(
797796 .c => unreachable,
798797 .spirv => unreachable,
799798 .wasm => {
800 dev.check(link.File.Tag.wasm.devFeature());
801799 const wasm = lf.cast(.wasm).?;
802800 assert(reloc_parent == .none);
803801 try wasm.addNavReloc(w.end, nav_index, nav_ty, @intCast(offset));
src/codegen/c.zig+1-2
......@@ -7,7 +7,6 @@ const Allocator = mem.Allocator;
77const Writer = std.Io.Writer;
88
99const codegen = @import("../codegen.zig");
10const dev = @import("../dev.zig");
1110const link = @import("../link.zig");
1211const Zcu = @import("../Zcu.zig");
1312const Module = @import("../Module.zig");
......@@ -25,7 +24,7 @@ const BigIntLimb = std.math.big.Limb;
2524const BigInt = std.math.big.int;
2625
2726pub fn legalizeFeatures(_: *const std.Target) ?*const Air.Legalize.Features {
28 return comptime switch (dev.env.supports(.legalize)) {
27 return comptime switch (@import("../dev.zig").env.supports(.legalize)) {
2928 inline false, true => |supports_legalize| &.init(.{
3029 // we don't currently ask zig1 to use safe optimization modes
3130 .expand_bit_cast_safe = supports_legalize,
src/codegen/llvm.zig+1-3
......@@ -10,7 +10,6 @@ const build_options = @import("build_options");
1010const Air = @import("../Air.zig");
1111const codegen = @import("../codegen.zig");
1212const Compilation = @import("../Compilation.zig");
13const dev = @import("../dev.zig");
1413const InternPool = @import("../InternPool.zig");
1514const link = @import("../link.zig");
1615const Module = @import("../Module.zig");
......@@ -155,12 +154,11 @@ pub const Object = struct {
155154 /// Values for `@llvm.used`.
156155 used: std.ArrayList(Builder.Constant),
157156
158 pub const Ptr = if (dev.env.supports(.llvm_backend)) *Object else noreturn;
157 pub const Ptr = if (@import("../dev.zig").env.supports(.llvm_backend)) *Object else noreturn;
159158
160159 const TypeMap = std.AutoHashMapUnmanaged(InternPool.Index, Builder.Type);
161160
162161 pub fn create(arena: Allocator, zcu: *Zcu) !Ptr {
163 dev.check(.llvm_backend);
164162 const comp = zcu.comp;
165163 const gpa = comp.gpa;
166164 const target = zcu.getTarget();
src/crash_report.zig-1
......@@ -215,7 +215,6 @@ const Sema = @import("Sema.zig");
215215const Zcu = @import("Zcu.zig");
216216const link = @import("link.zig");
217217const InternPool = @import("InternPool.zig");
218const dev = @import("dev.zig");
219218const print_zir = @import("print_zir.zig");
220219
221220const build_options = @import("build_options");
src/dev.zig-1
......@@ -227,7 +227,6 @@ pub const Env = enum {
227227 else => Env.sema.supports(feature),
228228 },
229229 .@"x86_64-windows" => switch (feature) {
230 .build_command,
231230 .stdio_listen,
232231 .incremental,
233232 .legalize,
src/link.zig+1-5
......@@ -97,7 +97,6 @@ pub const Diags = struct {
9797 return switch (msg.source_location) {
9898 .none => try bundle.addString(msg.msg),
9999 .wasm => |sl| {
100 dev.check(.wasm_linker);
101100 const wasm = base.?.cast(.wasm).?;
102101 return sl.string(msg.msg, bundle, wasm);
103102 },
......@@ -396,8 +395,6 @@ pub const Diags = struct {
396395 }
397396};
398397
399pub const producer_string = if (builtin.is_test) "zig test" else "zig " ++ build_options.version;
400
401398pub const File = struct {
402399 tag: Tag,
403400
......@@ -655,7 +652,6 @@ pub const File = struct {
655652 base.file = try emit.root_dir.handle.openFile(io, emit.sub_path, .{ .mode = .read_write });
656653 },
657654 .elf2, .coff2 => if (base.file == null) {
658 dev.checkAny(&.{ .elf2_linker, .coff2_linker });
659655 const mf = if (base.cast(.elf2)) |elf|
660656 &elf.mf
661657 else if (base.cast(.coff2)) |coff|
......@@ -1347,7 +1343,7 @@ pub const File = struct {
13471343 };
13481344 }
13491345
1350 pub fn devFeature(tag: Tag) dev.Feature {
1346 fn devFeature(tag: Tag) dev.Feature {
13511347 return @field(dev.Feature, @tagName(tag) ++ "_linker");
13521348 }
13531349 };
src/link/Coff.zig+1-1
......@@ -13,7 +13,7 @@ const codegen = @import("../codegen.zig");
1313const Compilation = @import("../Compilation.zig");
1414const InternPool = @import("../InternPool.zig");
1515const link = @import("../link.zig");
16const MappedFile = @import("MappedFile.zig");
16const MappedFile = link.MappedFile;
1717const target_util = @import("../target.zig");
1818const Type = @import("../Type.zig");
1919const Value = @import("../Value.zig");
src/link/ConstPool.zig+25-4
......@@ -45,11 +45,22 @@ pub const Index = enum(u32) {
4545};
4646
4747pub const User = union(enum) {
48 dwarf: *@import("Dwarf.zig"),
48 elf: *@import("Dwarf.zig"),
4949 elf2: *@import("Elf2.zig"),
50 macho: *@import("Dwarf.zig"),
5051 c: *@import("C.zig"),
5152 llvm: @import("../codegen/llvm.zig").Object.Ptr,
5253
54 fn devFeature(tag: @typeInfo(User).@"union".tag_type.?) dev.Feature {
55 return switch (tag) {
56 .elf => .elf_linker,
57 .elf2 => .elf2_linker,
58 .macho => .macho_linker,
59 .c => .c_linker,
60 .llvm => .llvm_backend,
61 };
62 }
63
5364 /// Inform the debug info implementation that the new constant `val` was added to the pool at
5465 /// the given index (which equals the current pool length) due to a `get` call. It is guaranteed
5566 /// that there will eventually be a call to either `updateConst` or `updateConstIncomplete`
......@@ -61,7 +72,10 @@ pub const User = union(enum) {
6172 val: InternPool.Index,
6273 ) link.Error!void {
6374 switch (user) {
64 inline else => |impl| return impl.addConst(pt, index, val),
75 inline else => |impl, tag| {
76 dev.check(devFeature(tag));
77 return impl.addConst(pt, index, val);
78 },
6579 }
6680 }
6781
......@@ -76,7 +90,10 @@ pub const User = union(enum) {
7690 val: InternPool.Index,
7791 ) link.Error!void {
7892 switch (user) {
79 inline else => |impl| return impl.updateConst(pt, index, val),
93 inline else => |impl, tag| {
94 dev.check(devFeature(tag));
95 return impl.updateConst(pt, index, val);
96 },
8097 }
8198 }
8299
......@@ -92,7 +109,10 @@ pub const User = union(enum) {
92109 val: InternPool.Index,
93110 ) link.Error!void {
94111 switch (user) {
95 inline else => |impl| return impl.updateConstIncomplete(pt, index, val),
112 inline else => |impl, tag| {
113 dev.check(devFeature(tag));
114 return impl.updateConstIncomplete(pt, index, val);
115 },
96116 }
97117 }
98118};
......@@ -289,6 +309,7 @@ fn registerTypeDeps(pool: *ConstPool, root: Index, ty: Type, zcu: *const Zcu) Al
289309const std = @import("std");
290310const Allocator = std.mem.Allocator;
291311
312const dev = @import("../dev.zig");
292313const InternPool = @import("../InternPool.zig");
293314const link = @import("../link.zig");
294315const Type = @import("../Type.zig");
src/link/Dwarf.zig+24-16
......@@ -122,7 +122,7 @@ const DebugFrame = struct {
122122 uleb128Bytes(1) + 1,
123123 } + switch (target.cpu.arch) {
124124 .x86_64 => len: {
125 dev.check(.x86_64_backend);
125 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
126126 const Register = @import("../codegen/x86_64/bits.zig").Register;
127127 break :len uleb128Bytes(1) + sleb128Bytes(-8) + uleb128Bytes(Register.rip.dwarfNum()) +
128128 1 + uleb128Bytes(Register.rsp.dwarfNum()) + sleb128Bytes(-1) +
......@@ -2092,7 +2092,7 @@ pub const WipNav = struct {
20922092 assert(value.typeOf(wip_nav.pt.zcu).comptimeOnly(wip_nav.pt.zcu));
20932093 }
20942094 const dwarf = wip_nav.dwarf;
2095 const index = try dwarf.const_pool.get(wip_nav.pt, .{ .dwarf = dwarf }, value.toIntern());
2095 const index = try dwarf.const_pool.get(wip_nav.pt, dwarf.constPoolUser(), value.toIntern());
20962096 return dwarf.values.items[@backingInt(index)];
20972097 }
20982098
......@@ -3005,7 +3005,7 @@ fn finishWipNavWriterError(
30053005 try dwarf.debug_line.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_line.written());
30063006 try dwarf.debug_loclists.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_loclists.written());
30073007
3008 try dwarf.const_pool.flushPending(pt, .{ .dwarf = dwarf });
3008 try dwarf.const_pool.flushPending(pt, dwarf.constPoolUser());
30093009}
30103010
30113011pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) link.Error!void {
......@@ -3067,8 +3067,8 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo
30673067 const loaded_struct = ip.loadStructType(nav_val.toIntern());
30683068 if (nav_index.toOptional() == loaded_struct.name_nav) {
30693069 // This Nav's entry is populated by the type, not the actual Nav.
3070 _ = try dwarf.const_pool.get(pt, .{ .dwarf = dwarf }, nav_val.toIntern());
3071 try dwarf.const_pool.flushPending(pt, .{ .dwarf = dwarf });
3070 _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern());
3071 try dwarf.const_pool.flushPending(pt, dwarf.constPoolUser());
30723072 return;
30733073 }
30743074 break :tag .alias;
......@@ -3077,8 +3077,8 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo
30773077 const loaded_enum = ip.loadEnumType(nav_val.toIntern());
30783078 if (nav_index.toOptional() == loaded_enum.name_nav) {
30793079 // This Nav's entry is populated by the type, not the actual Nav.
3080 _ = try dwarf.const_pool.get(pt, .{ .dwarf = dwarf }, nav_val.toIntern());
3081 try dwarf.const_pool.flushPending(pt, .{ .dwarf = dwarf });
3080 _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern());
3081 try dwarf.const_pool.flushPending(pt, dwarf.constPoolUser());
30823082 return;
30833083 }
30843084 break :tag .alias;
......@@ -3087,8 +3087,8 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo
30873087 const loaded_union = ip.loadUnionType(nav_val.toIntern());
30883088 if (nav_index.toOptional() == loaded_union.name_nav) {
30893089 // This Nav's entry is populated by the type, not the actual Nav.
3090 _ = try dwarf.const_pool.get(pt, .{ .dwarf = dwarf }, nav_val.toIntern());
3091 try dwarf.const_pool.flushPending(pt, .{ .dwarf = dwarf });
3090 _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern());
3091 try dwarf.const_pool.flushPending(pt, dwarf.constPoolUser());
30923092 return;
30933093 }
30943094 break :tag .alias;
......@@ -3097,8 +3097,8 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo
30973097 const loaded_opaque = ip.loadOpaqueType(nav_val.toIntern());
30983098 if (nav_index.toOptional() == loaded_opaque.name_nav) {
30993099 // This Nav's entry is populated by the type, not the actual Nav.
3100 _ = try dwarf.const_pool.get(pt, .{ .dwarf = dwarf }, nav_val.toIntern());
3101 try dwarf.const_pool.flushPending(pt, .{ .dwarf = dwarf });
3100 _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern());
3101 try dwarf.const_pool.flushPending(pt, dwarf.constPoolUser());
31023102 return;
31033103 }
31043104 break :tag .alias;
......@@ -3274,7 +3274,7 @@ fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPoo
32743274 },
32753275 }
32763276 try dwarf.debug_info.section.replaceEntry(unit, wip_nav.entry, dwarf, wip_nav.debug_info.written());
3277 try dwarf.const_pool.flushPending(pt, .{ .dwarf = dwarf });
3277 try dwarf.const_pool.flushPending(pt, dwarf.constPoolUser());
32783278}
32793279
32803280pub fn updateContainerType(
......@@ -3283,7 +3283,7 @@ pub fn updateContainerType(
32833283 ty: InternPool.Index,
32843284 success: bool,
32853285) !void {
3286 try dwarf.const_pool.updateContainerType(pt, .{ .dwarf = dwarf }, ty, success);
3286 try dwarf.const_pool.updateContainerType(pt, dwarf.constPoolUser(), ty, success);
32873287}
32883288/// Should only be called by the `link.ConstPool` implementation.
32893289pub fn addConst(dwarf: *Dwarf, pt: Zcu.PerThread, index: link.ConstPool.Index, val: InternPool.Index) Allocator.Error!void {
......@@ -4702,7 +4702,7 @@ fn flushWriterError(dwarf: *Dwarf, pt: Zcu.PerThread) (UpdateError || Writer.Err
47024702
47034703 // Update `anyerror` based on the finished global error set.
47044704 {
4705 const index = try dwarf.const_pool.get(pt, .{ .dwarf = dwarf }, .anyerror_type);
4705 const index = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), .anyerror_type);
47064706 const unit, const entry = dwarf.values.items[@backingInt(index)];
47074707 var wip_nav: WipNav = .{
47084708 .dwarf = dwarf,
......@@ -4737,7 +4737,7 @@ fn flushWriterError(dwarf: *Dwarf, pt: Zcu.PerThread) (UpdateError || Writer.Err
47374737 }
47384738 if (global_error_set_names.len > 0) try diw.writeUleb128(@backingInt(AbbrevCode.null));
47394739 try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.written());
4740 try dwarf.const_pool.flushPending(pt, .{ .dwarf = dwarf });
4740 try dwarf.const_pool.flushPending(pt, dwarf.constPoolUser());
47414741 }
47424742
47434743 for (dwarf.mods.keys(), dwarf.mods.values()) |mod, *mod_info| {
......@@ -4789,7 +4789,7 @@ fn flushWriterError(dwarf: *Dwarf, pt: Zcu.PerThread) (UpdateError || Writer.Err
47894789 .debug_frame => unreachable,
47904790 .eh_frame => switch (target.cpu.arch) {
47914791 .x86_64 => {
4792 dev.check(.x86_64_backend);
4792 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
47934793 const Register = @import("../codegen/x86_64/bits.zig").Register;
47944794 for (dwarf.debug_frame.section.units.items) |*unit| {
47954795 header_aw.clearRetainingCapacity();
......@@ -6307,6 +6307,14 @@ fn getFile(dwarf: *Dwarf) ?Io.File {
63076307 return dwarf.bin_file.file;
63086308}
63096309
6310fn constPoolUser(dwarf: *Dwarf) link.ConstPool.User {
6311 return switch (dwarf.bin_file.tag) {
6312 else => unreachable,
6313 .elf => .{ .elf = dwarf },
6314 .macho => .{ .macho = dwarf },
6315 };
6316}
6317
63106318fn addCommonEntry(dwarf: *Dwarf, unit: Unit.Index) UpdateError!Entry.Index {
63116319 const entry = try dwarf.debug_aranges.section.getUnit(unit).addEntry(dwarf.gpa);
63126320 assert(try dwarf.debug_frame.section.getUnit(unit).addEntry(dwarf.gpa) == entry);
src/link/Dwarf2.zig+69-64
......@@ -27,15 +27,15 @@ pub const Unit = struct {
2727 alive: bool,
2828 dirs: std.array_hash_map.Auto(Unit.Index, void),
2929 files: std.array_hash_map.Auto(Zcu.File.Index, void),
30 frame_ni: MappedFile.Node.Index.Optional,
31 cie_ni: MappedFile.Node.Index.Optional,
32 debug_info_ni: MappedFile.Node.Index.Optional,
33 debug_info_header_ni: MappedFile.Node.Index.Optional,
34 debug_info_footer_ni: MappedFile.Node.Index.Optional,
35 debug_line_ni: MappedFile.Node.Index.Optional,
36 debug_line_header_ni: MappedFile.Node.Index.Optional,
30 frame_ni: link.MappedFile.Node.Index.Optional,
31 cie_ni: link.MappedFile.Node.Index.Optional,
32 debug_info_ni: link.MappedFile.Node.Index.Optional,
33 debug_info_header_ni: link.MappedFile.Node.Index.Optional,
34 debug_info_footer_ni: link.MappedFile.Node.Index.Optional,
35 debug_line_ni: link.MappedFile.Node.Index.Optional,
36 debug_line_header_ni: link.MappedFile.Node.Index.Optional,
3737 debug_line_header_changed: bool,
38 debug_rnglists_ni: MappedFile.Node.Index.Optional,
38 debug_rnglists_ni: link.MappedFile.Node.Index.Optional,
3939 debug_rnglists_offsets_table_offset: usize,
4040 debug_rnglists_end: usize,
4141
......@@ -96,7 +96,7 @@ pub const Unit = struct {
9696};
9797
9898pub const Const = struct {
99 debug_info_ni: MappedFile.Node.Index.Optional,
99 debug_info_ni: link.MappedFile.Node.Index.Optional,
100100
101101 pub fn get(cpi: link.ConstPool.Index, dwarf: *Dwarf) *Const {
102102 return &dwarf.consts.items[@backingInt(cpi)];
......@@ -104,7 +104,7 @@ pub const Const = struct {
104104};
105105
106106pub const Global = struct {
107 debug_info_ni: MappedFile.Node.Index.Optional,
107 debug_info_ni: link.MappedFile.Node.Index.Optional,
108108
109109 pub const Index = enum(u32) {
110110 _,
......@@ -121,9 +121,9 @@ pub const Global = struct {
121121
122122pub const Func = struct {
123123 state: State,
124 fde_ni: MappedFile.Node.Index.Optional,
125 debug_info_ni: MappedFile.Node.Index.Optional,
126 debug_line_ni: MappedFile.Node.Index.Optional,
124 fde_ni: link.MappedFile.Node.Index.Optional,
125 debug_info_ni: link.MappedFile.Node.Index.Optional,
126 debug_line_ni: link.MappedFile.Node.Index.Optional,
127127
128128 pub const State = enum { unresolved, resolved };
129129
......@@ -141,7 +141,7 @@ pub const Func = struct {
141141};
142142
143143pub const Decl = struct {
144 debug_info_ni: MappedFile.Node.Index.Optional,
144 debug_info_ni: link.MappedFile.Node.Index.Optional,
145145
146146 pub const Index = enum(u32) {
147147 _,
......@@ -170,7 +170,7 @@ pub const Frame = struct {
170170};
171171
172172pub const Abbrev = struct {
173 ni: MappedFile.Node.Index.Optional,
173 ni: link.MappedFile.Node.Index.Optional,
174174 end: usize,
175175 set: std.enums.EnumSet(AbbrevCode),
176176};
......@@ -191,16 +191,16 @@ pub const Line = struct {
191191};
192192
193193pub const Str = struct {
194 ni: MappedFile.Node.Index.Optional,
194 ni: link.MappedFile.Node.Index.Optional,
195195 offset: usize,
196196 map: std.HashMapUnmanaged(usize, void, Context, std.hash_map.default_max_load_percentage),
197197
198198 fn get(
199199 s: *Str,
200200 gpa: std.mem.Allocator,
201 mf: *MappedFile,
201 mf: *link.MappedFile,
202202 str: []const u8,
203 ) MappedFile.Error!usize {
203 ) link.MappedFile.Error!usize {
204204 const ni = s.ni.unwrap().?;
205205 const slice = ni.sliceConst(mf);
206206 const gop = try s.map.getOrPutContextAdapted(
......@@ -250,7 +250,7 @@ pub const Rnglists = struct {
250250};
251251
252252pub const StrOffsets = struct {
253 ni: MappedFile.Node.Index.Optional,
253 ni: link.MappedFile.Node.Index.Optional,
254254 offset: usize,
255255};
256256
......@@ -268,13 +268,13 @@ pub const Loc = union(enum) {
268268 push_object_address,
269269 call: struct {
270270 args: []const Loc = &.{},
271 node: MappedFile.Node.Index,
271 node: link.MappedFile.Node.Index,
272272 },
273273 form_tls_address: *const Loc,
274274 implicit_value: []const u8,
275275 stack_value: *const Loc,
276276 implicit_pointer: struct {
277 node: MappedFile.Node.Index,
277 node: link.MappedFile.Node.Index,
278278 offset: i65 = 0,
279279 },
280280 wasm_ext: union(enum) {
......@@ -311,7 +311,7 @@ pub const Loc = union(enum) {
311311
312312 fn write(loc: Loc, writer: union(enum) {
313313 io: *std.Io.Writer,
314 mf: *MappedFile.Node.Writer,
314 mf: *link.MappedFile.Node.Writer,
315315 }, dwarf: *Dwarf) link.EmitError!void {
316316 const w = switch (writer) {
317317 .io => |w| w,
......@@ -631,7 +631,7 @@ pub const WipNav = struct {
631631 cfa: Cfa.RegOff,
632632 },
633633 frame_format: Frame.Format,
634 fde_writer: MappedFile.Node.Writer,
634 fde_writer: link.MappedFile.Node.Writer,
635635 frame_func_length: struct { offset: usize, size: AddressSize },
636636
637637 pub const Debug = struct {
......@@ -643,9 +643,9 @@ pub const WipNav = struct {
643643 low_pc_off: usize,
644644 high_pc: u32,
645645 }),
646 info_writer: MappedFile.Node.Writer,
646 info_writer: link.MappedFile.Node.Writer,
647647 info_func_length_offset: usize,
648 line_writer: MappedFile.Node.Writer,
648 line_writer: link.MappedFile.Node.Writer,
649649
650650 pub fn deinit(debug: *Debug) void {
651651 const gpa = debug.pt.zcu.gpa;
......@@ -1268,7 +1268,7 @@ pub fn init(lf: *link.File, format: DW.Format) Dwarf {
12681268 },
12691269 .frame = .{
12701270 .header = if (target.cpu.arch == .x86_64 and target.ofmt == .elf) header: {
1271 dev.check(.x86_64_backend);
1271 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
12721272 const Register = @import("../codegen/x86_64/bits.zig").Register;
12731273 break :header comptime .{
12741274 .code_alignment_factor = 1,
......@@ -1385,7 +1385,7 @@ pub fn getUnit(dwarf: *Dwarf, mod: *Module) Unit.Index {
13851385
13861386pub fn getConst(dwarf: *Dwarf, pt: Zcu.PerThread, val: Value) link.Error!link.ConstPool.Index {
13871387 assert(val.typeOf(pt.zcu).comptimeOnly(pt.zcu));
1388 return dwarf.const_pool.get(pt, .{ .elf2 = dwarf.lf.cast(.elf2).? }, val.toIntern());
1388 return dwarf.const_pool.get(pt, dwarf.constPoolUser(), val.toIntern());
13891389}
13901390
13911391pub fn getGlobal(dwarf: *Dwarf, nav: InternPool.Nav.Index) link.Error!Global.Index {
......@@ -1514,7 +1514,7 @@ pub fn getDecl(
15141514 dwarf: *Dwarf,
15151515 pt: Zcu.PerThread,
15161516 instance_val: InternPool.Index,
1517) link.Error!MappedFile.Node.Index {
1517) link.Error!link.MappedFile.Node.Index {
15181518 assert(dwarf.pending_decl.instance_val == .none);
15191519 const comp = dwarf.lf.comp;
15201520 const gpa = comp.gpa;
......@@ -1634,7 +1634,7 @@ pub fn genDebugFrameCie(
16341634 switch (arch orelse return) {
16351635 else => unreachable,
16361636 .x86_64 => {
1637 dev.check(.x86_64_backend);
1637 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
16381638 const Register = @import("../codegen/x86_64/bits.zig").Register;
16391639 switch (format) {
16401640 .eh_frame => try df_w.writeAll("zR\x00"),
......@@ -1682,7 +1682,7 @@ pub fn genDebugInfoHeader(
16821682 zcu: *Zcu,
16831683 mod: *Module,
16841684 unit: *Unit,
1685 dih_nw: *MappedFile.Node.Writer,
1685 dih_nw: *link.MappedFile.Node.Writer,
16861686) link.EmitError!void {
16871687 const comp = zcu.comp;
16881688 const dih_w = &dih_nw.interface;
......@@ -1728,7 +1728,7 @@ pub fn genDebugInfoHeader(
17281728
17291729fn genModuleDependency(
17301730 dwarf: *Dwarf,
1731 di_nw: *MappedFile.Node.Writer,
1731 di_nw: *link.MappedFile.Node.Writer,
17321732 name: []const u8,
17331733 dep: *Module,
17341734 module_offset: usize,
......@@ -1773,7 +1773,7 @@ pub fn genDebugInfoPadding(dwarf: *Dwarf, di_w: *std.Io.Writer, size: u64) std.I
17731773pub fn genDebugLineHeader(
17741774 dwarf: *Dwarf,
17751775 unit: *Unit,
1776 dlh_nw: *MappedFile.Node.Writer,
1776 dlh_nw: *link.MappedFile.Node.Writer,
17771777 zcu: *Zcu,
17781778) link.EmitError!void {
17791779 const comp = zcu.comp;
......@@ -1911,7 +1911,7 @@ pub fn genDebugLinePadding(dl_w: *std.Io.Writer, size: u64) std.Io.Writer.Error!
19111911pub fn genDebugRnglistsHeader(
19121912 dwarf: *Dwarf,
19131913 unit: *Unit,
1914 drh_nw: *MappedFile.Node.Writer,
1914 drh_nw: *link.MappedFile.Node.Writer,
19151915) std.Io.Writer.Error!void {
19161916 const drh_w = &drh_nw.interface;
19171917 try dwarf.genUnitLength(drh_w);
......@@ -1931,7 +1931,7 @@ pub fn genDebugRnglistsHeader(
19311931pub fn genDebugRnglists(
19321932 dwarf: *Dwarf,
19331933 unit: *Unit,
1934 dr_nw: *MappedFile.Node.Writer,
1934 dr_nw: *link.MappedFile.Node.Writer,
19351935 func_si: link.File.SymbolId,
19361936 func_length: u64,
19371937) link.EmitError!void {
......@@ -1965,7 +1965,7 @@ pub fn updateComptimeNav(
19651965 .struct_type => {
19661966 const loaded_struct = ip.loadStructType(nav_val.toIntern());
19671967 if (nav_index.toOptional() == loaded_struct.name_nav) {
1968 _ = try dwarf.const_pool.get(pt, .{ .elf2 = dwarf.lf.cast(.elf2).? }, nav_val.toIntern());
1968 _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern());
19691969 break :done;
19701970 }
19711971 return;
......@@ -1973,7 +1973,7 @@ pub fn updateComptimeNav(
19731973 .enum_type => {
19741974 const loaded_enum = ip.loadEnumType(nav_val.toIntern());
19751975 if (nav_index.toOptional() == loaded_enum.name_nav) {
1976 _ = try dwarf.const_pool.get(pt, .{ .elf2 = dwarf.lf.cast(.elf2).? }, nav_val.toIntern());
1976 _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern());
19771977 break :done;
19781978 }
19791979 return;
......@@ -1981,7 +1981,7 @@ pub fn updateComptimeNav(
19811981 .union_type => {
19821982 const loaded_union = ip.loadUnionType(nav_val.toIntern());
19831983 if (nav_index.toOptional() == loaded_union.name_nav) {
1984 _ = try dwarf.const_pool.get(pt, .{ .elf2 = dwarf.lf.cast(.elf2).? }, nav_val.toIntern());
1984 _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern());
19851985 break :done;
19861986 }
19871987 return;
......@@ -1989,13 +1989,13 @@ pub fn updateComptimeNav(
19891989 .opaque_type => {
19901990 const loaded_opaque = ip.loadOpaqueType(nav_val.toIntern());
19911991 if (nav_index.toOptional() == loaded_opaque.name_nav) {
1992 _ = try dwarf.const_pool.get(pt, .{ .elf2 = dwarf.lf.cast(.elf2).? }, nav_val.toIntern());
1992 _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern());
19931993 break :done;
19941994 }
19951995 return;
19961996 },
19971997 .func => |func| if (func.owner_nav == nav_index and func.generic_owner == .none) {
1998 _ = try dwarf.const_pool.get(pt, .{ .elf2 = dwarf.lf.cast(.elf2).? }, nav_val.toIntern());
1998 _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern());
19991999 break :done;
20002000 } else return,
20012001
......@@ -2004,7 +2004,7 @@ pub fn updateComptimeNav(
20042004 // memoization, not values
20052005 .memoized_call => unreachable,
20062006 }
2007 try dwarf.const_pool.flushPending(pt, .{ .elf2 = dwarf.lf.cast(.elf2).? });
2007 try dwarf.const_pool.flushPending(pt, dwarf.constPoolUser());
20082008}
20092009
20102010pub fn addConst(
......@@ -2015,7 +2015,7 @@ pub fn addConst(
20152015 lf: *link.File,
20162016 ui: Unit.Index,
20172017 cpi: link.ConstPool.Index,
2018 ) link.Error!MappedFile.Node.Index,
2018 ) link.Error!link.MappedFile.Node.Index,
20192019) link.Error!void {
20202020 const zcu = dwarf.lf.comp.zcu.?;
20212021 const ip = &zcu.intern_pool;
......@@ -2053,7 +2053,7 @@ pub fn addConst(
20532053pub fn updateConst(
20542054 dwarf: *Dwarf,
20552055 pt: Zcu.PerThread,
2056 di_nw: *MappedFile.Node.Writer,
2056 di_nw: *link.MappedFile.Node.Writer,
20572057 val: InternPool.Index,
20582058) link.Error!void {
20592059 switch (val) {
......@@ -2068,7 +2068,7 @@ pub fn updateConst(
20682068fn updateConstInner(
20692069 dwarf: *Dwarf,
20702070 pt: Zcu.PerThread,
2071 di_nw: *MappedFile.Node.Writer,
2071 di_nw: *link.MappedFile.Node.Writer,
20722072 val: InternPool.Index,
20732073) link.EmitError!void {
20742074 const zcu = pt.zcu;
......@@ -2956,7 +2956,7 @@ fn optRepr(opt_child_type: Type, zcu: *const Zcu) enum { unpacked, opv_null, err
29562956pub fn updateConstIncomplete(
29572957 dwarf: *Dwarf,
29582958 pt: Zcu.PerThread,
2959 di_nw: *MappedFile.Node.Writer,
2959 di_nw: *link.MappedFile.Node.Writer,
29602960 val: InternPool.Index,
29612961) link.Error!void {
29622962 log.debug("updateConstIncomplete({f})", .{Value.fromInterned(val).fmtValue(pt)});
......@@ -2968,7 +2968,7 @@ pub fn updateConstIncomplete(
29682968fn updateConstIncompleteInner(
29692969 dwarf: *Dwarf,
29702970 pt: Zcu.PerThread,
2971 di_nw: *MappedFile.Node.Writer,
2971 di_nw: *link.MappedFile.Node.Writer,
29722972 val: InternPool.Index,
29732973) link.EmitError!void {
29742974 const zcu = pt.zcu;
......@@ -3185,7 +3185,7 @@ fn updateConstIncompleteInner(
31853185fn genCaptures(
31863186 dwarf: *Dwarf,
31873187 pt: Zcu.PerThread,
3188 di_nw: *MappedFile.Node.Writer,
3188 di_nw: *link.MappedFile.Node.Writer,
31893189 captures: anytype,
31903190) link.EmitError!void {
31913191 const zcu = pt.zcu;
......@@ -3229,7 +3229,7 @@ fn genCaptures(
32293229pub fn genDecl(
32303230 dwarf: *Dwarf,
32313231 pt: Zcu.PerThread,
3232 di_nw: *MappedFile.Node.Writer,
3232 di_nw: *link.MappedFile.Node.Writer,
32333233 instance_val: InternPool.Index,
32343234) link.Error!void {
32353235 log.debug("genDecl({f})", .{Value.fromInterned(instance_val).fmtValue(pt)});
......@@ -3241,7 +3241,7 @@ pub fn genDecl(
32413241fn genDeclInner(
32423242 dwarf: *Dwarf,
32433243 pt: Zcu.PerThread,
3244 di_nw: *MappedFile.Node.Writer,
3244 di_nw: *link.MappedFile.Node.Writer,
32453245 instance_val: InternPool.Index,
32463246) link.EmitError!void {
32473247 const zcu = pt.zcu;
......@@ -3458,7 +3458,7 @@ fn genDeclInner(
34583458
34593459pub fn updateLineNumber(
34603460 dwarf: *Dwarf,
3461 mf: *MappedFile,
3461 mf: *link.MappedFile,
34623462 inst: InternPool.TrackedInst.Index,
34633463 line: u32,
34643464) void {
......@@ -3472,7 +3472,7 @@ pub fn updateLineNumber(
34723472 );
34733473}
34743474
3475pub fn lostTracking(dwarf: *Dwarf, di_nw: *MappedFile.Node.Writer) link.EmitError!void {
3475pub fn lostTracking(dwarf: *Dwarf, di_nw: *link.MappedFile.Node.Writer) link.EmitError!void {
34763476 try dwarf.abbrevCode(di_nw, .decl_lost);
34773477}
34783478
......@@ -3485,14 +3485,14 @@ fn refAbbrevCodeIfExists(
34853485}
34863486fn refAbbrevCode(
34873487 dwarf: *Dwarf,
3488 mf: *MappedFile,
3488 mf: *link.MappedFile,
34893489 abbrev_code: AbbrevCode,
34903490) link.Error!@typeInfo(AbbrevCode).@"enum".tag_type {
34913491 if (dwarf.refAbbrevCodeIfExists(abbrev_code)) |backing_int| {
34923492 @branchHint(.likely);
34933493 return backing_int;
34943494 }
3495 var da_nw: MappedFile.Node.Writer = undefined;
3495 var da_nw: link.MappedFile.Node.Writer = undefined;
34963496 dwarf.debug_abbrev.ni.unwrap().?.writer(dwarf.lf.comp.gpa, mf, &da_nw);
34973497 defer da_nw.deinit();
34983498 dwarf.genDebugAbbrev(&da_nw, abbrev_code) catch |err| switch (err) {
......@@ -3504,7 +3504,7 @@ fn refAbbrevCode(
35043504}
35053505fn abbrevCode(
35063506 dwarf: *Dwarf,
3507 nw: *MappedFile.Node.Writer,
3507 nw: *link.MappedFile.Node.Writer,
35083508 abbrev_code: AbbrevCode,
35093509) link.EmitError!void {
35103510 try nw.interface.writeUleb128(try dwarf.refAbbrevCode(nw.mf, abbrev_code));
......@@ -3512,7 +3512,7 @@ fn abbrevCode(
35123512
35133513fn genDebugAbbrev(
35143514 dwarf: *Dwarf,
3515 da_nw: *MappedFile.Node.Writer,
3515 da_nw: *link.MappedFile.Node.Writer,
35163516 abbrev_code: AbbrevCode,
35173517) link.EmitError!void {
35183518 const abbrev = AbbrevCode.abbrevs.get(abbrev_code);
......@@ -3543,8 +3543,8 @@ fn secOffsetPlaceholder(dwarf: *Dwarf, w: *std.Io.Writer) std.Io.Writer.Error!vo
35433543}
35443544fn secOffset(
35453545 dwarf: *Dwarf,
3546 nw: *MappedFile.Node.Writer,
3547 target_ni: MappedFile.Node.Index,
3546 nw: *link.MappedFile.Node.Writer,
3547 target_ni: link.MappedFile.Node.Index,
35483548 addend: usize,
35493549) link.EmitError!void {
35503550 const offset = nw.interface.end;
......@@ -3566,7 +3566,7 @@ fn addrPlaceholder(dwarf: *Dwarf, w: *std.Io.Writer) std.Io.Writer.Error!void {
35663566}
35673567fn addrSym(
35683568 dwarf: *Dwarf,
3569 nw: *MappedFile.Node.Writer,
3569 nw: *link.MappedFile.Node.Writer,
35703570 target_si: link.File.SymbolId,
35713571 addend: usize,
35723572) link.EmitError!void {
......@@ -3584,7 +3584,7 @@ fn addrSym(
35843584fn blockConst(
35853585 dwarf: *Dwarf,
35863586 pt: Zcu.PerThread,
3587 nw: *MappedFile.Node.Writer,
3587 nw: *link.MappedFile.Node.Writer,
35883588 val: Value,
35893589) link.EmitError!void {
35903590 const ty = val.typeOf(pt.zcu);
......@@ -3604,7 +3604,7 @@ fn blockConst(
36043604fn refType(
36053605 dwarf: *Dwarf,
36063606 pt: Zcu.PerThread,
3607 nw: *MappedFile.Node.Writer,
3607 nw: *link.MappedFile.Node.Writer,
36083608 ty: Type,
36093609) link.EmitError!void {
36103610 return dwarf.refConst(pt, nw, ty.toValue());
......@@ -3612,7 +3612,7 @@ fn refType(
36123612fn refConst(
36133613 dwarf: *Dwarf,
36143614 pt: Zcu.PerThread,
3615 nw: *MappedFile.Node.Writer,
3615 nw: *link.MappedFile.Node.Writer,
36163616 val: Value,
36173617) link.EmitError!void {
36183618 try dwarf.secOffset(nw, Const.get(try dwarf.getConst(pt, val), dwarf).debug_info_ni.unwrap().?, 0);
......@@ -3685,7 +3685,7 @@ fn enumConstValue(
36853685 );
36863686}
36873687
3688fn exprLoc(dwarf: *Dwarf, nw: *MappedFile.Node.Writer, loc: Loc) link.EmitError!void {
3688fn exprLoc(dwarf: *Dwarf, nw: *link.MappedFile.Node.Writer, loc: Loc) link.EmitError!void {
36893689 var buf: [@max(8, std.atomic.cache_line)]u8 = undefined;
36903690 var dw: std.Io.Writer.Discarding = .init(&buf);
36913691 try loc.write(.{ .io = &dw.writer }, dwarf);
......@@ -3694,7 +3694,7 @@ fn exprLoc(dwarf: *Dwarf, nw: *MappedFile.Node.Writer, loc: Loc) link.EmitError!
36943694 try loc.write(.{ .mf = nw }, dwarf);
36953695}
36963696
3697fn strp(dwarf: *Dwarf, s: *Str, nw: *MappedFile.Node.Writer, str: []const u8) link.EmitError!void {
3697fn strp(dwarf: *Dwarf, s: *Str, nw: *link.MappedFile.Node.Writer, str: []const u8) link.EmitError!void {
36983698 const comp = dwarf.lf.comp;
36993699 try dwarf.secOffset(nw, s.ni.unwrap().?, s.get(comp.gpa, nw.mf, str) catch |err| switch (err) {
37003700 error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{
......@@ -3704,7 +3704,7 @@ fn strp(dwarf: *Dwarf, s: *Str, nw: *MappedFile.Node.Writer, str: []const u8) li
37043704 });
37053705}
37063706
3707fn reportWriteError(dwarf: *Dwarf, nw: *const MappedFile.Node.Writer) link.Error {
3707fn reportWriteError(dwarf: *Dwarf, nw: *const link.MappedFile.Node.Writer) link.Error {
37083708 switch (nw.err.?) {
37093709 else => |e| return e,
37103710 error.MappedFileIo => return dwarf.lf.comp.link_diags.fail(
......@@ -3714,6 +3714,12 @@ fn reportWriteError(dwarf: *Dwarf, nw: *const MappedFile.Node.Writer) link.Error
37143714 }
37153715}
37163716
3717fn constPoolUser(dwarf: *Dwarf) link.ConstPool.User {
3718 return if (dwarf.lf.cast(.elf2)) |elf| .{
3719 .elf2 = elf,
3720 } else unreachable;
3721}
3722
37173723fn DeclValEnum(comptime T: type) type {
37183724 const decl_names = @typeInfo(T).@"struct".decl_names;
37193725 @setEvalBranchQuota(10 * decl_names.len);
......@@ -5239,7 +5245,6 @@ const Dwarf = @This();
52395245const InternPool = @import("../InternPool.zig");
52405246const link = @import("../link.zig");
52415247const log = std.log.scoped(.dwarf);
5242const MappedFile = @import("MappedFile.zig");
52435248const Module = @import("../Module.zig");
52445249const std = @import("std");
52455250const target_info = @import("../target.zig");
src/link/Elf.zig-1
......@@ -4410,7 +4410,6 @@ const Path = std.Build.Cache.Path;
44104410const Stat = std.Build.Cache.File.Stat;
44114411
44124412const codegen = @import("../codegen.zig");
4413const dev = @import("../dev.zig");
44144413const eh_frame = @import("Elf/eh_frame.zig");
44154414const gc = @import("Elf/gc.zig");
44164415const musl = @import("../libs/musl.zig");
src/link/Elf/Atom.zig+17-11
......@@ -945,7 +945,7 @@ const x86_64 = struct {
945945 code: ?[]const u8,
946946 it: *RelocsIterator,
947947 ) !void {
948 dev.check(.x86_64_backend);
948 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
949949 const t = &elf_file.base.comp.root_mod.resolved_target.result;
950950 const is_static = elf_file.base.isStatic();
951951 const is_dyn_lib = elf_file.isEffectivelyDynLib();
......@@ -1059,7 +1059,7 @@ const x86_64 = struct {
10591059 it: *RelocsIterator,
10601060 code: []u8,
10611061 ) !void {
1062 dev.check(.x86_64_backend);
1062 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
10631063 const t = &elf_file.base.comp.root_mod.resolved_target.result;
10641064 const diags = &elf_file.base.comp.link_diags;
10651065 const r_type: elf.R_X86_64 = @fromBackingInt(@intCast(rel.r_type()));
......@@ -1200,7 +1200,7 @@ const x86_64 = struct {
12001200 args: ResolveArgs,
12011201 code: []u8,
12021202 ) !void {
1203 dev.check(.x86_64_backend);
1203 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
12041204 const r_type: elf.R_X86_64 = @fromBackingInt(@intCast(rel.r_type()));
12051205
12061206 _, const A, const S, const GOT, _, _, const DTP = args;
......@@ -1240,7 +1240,7 @@ const x86_64 = struct {
12401240 }
12411241
12421242 fn relaxGotpcrelx(code: []u8, t: *const std.Target) !void {
1243 dev.check(.x86_64_backend);
1243 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
12441244 const old_inst = disassemble(code) orelse return error.RelaxFailure;
12451245 const inst: Instruction = switch (old_inst.encoding.mnemonic) {
12461246 .call => try .new(old_inst.prefix, .call, &.{
......@@ -1259,7 +1259,7 @@ const x86_64 = struct {
12591259 }
12601260
12611261 fn relaxRexGotpcrelx(code: []u8, t: *const std.Target) !void {
1262 dev.check(.x86_64_backend);
1262 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
12631263 const old_inst = disassemble(code) orelse return error.RelaxFailure;
12641264 switch (old_inst.encoding.mnemonic) {
12651265 .mov => {
......@@ -1279,7 +1279,7 @@ const x86_64 = struct {
12791279 code: []u8,
12801280 r_offset: usize,
12811281 ) !void {
1282 dev.check(.x86_64_backend);
1282 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
12831283 assert(rels.len == 2);
12841284 const diags = &elf_file.base.comp.link_diags;
12851285 const rel: elf.R_X86_64 = @fromBackingInt(@intCast(rels[1].r_type()));
......@@ -1319,7 +1319,7 @@ const x86_64 = struct {
13191319 code: []u8,
13201320 r_offset: usize,
13211321 ) !void {
1322 dev.check(.x86_64_backend);
1322 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
13231323 assert(rels.len == 2);
13241324 const diags = &elf_file.base.comp.link_diags;
13251325 const rel: elf.R_X86_64 = @fromBackingInt(@intCast(rels[1].r_type()));
......@@ -1366,7 +1366,7 @@ const x86_64 = struct {
13661366 }
13671367
13681368 fn canRelaxGotTpOff(code: []const u8, t: *const std.Target) bool {
1369 dev.check(.x86_64_backend);
1369 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
13701370 const old_inst = disassemble(code) orelse return false;
13711371 switch (old_inst.encoding.mnemonic) {
13721372 .mov => {
......@@ -1384,7 +1384,7 @@ const x86_64 = struct {
13841384 }
13851385
13861386 fn relaxGotTpOff(code: []u8, t: *const std.Target) void {
1387 dev.check(.x86_64_backend);
1387 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
13881388 const old_inst = disassemble(code) orelse unreachable;
13891389 switch (old_inst.encoding.mnemonic) {
13901390 .mov => {
......@@ -1401,7 +1401,7 @@ const x86_64 = struct {
14011401 }
14021402
14031403 fn relaxGotPcTlsDesc(code: []u8, target: *const std.Target) !void {
1404 dev.check(.x86_64_backend);
1404 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
14051405 const old_inst = disassemble(code) orelse return error.RelaxFailure;
14061406 switch (old_inst.encoding.mnemonic) {
14071407 .lea => {
......@@ -1425,7 +1425,7 @@ const x86_64 = struct {
14251425 code: []u8,
14261426 r_offset: usize,
14271427 ) !void {
1428 dev.check(.x86_64_backend);
1428 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
14291429 assert(rels.len == 2);
14301430 const diags = &elf_file.base.comp.link_diags;
14311431 const rel: elf.R_X86_64 = @fromBackingInt(@intCast(rels[1].r_type()));
......@@ -1492,6 +1492,7 @@ const aarch64 = struct {
14921492 ) !void {
14931493 _ = code;
14941494 _ = it;
1495 dev.checkAny(&.{ .llvm_backend, .aarch64_backend });
14951496
14961497 const r_type: elf.R_AARCH64 = @fromBackingInt(@intCast(rel.r_type()));
14971498 const is_dyn_lib = elf_file.isEffectivelyDynLib();
......@@ -1569,6 +1570,7 @@ const aarch64 = struct {
15691570 code_buffer: []u8,
15701571 ) (error{ UnexpectedRemainder, DivisionByZero } || RelocError)!void {
15711572 _ = it;
1573 dev.checkAny(&.{ .llvm_backend, .aarch64_backend });
15721574
15731575 const diags = &elf_file.base.comp.link_diags;
15741576 const r_type: elf.R_AARCH64 = @fromBackingInt(@intCast(rel.r_type()));
......@@ -1742,6 +1744,7 @@ const aarch64 = struct {
17421744 args: ResolveArgs,
17431745 code: []u8,
17441746 ) !void {
1747 dev.checkAny(&.{ .llvm_backend, .aarch64_backend });
17451748 const r_type: elf.R_AARCH64 = @fromBackingInt(@intCast(rel.r_type()));
17461749
17471750 _, const A, const S, _, _, _, _ = args;
......@@ -1772,6 +1775,7 @@ const riscv = struct {
17721775 ) !void {
17731776 _ = code;
17741777 _ = it;
1778 dev.checkAny(&.{ .llvm_backend, .riscv64_backend });
17751779
17761780 const r_type: elf.R_RISCV = @fromBackingInt(@intCast(rel.r_type()));
17771781
......@@ -1815,6 +1819,7 @@ const riscv = struct {
18151819 it: *RelocsIterator,
18161820 code: []u8,
18171821 ) !void {
1822 dev.checkAny(&.{ .llvm_backend, .riscv64_backend });
18181823 const diags = &elf_file.base.comp.link_diags;
18191824 const r_type: elf.R_RISCV = @fromBackingInt(@intCast(rel.r_type()));
18201825 const r_offset = std.math.cast(usize, rel.r_offset) orelse return error.Overflow;
......@@ -1951,6 +1956,7 @@ const riscv = struct {
19511956 args: ResolveArgs,
19521957 code: []u8,
19531958 ) !void {
1959 dev.checkAny(&.{ .llvm_backend, .riscv64_backend });
19541960 const r_type: elf.R_RISCV = @fromBackingInt(@intCast(rel.r_type()));
19551961
19561962 _, const A, const S, const GOT, _, _, const DTP = args;
src/link/Elf/Thunk.zig+2
......@@ -91,6 +91,7 @@ pub const Index = u32;
9191
9292const aarch64 = struct {
9393 fn write(thunk: Thunk, elf_file: *Elf, writer: anytype) !void {
94 dev.checkAny(&.{ .llvm_backend, .aarch64_backend });
9495 for (thunk.symbols.keys(), 0..) |ref, i| {
9596 const sym = elf_file.symbol(ref).?;
9697 const saddr = thunk.address(elf_file) + @as(i64, @intCast(i * trampoline_size));
......@@ -113,6 +114,7 @@ const aarch64 = struct {
113114};
114115
115116const assert = std.debug.assert;
117const dev = @import("../../dev.zig");
116118const elf = std.elf;
117119const log = std.log.scoped(.link);
118120const math = std.math;
src/link/Elf/ZigObject.zig+2
......@@ -2396,6 +2396,7 @@ const TlsTable = std.array_hash_map.Auto(Atom.Index, void);
23962396
23972397const x86_64 = struct {
23982398 fn writeTrampolineCode(source_addr: i64, target_addr: i64, buf: *[max_trampoline_len]u8) ![]u8 {
2399 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
23992400 const disp = @as(i64, @intCast(target_addr)) - source_addr - 5;
24002401 var bytes = [_]u8{
24012402 0xe9, 0x00, 0x00, 0x00, 0x00, // jmp rel32
......@@ -2411,6 +2412,7 @@ const assert = std.debug.assert;
24112412const build_options = @import("build_options");
24122413const builtin = @import("builtin");
24132414const codegen = @import("../../codegen.zig");
2415const dev = @import("../../dev.zig");
24142416const elf = std.elf;
24152417const link = @import("../../link.zig");
24162418const log = std.log.scoped(.link);
src/link/Elf/eh_frame.zig+4
......@@ -535,6 +535,7 @@ pub fn writeEhFrameHdr(elf_file: *Elf, writer: anytype) !void {
535535
536536const x86_64 = struct {
537537 fn resolveReloc(rec: anytype, elf_file: *Elf, rel: elf.Elf64_Rela, source: i64, target: i64, data: []u8) !void {
538 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
538539 const r_type: elf.R_X86_64 = @fromBackingInt(@intCast(rel.r_type()));
539540 switch (r_type) {
540541 .NONE => {},
......@@ -549,6 +550,7 @@ const x86_64 = struct {
549550
550551const aarch64 = struct {
551552 fn resolveReloc(rec: anytype, elf_file: *Elf, rel: elf.Elf64_Rela, source: i64, target: i64, data: []u8) !void {
553 dev.checkAny(&.{ .llvm_backend, .aarch64_backend });
552554 const r_type: elf.R_AARCH64 = @fromBackingInt(@intCast(rel.r_type()));
553555 switch (r_type) {
554556 .NONE => {},
......@@ -562,6 +564,7 @@ const aarch64 = struct {
562564
563565const riscv = struct {
564566 fn resolveReloc(rec: anytype, elf_file: *Elf, rel: elf.Elf64_Rela, source: i64, target: i64, data: []u8) !void {
567 dev.checkAny(&.{ .llvm_backend, .riscv64_backend });
565568 const r_type: elf.R_RISCV = @fromBackingInt(@intCast(rel.r_type()));
566569 switch (r_type) {
567570 .NONE => {},
......@@ -584,6 +587,7 @@ fn reportInvalidReloc(rec: anytype, elf_file: *Elf, rel: elf.Elf64_Rela) !void {
584587
585588const std = @import("std");
586589const assert = std.debug.assert;
590const dev = @import("../../dev.zig");
587591const elf = std.elf;
588592const math = std.math;
589593const relocs_log = std.log.scoped(.link_relocs);
src/link/Elf/synthetic_sections.zig+5
......@@ -772,6 +772,7 @@ pub const PltSection = struct {
772772
773773 const x86_64 = struct {
774774 fn write(plt: PltSection, elf_file: *Elf, writer: *std.Io.Writer) !void {
775 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
775776 const shdrs = elf_file.sections.items(.shdr);
776777 const plt_addr = shdrs[elf_file.section_indexes.plt.?].sh_addr;
777778 const got_plt_addr = shdrs[elf_file.section_indexes.got_plt.?].sh_addr;
......@@ -807,6 +808,7 @@ pub const PltSection = struct {
807808
808809 const aarch64 = struct {
809810 fn write(plt: PltSection, elf_file: *Elf, writer: *std.Io.Writer) !void {
811 dev.checkAny(&.{ .llvm_backend, .aarch64_backend });
810812 {
811813 const shdrs = elf_file.sections.items(.shdr);
812814 const plt_addr: i64 = @intCast(shdrs[elf_file.section_indexes.plt.?].sh_addr);
......@@ -949,6 +951,7 @@ pub const PltGotSection = struct {
949951
950952 const x86_64 = struct {
951953 pub fn write(plt_got: PltGotSection, elf_file: *Elf, writer: *std.Io.Writer) !void {
954 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
952955 for (plt_got.symbols.items) |ref| {
953956 const sym = elf_file.symbol(ref).?;
954957 const target_addr = sym.gotAddress(elf_file);
......@@ -967,6 +970,7 @@ pub const PltGotSection = struct {
967970
968971 const aarch64 = struct {
969972 fn write(plt_got: PltGotSection, elf_file: *Elf, writer: *std.Io.Writer) !void {
973 dev.checkAny(&.{ .llvm_backend, .aarch64_backend });
970974 for (plt_got.symbols.items) |ref| {
971975 const sym = elf_file.symbol(ref).?;
972976 const target_addr = sym.gotAddress(elf_file);
......@@ -1518,6 +1522,7 @@ fn writeInt(value: anytype, elf_file: *Elf, writer: *std.Io.Writer) !void {
15181522
15191523const assert = std.debug.assert;
15201524const builtin = @import("builtin");
1525const dev = @import("../../dev.zig");
15211526const elf = std.elf;
15221527const math = std.math;
15231528const mem = std.mem;
src/link/Elf2.zig+1-2
......@@ -7,11 +7,10 @@ const log = std.log.scoped(.link);
77
88const codegen = @import("../codegen.zig");
99const Compilation = @import("../Compilation.zig");
10const dev = @import("../dev.zig");
1110const Dwarf = @import("Dwarf2.zig");
1211const InternPool = @import("../InternPool.zig");
1312const link = @import("../link.zig");
14const MappedFile = @import("MappedFile.zig");
13const MappedFile = link.MappedFile;
1514const target_util = @import("../target.zig");
1615const tracy = @import("../tracy.zig");
1716const Type = @import("../Type.zig");
src/link/MachO.zig-1
......@@ -5503,4 +5503,3 @@ const Value = @import("../Value.zig");
55035503const UnwindInfo = @import("MachO/UnwindInfo.zig");
55045504const WeakBind = bind.WeakBind;
55055505const ZigObject = @import("MachO/ZigObject.zig");
5506const dev = @import("../dev.zig");
src/link/MachO/Atom.zig+2-2
......@@ -853,7 +853,7 @@ fn resolveRelocInner(
853853
854854const x86_64 = struct {
855855 fn relaxGotLoad(self: Atom, code: []u8, rel: Relocation, macho_file: *MachO) ResolveError!void {
856 dev.check(.x86_64_backend);
856 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
857857 const t = &macho_file.base.comp.root_mod.resolved_target.result;
858858 const diags = &macho_file.base.comp.link_diags;
859859 const old_inst = disassemble(code) orelse return error.RelaxFail;
......@@ -879,7 +879,7 @@ const x86_64 = struct {
879879 }
880880
881881 fn relaxTlv(code: []u8, t: *const std.Target) error{RelaxFail}!void {
882 dev.check(.x86_64_backend);
882 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
883883 const old_inst = disassemble(code) orelse return error.RelaxFail;
884884 switch (old_inst.encoding.mnemonic) {
885885 .mov => {
src/link/MachO/Object.zig+5
......@@ -3,6 +3,7 @@ const Object = @This();
33const trace = @import("../../tracy.zig").trace;
44const Archive = @import("Archive.zig");
55const Atom = @import("Atom.zig");
6const dev = @import("../../dev.zig");
67const Dwarf = @import("Dwarf.zig");
78const File = @import("file.zig").File;
89const MachO = @import("../MachO.zig");
......@@ -2826,6 +2827,7 @@ const x86_64 = struct {
28262827 handle: File.Handle,
28272828 macho_file: *MachO,
28282829 ) !void {
2830 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
28292831 const comp = macho_file.base.comp;
28302832 const io = comp.io;
28312833 const gpa = comp.gpa;
......@@ -2938,6 +2940,7 @@ const x86_64 = struct {
29382940 }
29392941
29402942 fn validateRelocType(rel: macho.relocation_info, rel_type: macho.reloc_type_x86_64, is_extern: bool) !Relocation.Type {
2943 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
29412944 switch (rel_type) {
29422945 .X86_64_RELOC_UNSIGNED => {
29432946 if (rel.r_pcrel == 1) return error.Pcrel;
......@@ -2995,6 +2998,7 @@ const aarch64 = struct {
29952998 handle: File.Handle,
29962999 macho_file: *MachO,
29973000 ) !void {
3001 dev.checkAny(&.{ .llvm_backend, .aarch64_backend });
29983002 const comp = macho_file.base.comp;
29993003 const io = comp.io;
30003004 const gpa = comp.gpa;
......@@ -3131,6 +3135,7 @@ const aarch64 = struct {
31313135 }
31323136
31333137 fn validateRelocType(rel: macho.relocation_info, rel_type: macho.reloc_type_arm64, is_extern: bool) !Relocation.Type {
3138 dev.checkAny(&.{ .llvm_backend, .aarch64_backend });
31343139 switch (rel_type) {
31353140 .ARM64_RELOC_UNSIGNED => {
31363141 if (rel.r_pcrel == 1) return error.Pcrel;
src/link/MachO/ZigObject.zig+2
......@@ -1744,6 +1744,7 @@ const TlvInitializerTable = std.array_hash_map.Auto(Atom.Index, TlvInitializer);
17441744
17451745const x86_64 = struct {
17461746 fn writeTrampolineCode(source_addr: u64, target_addr: u64, buf: *[max_trampoline_len]u8) ![]u8 {
1747 dev.checkAny(&.{ .llvm_backend, .x86_64_backend });
17471748 const disp = @as(i64, @intCast(target_addr)) - @as(i64, @intCast(source_addr)) - 5;
17481749 var bytes = [_]u8{
17491750 0xe9, 0x00, 0x00, 0x00, 0x00, // jmp rel32
......@@ -1758,6 +1759,7 @@ const x86_64 = struct {
17581759const assert = std.debug.assert;
17591760const builtin = @import("builtin");
17601761const codegen = @import("../../codegen.zig");
1762const dev = @import("../../dev.zig");
17611763const link = @import("../../link.zig");
17621764const log = std.log.scoped(.link);
17631765const macho = std.macho;
src/link/Spork8.zig-2
......@@ -18,7 +18,6 @@ const Mir = @import("../codegen/spork8/Mir.zig");
1818const link = @import("../link.zig");
1919const Compilation = @import("../Compilation.zig");
2020const Liveness = @import("../Air/Liveness.zig");
21const dev = @import("../dev.zig");
2221const Value = @import("../Value.zig");
2322
2423base: link.File,
......@@ -89,7 +88,6 @@ pub fn updateFunc(
8988 func_index: InternPool.Index,
9089 any_mir: *const codegen.AnyMir,
9190) !void {
92 dev.check(.spork8_backend);
9391 // This linker implementation only works with `std.lang.CompilerBackend.zsf_spork8`.
9492 const mir = &any_mir.spork8;
9593 const zcu = pt.zcu;
src/link/Wasm.zig-3
......@@ -38,7 +38,6 @@ const Dwarf = @import("Dwarf.zig");
3838const InternPool = @import("../InternPool.zig");
3939const Zcu = @import("../Zcu.zig");
4040const codegen = @import("../codegen.zig");
41const dev = @import("../dev.zig");
4241const link = @import("../link.zig");
4342const trace = @import("../tracy.zig").trace;
4443const wasi_libc = @import("../libs/wasi_libc.zig");
......@@ -3575,8 +3574,6 @@ pub fn updateFunc(
35753574 func_index: InternPool.Index,
35763575 any_mir: *const codegen.AnyMir,
35773576) !void {
3578 dev.check(.wasm_backend);
3579
35803577 // This linker implementation only works with codegen backend `.stage2_wasm`.
35813578 const mir = &any_mir.wasm;
35823579 const zcu = pt.zcu;
src/main.zig+1-1
......@@ -36,7 +36,7 @@ const Module = @import("Module.zig");
3636
3737test {
3838 _ = @import("codegen.zig");
39 _ = @import("link/MappedFile.zig");
39 _ = link.MappedFile;
4040}
4141
4242const thread_stack_size = 60 << 20;
src/target.zig+5-1
......@@ -2,6 +2,7 @@ const builtin = @import("builtin");
22const std = @import("std");
33const assert = std.debug.assert;
44
5const dev = @import("dev.zig");
56const Type = @import("Type.zig");
67const AddressSpace = std.lang.AddressSpace;
78const Alignment = @import("InternPool.zig").Alignment;
......@@ -855,7 +856,10 @@ pub fn functionPointerMask(target: *const std.Target) ?u64 {
855856
856857pub fn supportsTailCall(target: *const std.Target, backend: std.lang.CompilerBackend) bool {
857858 switch (backend) {
858 .stage2_llvm => return @import("codegen/llvm.zig").supportsTailCall(target),
859 .stage2_llvm => {
860 dev.check(.llvm_backend);
861 return @import("codegen/llvm.zig").supportsTailCall(target);
862 },
859863 .stage2_c => return true,
860864 else => return false,
861865 }