zig

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

commit 2e65244cae7e4365ecf3aa6857b84451272316a1 (tree)
parent 4f742c4cfc3c3134a0d6ebfdfc354286ae97b2c1
Author: Jacob Young <jacobly0@users.noreply.github.com>
Date:   Sat, 20 Jul 2024 07:43:40 -0400

dev: fix llvm backend checks

Diffstat:
Msrc/Compilation.zig | 3+--
Msrc/Zcu.zig | 2+-
Msrc/codegen/llvm.zig | 6+++++-
Msrc/link.zig | 2+-
Msrc/link/Coff.zig | 3++-
Msrc/link/Elf.zig | 2+-
Msrc/link/MachO.zig | 4++--
Msrc/link/NvPtx.zig | 2+-
Msrc/link/Wasm.zig | 2+-
9 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/Compilation.zig b/src/Compilation.zig @@ -1729,7 +1729,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil comp.emit_llvm_ir != null or comp.emit_llvm_bc != null)) { - dev.check(.llvm_backend); if (opt_zcu) |zcu| zcu.llvm_object = try LlvmObject.create(arena, comp); } @@ -2704,7 +2703,7 @@ pub fn emitLlvmObject( arena: Allocator, default_emit: Emit, bin_emit_loc: ?EmitLoc, - llvm_object: *LlvmObject, + llvm_object: LlvmObject.Ptr, prog_node: std.Progress.Node, ) !void { const sub_prog_node = prog_node.start("LLVM Emit Object", 0); diff --git a/src/Zcu.zig b/src/Zcu.zig @@ -58,7 +58,7 @@ comp: *Compilation, /// Usually, the LlvmObject is managed by linker code, however, in the case /// that -fno-emit-bin is specified, the linker code never executes, so we /// store the LlvmObject here. -llvm_object: if (dev.env.supports(.llvm_backend)) ?*LlvmObject else ?noreturn, +llvm_object: ?LlvmObject.Ptr, /// Pointer to externally managed resource. root_mod: *Package.Module, diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig @@ -26,6 +26,7 @@ const wasm_c_abi = @import("../arch/wasm/abi.zig"); const aarch64_c_abi = @import("../arch/aarch64/abi.zig"); const arm_c_abi = @import("../arch/arm/abi.zig"); const riscv_c_abi = @import("../arch/riscv64/abi.zig"); +const dev = @import("../dev.zig"); const target_util = @import("../target.zig"); const libcFloatPrefix = target_util.libcFloatPrefix; @@ -865,9 +866,12 @@ pub const Object = struct { field_index: u32, }; + pub const Ptr = if (dev.env.supports(.llvm_backend)) *Object else noreturn; + pub const TypeMap = std.AutoHashMapUnmanaged(InternPool.Index, Builder.Type); - pub fn create(arena: Allocator, comp: *Compilation) !*Object { + pub fn create(arena: Allocator, comp: *Compilation) !Ptr { + dev.check(.llvm_backend); const gpa = comp.gpa; const target = comp.root_mod.resolved_target.result; const llvm_target_triple = try targetTriple(arena, target); diff --git a/src/link.zig b/src/link.zig @@ -968,7 +968,7 @@ pub const File = struct { pub fn emitLlvmObject( base: File, arena: Allocator, - llvm_object: *LlvmObject, + llvm_object: LlvmObject.Ptr, prog_node: std.Progress.Node, ) !void { return base.comp.emitLlvmObject(arena, base.emit, .{ diff --git a/src/link/Coff.zig b/src/link/Coff.zig @@ -4,7 +4,7 @@ //! LLD is also the default linker for LLVM. /// If this is not null, an object file is created by LLVM and emitted to zcu_object_sub_path. -llvm_object: ?*LlvmObject = null, +llvm_object: ?LlvmObject.Ptr = null, base: link.File, image_base: u64, @@ -2765,6 +2765,7 @@ const StringTable = @import("StringTable.zig"); const Type = @import("../Type.zig"); const Value = @import("../Value.zig"); const AnalUnit = InternPool.AnalUnit; +const dev = @import("../dev.zig"); pub const base_tag: link.File.Tag = .coff; diff --git a/src/link/Elf.zig b/src/link/Elf.zig @@ -30,7 +30,7 @@ entry_name: ?[]const u8, ptr_width: PtrWidth, /// If this is not null, an object file is created by LLVM and emitted to zcu_object_sub_path. -llvm_object: ?*LlvmObject = null, +llvm_object: ?LlvmObject.Ptr = null, /// A list of all input files. /// Index of each input file also encodes the priority or precedence of one input file diff --git a/src/link/MachO.zig b/src/link/MachO.zig @@ -1,7 +1,7 @@ base: link.File, /// If this is not null, an object file is created by LLVM and emitted to zcu_object_sub_path. -llvm_object: ?*LlvmObject = null, +llvm_object: ?LlvmObject.Ptr = null, /// Debug symbols bundle (or dSym). d_sym: ?DebugSymbols = null, @@ -4510,7 +4510,6 @@ const dead_strip = @import("MachO/dead_strip.zig"); const eh_frame = @import("MachO/eh_frame.zig"); const fat = @import("MachO/fat.zig"); const link = @import("../link.zig"); -const llvm_backend = @import("../codegen/llvm.zig"); const load_commands = @import("MachO/load_commands.zig"); const relocatable = @import("MachO/relocatable.zig"); const tapi = @import("tapi.zig"); @@ -4562,6 +4561,7 @@ const UnwindInfo = @import("MachO/UnwindInfo.zig"); const WeakBind = bind.WeakBind; const ZigGotSection = synthetic.ZigGotSection; const ZigObject = @import("MachO/ZigObject.zig"); +const dev = @import("../dev.zig"); pub const MachError = error{ /// Not enough permissions held to perform the requested kernel diff --git a/src/link/NvPtx.zig b/src/link/NvPtx.zig @@ -23,7 +23,7 @@ const Liveness = @import("../Liveness.zig"); const LlvmObject = @import("../codegen/llvm.zig").Object; base: link.File, -llvm_object: *LlvmObject, +llvm_object: LlvmObject.Ptr, pub fn createEmpty( arena: Allocator, diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig @@ -61,7 +61,7 @@ export_table: bool, /// Output name of the file name: []const u8, /// If this is not null, an object file is created by LLVM and linked with LLD afterwards. -llvm_object: ?*LlvmObject = null, +llvm_object: ?LlvmObject.Ptr = null, /// The file index of a `ZigObject`. This will only contain a valid index when a zcu exists, /// and the chosen backend is the Wasm backend. zig_object_index: File.Index = .null,