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