diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-12-24 19:47:34 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-01-01 17:51:21 -0700 |
| commit | 981166e33f967c62971de1aee79779fcfb3e37b7 (patch) | |
| tree | a02c4b9fd1b3e66544638828c7c16ad0265760ad /src/link/Elf.zig | |
| parent | 4d28db7329c32d7a2b7915d7a5da7f93c4088ccd (diff) | |
| download | zig-981166e33f967c62971de1aee79779fcfb3e37b7.tar.gz zig-981166e33f967c62971de1aee79779fcfb3e37b7.zip | |
link.Elf: truncate=true in createEmpty
Diffstat (limited to 'src/link/Elf.zig')
| -rw-r--r-- | src/link/Elf.zig | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 6cb6a98250..eb08fe2855 100644 --- 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); } |
