authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-07-20 07:43:40-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-07-20 07:43:40-04:00
log2e65244cae7e4365ecf3aa6857b84451272316a1
tree2607649bf5c9e27778635c25827680794aa04423
parent4f742c4cfc3c3134a0d6ebfdfc354286ae97b2c1

dev: fix llvm backend checks


9 files changed, 15 insertions(+), 11 deletions(-)

src/Compilation.zig+1-2
...@@ -1729,7 +1729,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil...@@ -1729,7 +1729,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
1729 comp.emit_llvm_ir != null or1729 comp.emit_llvm_ir != null or
1730 comp.emit_llvm_bc != null))1730 comp.emit_llvm_bc != null))
1731 {1731 {
1732 dev.check(.llvm_backend);
1733 if (opt_zcu) |zcu| zcu.llvm_object = try LlvmObject.create(arena, comp);1732 if (opt_zcu) |zcu| zcu.llvm_object = try LlvmObject.create(arena, comp);
1734 }1733 }
17351734
...@@ -2704,7 +2703,7 @@ pub fn emitLlvmObject(...@@ -2704,7 +2703,7 @@ pub fn emitLlvmObject(
2704 arena: Allocator,2703 arena: Allocator,
2705 default_emit: Emit,2704 default_emit: Emit,
2706 bin_emit_loc: ?EmitLoc,2705 bin_emit_loc: ?EmitLoc,
2707 llvm_object: *LlvmObject,2706 llvm_object: LlvmObject.Ptr,
2708 prog_node: std.Progress.Node,2707 prog_node: std.Progress.Node,
2709) !void {2708) !void {
2710 const sub_prog_node = prog_node.start("LLVM Emit Object", 0);2709 const sub_prog_node = prog_node.start("LLVM Emit Object", 0);
src/Zcu.zig+1-1
...@@ -58,7 +58,7 @@ comp: *Compilation,...@@ -58,7 +58,7 @@ comp: *Compilation,
58/// Usually, the LlvmObject is managed by linker code, however, in the case58/// Usually, the LlvmObject is managed by linker code, however, in the case
59/// that -fno-emit-bin is specified, the linker code never executes, so we59/// that -fno-emit-bin is specified, the linker code never executes, so we
60/// store the LlvmObject here.60/// store the LlvmObject here.
61llvm_object: if (dev.env.supports(.llvm_backend)) ?*LlvmObject else ?noreturn,61llvm_object: ?LlvmObject.Ptr,
6262
63/// Pointer to externally managed resource.63/// Pointer to externally managed resource.
64root_mod: *Package.Module,64root_mod: *Package.Module,
src/codegen/llvm.zig+5-1
...@@ -26,6 +26,7 @@ const wasm_c_abi = @import("../arch/wasm/abi.zig");...@@ -26,6 +26,7 @@ const wasm_c_abi = @import("../arch/wasm/abi.zig");
26const aarch64_c_abi = @import("../arch/aarch64/abi.zig");26const aarch64_c_abi = @import("../arch/aarch64/abi.zig");
27const arm_c_abi = @import("../arch/arm/abi.zig");27const arm_c_abi = @import("../arch/arm/abi.zig");
28const riscv_c_abi = @import("../arch/riscv64/abi.zig");28const riscv_c_abi = @import("../arch/riscv64/abi.zig");
29const dev = @import("../dev.zig");
2930
30const target_util = @import("../target.zig");31const target_util = @import("../target.zig");
31const libcFloatPrefix = target_util.libcFloatPrefix;32const libcFloatPrefix = target_util.libcFloatPrefix;
...@@ -865,9 +866,12 @@ pub const Object = struct {...@@ -865,9 +866,12 @@ pub const Object = struct {
865 field_index: u32,866 field_index: u32,
866 };867 };
867868
869 pub const Ptr = if (dev.env.supports(.llvm_backend)) *Object else noreturn;
870
868 pub const TypeMap = std.AutoHashMapUnmanaged(InternPool.Index, Builder.Type);871 pub const TypeMap = std.AutoHashMapUnmanaged(InternPool.Index, Builder.Type);
869872
870 pub fn create(arena: Allocator, comp: *Compilation) !*Object {873 pub fn create(arena: Allocator, comp: *Compilation) !Ptr {
874 dev.check(.llvm_backend);
871 const gpa = comp.gpa;875 const gpa = comp.gpa;
872 const target = comp.root_mod.resolved_target.result;876 const target = comp.root_mod.resolved_target.result;
873 const llvm_target_triple = try targetTriple(arena, target);877 const llvm_target_triple = try targetTriple(arena, target);
src/link.zig+1-1
...@@ -968,7 +968,7 @@ pub const File = struct {...@@ -968,7 +968,7 @@ pub const File = struct {
968 pub fn emitLlvmObject(968 pub fn emitLlvmObject(
969 base: File,969 base: File,
970 arena: Allocator,970 arena: Allocator,
971 llvm_object: *LlvmObject,971 llvm_object: LlvmObject.Ptr,
972 prog_node: std.Progress.Node,972 prog_node: std.Progress.Node,
973 ) !void {973 ) !void {
974 return base.comp.emitLlvmObject(arena, base.emit, .{974 return base.comp.emitLlvmObject(arena, base.emit, .{
src/link/Coff.zig+2-1
...@@ -4,7 +4,7 @@...@@ -4,7 +4,7 @@
4//! LLD is also the default linker for LLVM.4//! LLD is also the default linker for LLVM.
55
6/// If this is not null, an object file is created by LLVM and emitted to zcu_object_sub_path.6/// If this is not null, an object file is created by LLVM and emitted to zcu_object_sub_path.
7llvm_object: ?*LlvmObject = null,7llvm_object: ?LlvmObject.Ptr = null,
88
9base: link.File,9base: link.File,
10image_base: u64,10image_base: u64,
...@@ -2765,6 +2765,7 @@ const StringTable = @import("StringTable.zig");...@@ -2765,6 +2765,7 @@ const StringTable = @import("StringTable.zig");
2765const Type = @import("../Type.zig");2765const Type = @import("../Type.zig");
2766const Value = @import("../Value.zig");2766const Value = @import("../Value.zig");
2767const AnalUnit = InternPool.AnalUnit;2767const AnalUnit = InternPool.AnalUnit;
2768const dev = @import("../dev.zig");
27682769
2769pub const base_tag: link.File.Tag = .coff;2770pub const base_tag: link.File.Tag = .coff;
27702771
src/link/Elf.zig+1-1
...@@ -30,7 +30,7 @@ entry_name: ?[]const u8,...@@ -30,7 +30,7 @@ entry_name: ?[]const u8,
30ptr_width: PtrWidth,30ptr_width: PtrWidth,
3131
32/// If this is not null, an object file is created by LLVM and emitted to zcu_object_sub_path.32/// If this is not null, an object file is created by LLVM and emitted to zcu_object_sub_path.
33llvm_object: ?*LlvmObject = null,33llvm_object: ?LlvmObject.Ptr = null,
3434
35/// A list of all input files.35/// A list of all input files.
36/// Index of each input file also encodes the priority or precedence of one input file36/// Index of each input file also encodes the priority or precedence of one input file
src/link/MachO.zig+2-2
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1base: link.File,1base: link.File,
22
3/// If this is not null, an object file is created by LLVM and emitted to zcu_object_sub_path.3/// If this is not null, an object file is created by LLVM and emitted to zcu_object_sub_path.
4llvm_object: ?*LlvmObject = null,4llvm_object: ?LlvmObject.Ptr = null,
55
6/// Debug symbols bundle (or dSym).6/// Debug symbols bundle (or dSym).
7d_sym: ?DebugSymbols = null,7d_sym: ?DebugSymbols = null,
...@@ -4510,7 +4510,6 @@ const dead_strip = @import("MachO/dead_strip.zig");...@@ -4510,7 +4510,6 @@ const dead_strip = @import("MachO/dead_strip.zig");
4510const eh_frame = @import("MachO/eh_frame.zig");4510const eh_frame = @import("MachO/eh_frame.zig");
4511const fat = @import("MachO/fat.zig");4511const fat = @import("MachO/fat.zig");
4512const link = @import("../link.zig");4512const link = @import("../link.zig");
4513const llvm_backend = @import("../codegen/llvm.zig");
4514const load_commands = @import("MachO/load_commands.zig");4513const load_commands = @import("MachO/load_commands.zig");
4515const relocatable = @import("MachO/relocatable.zig");4514const relocatable = @import("MachO/relocatable.zig");
4516const tapi = @import("tapi.zig");4515const tapi = @import("tapi.zig");
...@@ -4562,6 +4561,7 @@ const UnwindInfo = @import("MachO/UnwindInfo.zig");...@@ -4562,6 +4561,7 @@ const UnwindInfo = @import("MachO/UnwindInfo.zig");
4562const WeakBind = bind.WeakBind;4561const WeakBind = bind.WeakBind;
4563const ZigGotSection = synthetic.ZigGotSection;4562const ZigGotSection = synthetic.ZigGotSection;
4564const ZigObject = @import("MachO/ZigObject.zig");4563const ZigObject = @import("MachO/ZigObject.zig");
4564const dev = @import("../dev.zig");
45654565
4566pub const MachError = error{4566pub const MachError = error{
4567 /// Not enough permissions held to perform the requested kernel4567 /// Not enough permissions held to perform the requested kernel
src/link/NvPtx.zig+1-1
...@@ -23,7 +23,7 @@ const Liveness = @import("../Liveness.zig");...@@ -23,7 +23,7 @@ const Liveness = @import("../Liveness.zig");
23const LlvmObject = @import("../codegen/llvm.zig").Object;23const LlvmObject = @import("../codegen/llvm.zig").Object;
2424
25base: link.File,25base: link.File,
26llvm_object: *LlvmObject,26llvm_object: LlvmObject.Ptr,
2727
28pub fn createEmpty(28pub fn createEmpty(
29 arena: Allocator,29 arena: Allocator,
src/link/Wasm.zig+1-1
...@@ -61,7 +61,7 @@ export_table: bool,...@@ -61,7 +61,7 @@ export_table: bool,
61/// Output name of the file61/// Output name of the file
62name: []const u8,62name: []const u8,
63/// If this is not null, an object file is created by LLVM and linked with LLD afterwards.63/// If this is not null, an object file is created by LLVM and linked with LLD afterwards.
64llvm_object: ?*LlvmObject = null,64llvm_object: ?LlvmObject.Ptr = null,
65/// The file index of a `ZigObject`. This will only contain a valid index when a zcu exists,65/// The file index of a `ZigObject`. This will only contain a valid index when a zcu exists,
66/// and the chosen backend is the Wasm backend.66/// and the chosen backend is the Wasm backend.
67zig_object_index: File.Index = .null,67zig_object_index: File.Index = .null,