diff --git a/lib/std/Target.zig b/lib/std/Target.zig index ce439a0ab1..973c907e39 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -760,52 +760,59 @@ pub const Abi = enum { }; pub const ObjectFormat = enum { - /// Common Object File Format (Windows) - coff, - /// DirectX Container - dxcontainer, - /// Executable and Linking Format - elf, - /// macOS relocatables - macho, - /// Standard, Portable Intermediate Representation V - spirv, - /// WebAssembly - wasm, - /// C source code + /// C source code. c, - /// Intel IHEX + /// The Common Object File Format used by Windows and UEFI. + coff, + /// The DirectX Container format containing either DXIL or DXBC. + dxcontainer, + /// The Executable and Linkable Format used by many Unixes. + elf, + /// The Generalized Object File Format used by z/OS. + goff, + /// The Intel HEX format for storing binary code in ASCII text. hex, + /// The Mach object format used by macOS and other Apple platforms. + macho, + /// Nvidia's PTX (Parallel Thread Execution) assembly language. + nvptx, + /// The a.out format used by Plan 9 from Bell Labs. + plan9, /// Machine code with no metadata. raw, - /// Plan 9 from Bell Labs - plan9, - /// Nvidia PTX format - nvptx, + /// The Khronos Group's Standard Portable Intermediate Representation V. + spirv, + /// The WebAssembly binary format. + wasm, + /// The eXtended Common Object File Format used by AIX. + xcoff, pub fn fileExt(of: ObjectFormat, arch: Cpu.Arch) [:0]const u8 { return switch (of) { - .coff => ".obj", - .elf, .macho, .wasm => ".o", .c => ".c", - .spirv => ".spv", - .hex => ".ihex", - .raw => ".bin", - .plan9 => arch.plan9Ext(), - .nvptx => ".ptx", + .coff => ".obj", .dxcontainer => ".dxil", + .elf, .goff, .macho, .wasm, .xcoff => ".o", + .hex => ".ihex", + .nvptx => ".ptx", + .plan9 => arch.plan9Ext(), + .raw => ".bin", + .spirv => ".spv", }; } pub fn default(os_tag: Os.Tag, arch: Cpu.Arch) ObjectFormat { return switch (os_tag) { - .windows, .uefi => .coff, - .ios, .macos, .watchos, .tvos, .visionos => .macho, + .aix => .xcoff, + .driverkit, .ios, .macos, .tvos, .visionos, .watchos => .macho, .plan9 => .plan9, + .uefi, .windows => .coff, + .zos => .goff, else => switch (arch) { - .wasm32, .wasm64 => .wasm, - .spirv32, .spirv64 => .spirv, + .dxil => .dxcontainer, .nvptx, .nvptx64 => .nvptx, + .spirv, .spirv32, .spirv64 => .spirv, + .wasm32, .wasm64 => .wasm, else => .elf, }, }; diff --git a/lib/std/zig.zig b/lib/std/zig.zig index 01d3aafa75..c11b5319c5 100644 --- a/lib/std/zig.zig +++ b/lib/std/zig.zig @@ -163,7 +163,7 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe }, .Obj => return std.fmt.allocPrint(allocator, "{s}.obj", .{root_name}), }, - .elf => switch (options.output_mode) { + .elf, .goff, .xcoff => switch (options.output_mode) { .Exe => return allocator.dupe(u8, root_name), .Lib => { switch (options.link_mode orelse .static) { diff --git a/src/Compilation/Config.zig b/src/Compilation/Config.zig index 3f2e5809d4..6be2ae80f8 100644 --- a/src/Compilation/Config.zig +++ b/src/Compilation/Config.zig @@ -434,7 +434,7 @@ pub fn resolve(options: Options) ResolveError!Config { const debug_format: DebugFormat = b: { if (root_strip and !options.any_non_stripped) break :b .strip; break :b switch (target.ofmt) { - .elf, .macho, .wasm => .{ .dwarf = .@"32" }, + .elf, .goff, .macho, .wasm, .xcoff => .{ .dwarf = .@"32" }, .coff => .code_view, .c => switch (target.os.tag) { .windows, .uefi => .code_view, diff --git a/src/link.zig b/src/link.zig index 59ace7ce3e..3463a77147 100644 --- a/src/link.zig +++ b/src/link.zig @@ -902,6 +902,8 @@ pub const File = struct { .c => .c, .spirv => .spirv, .nvptx => .nvptx, + .goff => @panic("TODO implement goff object format"), + .xcoff => @panic("TODO implement xcoff object format"), .hex => @panic("TODO implement hex object format"), .raw => @panic("TODO implement raw object format"), .dxcontainer => @panic("TODO implement dxcontainer object format"), diff --git a/src/target.zig b/src/target.zig index f5cdf6627d..eb48b7b2e6 100644 --- a/src/target.zig +++ b/src/target.zig @@ -98,14 +98,16 @@ pub fn hasLlvmSupport(target: std.Target, ofmt: std.Target.ObjectFormat) bool { => return false, .coff, - .elf, - .macho, - .wasm, - .spirv, - .hex, - .raw, - .nvptx, .dxcontainer, + .elf, + .goff, + .hex, + .macho, + .nvptx, + .spirv, + .raw, + .wasm, + .xcoff, => {}, }