zig

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

commit e9807418e7e58f3cb85d5d3a6d114d5084e305bd (tree)
parent e9b137f23a9b38c6b808452ef216e4e18d3070ed
Author: Alexandros Naskos <alex_naskos@hotmail.com>
Date:   Fri,  4 Sep 2020 05:22:26 +0300

Added .pe ObjectFormat
MachO linker no longer collects unused dwarf debug information

Diffstat:
Mlib/std/target.zig | 1+
Msrc-self-hosted/link.zig | 2+-
Msrc-self-hosted/link/MachO.zig | 25+------------------------
Msrc-self-hosted/main.zig | 9+++------
4 files changed, 6 insertions(+), 31 deletions(-)

diff --git a/lib/std/target.zig b/lib/std/target.zig @@ -468,6 +468,7 @@ pub const Target = struct { /// TODO Get rid of this one. unknown, coff, + pe, elf, macho, wasm, diff --git a/src-self-hosted/link.zig b/src-self-hosted/link.zig @@ -68,7 +68,7 @@ pub const File = struct { pub fn openPath(allocator: *Allocator, dir: fs.Dir, sub_path: []const u8, options: Options) !*File { switch (options.object_format) { .unknown => unreachable, - .coff => return Coff.openPath(allocator, dir, sub_path, options), + .coff, .pe => return Coff.openPath(allocator, dir, sub_path, options), .elf => return Elf.openPath(allocator, dir, sub_path, options), .macho => return MachO.openPath(allocator, dir, sub_path, options), .wasm => return Wasm.openPath(allocator, dir, sub_path, options), diff --git a/src-self-hosted/link/MachO.zig b/src-self-hosted/link/MachO.zig @@ -316,31 +316,8 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void { var code_buffer = std.ArrayList(u8).init(self.base.allocator); defer code_buffer.deinit(); - var dbg_line_buffer = std.ArrayList(u8).init(self.base.allocator); - defer dbg_line_buffer.deinit(); - - var dbg_info_buffer = std.ArrayList(u8).init(self.base.allocator); - defer dbg_info_buffer.deinit(); - - var dbg_info_type_relocs: File.DbgInfoTypeRelocsTable = .{}; - defer { - var it = dbg_info_type_relocs.iterator(); - while (it.next()) |entry| { - entry.value.relocs.deinit(self.base.allocator); - } - dbg_info_type_relocs.deinit(self.base.allocator); - } - const typed_value = decl.typed_value.most_recent.typed_value; - const res = try codegen.generateSymbol( - &self.base, - decl.src(), - typed_value, - &code_buffer, - &dbg_line_buffer, - &dbg_info_buffer, - &dbg_info_type_relocs, - ); + const res = try codegen.generateSymbol(&self.base, decl.src(), typed_value, &code_buffer, .none); const code = switch (res) { .externally_managed => |x| x, diff --git a/src-self-hosted/main.zig b/src-self-hosted/main.zig @@ -153,8 +153,8 @@ const usage_build_generic = \\ elf Executable and Linking Format \\ c Compile to C source code \\ wasm WebAssembly + \\ pe Portable Executable (Windows) \\ coff (planned) Common Object File Format (Windows) - \\ pe (planned) Portable Executable (Windows) \\ macho (planned) macOS relocatables \\ hex (planned) Intel IHEX \\ raw (planned) Dump machine code directly @@ -451,7 +451,7 @@ fn buildOutputType( } else if (mem.eql(u8, ofmt, "coff")) { break :blk .coff; } else if (mem.eql(u8, ofmt, "pe")) { - break :blk .coff; + break :blk .pe; } else if (mem.eql(u8, ofmt, "macho")) { break :blk .macho; } else if (mem.eql(u8, ofmt, "wasm")) { @@ -524,10 +524,7 @@ fn buildOutputType( try stderr.print("\nUnable to parse command: {}\n", .{@errorName(err)}); continue; }) |line| { - const actual_line = if (line[line.len - 1] == '\r') - line[0 .. line.len - 1] - else - line; + const actual_line = mem.trimRight(u8, line, "\r\n "); if (mem.eql(u8, actual_line, "update")) { if (output_mode == .Exe) {