| author | |
| committer | |
| log | 6316fd95351fb207d0680f396123a455a91ea4a2 |
| tree | 0d65c18c41e4375762a88dc57d265b4814495fb1 |
| parent | fc2924080694d68945308d394751a2ec4841b3c0 |
Also improve the docs a bit, and handle driverkit and dxil in default().5 files changed, 43 insertions(+), 32 deletions(-)
lib/std/Target.zig+33-26| ... | @@ -760,52 +760,59 @@ pub const Abi = enum { | ... | @@ -760,52 +760,59 @@ pub const Abi = enum { |
| 760 | }; | 760 | }; |
| 761 | 761 | ||
| 762 | pub const ObjectFormat = enum { | 762 | pub const ObjectFormat = enum { |
| 763 | /// Common Object File Format (Windows) | 763 | /// C source code. |
| 764 | c, | ||
| 765 | /// The Common Object File Format used by Windows and UEFI. | ||
| 764 | coff, | 766 | coff, |
| 765 | /// DirectX Container | 767 | /// The DirectX Container format containing either DXIL or DXBC. |
| 766 | dxcontainer, | 768 | dxcontainer, |
| 767 | /// Executable and Linking Format | 769 | /// The Executable and Linkable Format used by many Unixes. |
| 768 | elf, | 770 | elf, |
| 769 | /// macOS relocatables | 771 | /// The Generalized Object File Format used by z/OS. |
| 770 | macho, | 772 | goff, |
| 771 | /// Standard, Portable Intermediate Representation V | 773 | /// The Intel HEX format for storing binary code in ASCII text. |
| 772 | spirv, | ||
| 773 | /// WebAssembly | ||
| 774 | wasm, | ||
| 775 | /// C source code | ||
| 776 | c, | ||
| 777 | /// Intel IHEX | ||
| 778 | hex, | 774 | hex, |
| 775 | /// The Mach object format used by macOS and other Apple platforms. | ||
| 776 | macho, | ||
| 777 | /// Nvidia's PTX (Parallel Thread Execution) assembly language. | ||
| 778 | nvptx, | ||
| 779 | /// The a.out format used by Plan 9 from Bell Labs. | ||
| 780 | plan9, | ||
| 779 | /// Machine code with no metadata. | 781 | /// Machine code with no metadata. |
| 780 | raw, | 782 | raw, |
| 781 | /// Plan 9 from Bell Labs | 783 | /// The Khronos Group's Standard Portable Intermediate Representation V. |
| 782 | plan9, | 784 | spirv, |
| 783 | /// Nvidia PTX format | 785 | /// The WebAssembly binary format. |
| 784 | nvptx, | 786 | wasm, |
| 787 | /// The eXtended Common Object File Format used by AIX. | ||
| 788 | xcoff, | ||
| 785 | 789 | ||
| 786 | pub fn fileExt(of: ObjectFormat, arch: Cpu.Arch) [:0]const u8 { | 790 | pub fn fileExt(of: ObjectFormat, arch: Cpu.Arch) [:0]const u8 { |
| 787 | return switch (of) { | 791 | return switch (of) { |
| 788 | .coff => ".obj", | ||
| 789 | .elf, .macho, .wasm => ".o", | ||
| 790 | .c => ".c", | 792 | .c => ".c", |
| 791 | .spirv => ".spv", | 793 | .coff => ".obj", |
| 794 | .dxcontainer => ".dxil", | ||
| 795 | .elf, .goff, .macho, .wasm, .xcoff => ".o", | ||
| 792 | .hex => ".ihex", | 796 | .hex => ".ihex", |
| 793 | .raw => ".bin", | ||
| 794 | .plan9 => arch.plan9Ext(), | ||
| 795 | .nvptx => ".ptx", | 797 | .nvptx => ".ptx", |
| 796 | .dxcontainer => ".dxil", | 798 | .plan9 => arch.plan9Ext(), |
| 799 | .raw => ".bin", | ||
| 800 | .spirv => ".spv", | ||
| 797 | }; | 801 | }; |
| 798 | } | 802 | } |
| 799 | 803 | ||
| 800 | pub fn default(os_tag: Os.Tag, arch: Cpu.Arch) ObjectFormat { | 804 | pub fn default(os_tag: Os.Tag, arch: Cpu.Arch) ObjectFormat { |
| 801 | return switch (os_tag) { | 805 | return switch (os_tag) { |
| 802 | .windows, .uefi => .coff, | 806 | .aix => .xcoff, |
| 803 | .ios, .macos, .watchos, .tvos, .visionos => .macho, | 807 | .driverkit, .ios, .macos, .tvos, .visionos, .watchos => .macho, |
| 804 | .plan9 => .plan9, | 808 | .plan9 => .plan9, |
| 809 | .uefi, .windows => .coff, | ||
| 810 | .zos => .goff, | ||
| 805 | else => switch (arch) { | 811 | else => switch (arch) { |
| 806 | .wasm32, .wasm64 => .wasm, | 812 | .dxil => .dxcontainer, |
| 807 | .spirv32, .spirv64 => .spirv, | ||
| 808 | .nvptx, .nvptx64 => .nvptx, | 813 | .nvptx, .nvptx64 => .nvptx, |
| 814 | .spirv, .spirv32, .spirv64 => .spirv, | ||
| 815 | .wasm32, .wasm64 => .wasm, | ||
| 809 | else => .elf, | 816 | else => .elf, |
| 810 | }, | 817 | }, |
| 811 | }; | 818 | }; |
lib/std/zig.zig+1-1| ... | @@ -163,7 +163,7 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe | ... | @@ -163,7 +163,7 @@ pub fn binNameAlloc(allocator: Allocator, options: BinNameOptions) error{OutOfMe |
| 163 | }, | 163 | }, |
| 164 | .Obj => return std.fmt.allocPrint(allocator, "{s}.obj", .{root_name}), | 164 | .Obj => return std.fmt.allocPrint(allocator, "{s}.obj", .{root_name}), |
| 165 | }, | 165 | }, |
| 166 | .elf => switch (options.output_mode) { | 166 | .elf, .goff, .xcoff => switch (options.output_mode) { |
| 167 | .Exe => return allocator.dupe(u8, root_name), | 167 | .Exe => return allocator.dupe(u8, root_name), |
| 168 | .Lib => { | 168 | .Lib => { |
| 169 | switch (options.link_mode orelse .static) { | 169 | switch (options.link_mode orelse .static) { |
src/Compilation/Config.zig+1-1| ... | @@ -434,7 +434,7 @@ pub fn resolve(options: Options) ResolveError!Config { | ... | @@ -434,7 +434,7 @@ pub fn resolve(options: Options) ResolveError!Config { |
| 434 | const debug_format: DebugFormat = b: { | 434 | const debug_format: DebugFormat = b: { |
| 435 | if (root_strip and !options.any_non_stripped) break :b .strip; | 435 | if (root_strip and !options.any_non_stripped) break :b .strip; |
| 436 | break :b switch (target.ofmt) { | 436 | break :b switch (target.ofmt) { |
| 437 | .elf, .macho, .wasm => .{ .dwarf = .@"32" }, | 437 | .elf, .goff, .macho, .wasm, .xcoff => .{ .dwarf = .@"32" }, |
| 438 | .coff => .code_view, | 438 | .coff => .code_view, |
| 439 | .c => switch (target.os.tag) { | 439 | .c => switch (target.os.tag) { |
| 440 | .windows, .uefi => .code_view, | 440 | .windows, .uefi => .code_view, |
src/link.zig+2| ... | @@ -902,6 +902,8 @@ pub const File = struct { | ... | @@ -902,6 +902,8 @@ pub const File = struct { |
| 902 | .c => .c, | 902 | .c => .c, |
| 903 | .spirv => .spirv, | 903 | .spirv => .spirv, |
| 904 | .nvptx => .nvptx, | 904 | .nvptx => .nvptx, |
| 905 | .goff => @panic("TODO implement goff object format"), | ||
| 906 | .xcoff => @panic("TODO implement xcoff object format"), | ||
| 905 | .hex => @panic("TODO implement hex object format"), | 907 | .hex => @panic("TODO implement hex object format"), |
| 906 | .raw => @panic("TODO implement raw object format"), | 908 | .raw => @panic("TODO implement raw object format"), |
| 907 | .dxcontainer => @panic("TODO implement dxcontainer object format"), | 909 | .dxcontainer => @panic("TODO implement dxcontainer object format"), |
src/target.zig+6-4| ... | @@ -98,14 +98,16 @@ pub fn hasLlvmSupport(target: std.Target, ofmt: std.Target.ObjectFormat) bool { | ... | @@ -98,14 +98,16 @@ pub fn hasLlvmSupport(target: std.Target, ofmt: std.Target.ObjectFormat) bool { |
| 98 | => return false, | 98 | => return false, |
| 99 | 99 | ||
| 100 | .coff, | 100 | .coff, |
| 101 | .dxcontainer, | ||
| 101 | .elf, | 102 | .elf, |
| 103 | .goff, | ||
| 104 | .hex, | ||
| 102 | .macho, | 105 | .macho, |
| 103 | .wasm, | 106 | .nvptx, |
| 104 | .spirv, | 107 | .spirv, |
| 105 | .hex, | ||
| 106 | .raw, | 108 | .raw, |
| 107 | .nvptx, | 109 | .wasm, |
| 108 | .dxcontainer, | 110 | .xcoff, |
| 109 | => {}, | 111 | => {}, |
| 110 | } | 112 | } |
| 111 | 113 |