zig

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

commit 981166e33f967c62971de1aee79779fcfb3e37b7 (tree)
parent 4d28db7329c32d7a2b7915d7a5da7f93c4088ccd
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Sun, 24 Dec 2023 19:47:34 -0700

link.Elf: truncate=true in createEmpty

Diffstat:
Msrc/link/Elf.zig | 14+++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/link/Elf.zig b/src/link/Elf.zig @@ -264,12 +264,10 @@ pub fn createEmpty( // If using LLVM to generate the object file for the zig compilation unit, // we need a place to put the object file so that it can be subsequently // handled. - const zcu_object_sub_path = if (!use_lld and !use_llvm) null else p: { - const o_file_path = try std.fmt.allocPrint(arena, "{s}{s}", .{ - emit.sub_path, target.ofmt.fileExt(target.cpu.arch), - }); - break :p o_file_path; - }; + const zcu_object_sub_path = if (!use_lld and !use_llvm) + null + else + try std.fmt.allocPrint(arena, "{s}.o", .{emit.sub_path}); const self = try arena.create(Elf); self.* = .{ @@ -343,7 +341,7 @@ pub fn createEmpty( // can be passed to LLD. const sub_path = if (use_lld) zcu_object_sub_path.? else emit.sub_path; self.base.file = try emit.directory.handle.createFile(sub_path, .{ - .truncate = false, + .truncate = true, .read = true, .mode = link.File.determineMode(use_lld, output_mode, link_mode), }); @@ -431,6 +429,8 @@ pub fn open( emit: Compilation.Emit, options: link.File.OpenOptions, ) !*Elf { + // TODO: restore saved linker state, don't truncate the file, and + // participate in incremental compilation. return createEmpty(arena, comp, emit, options); }