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