diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2021-07-23 17:06:19 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2021-07-23 17:06:19 +0200 |
| commit | 5533f77054acad376f2fce0d529569a7449e9949 (patch) | |
| tree | eba6945383fefa59a8858f7eec8beee3cfca7731 /src/link.zig | |
| parent | 1beda818e1c10bde98b35759b3c131a864be58d9 (diff) | |
| parent | e5b476209a1215a03164890d331e2013f20882a6 (diff) | |
| download | zig-5533f77054acad376f2fce0d529569a7449e9949.tar.gz zig-5533f77054acad376f2fce0d529569a7449e9949.zip | |
Merge remote-tracking branch 'origin/master' into zld-incremental-2
Diffstat (limited to 'src/link.zig')
| -rw-r--r-- | src/link.zig | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/link.zig b/src/link.zig index e9f2c932de..1293fab4d2 100644 --- a/src/link.zig +++ b/src/link.zig @@ -191,7 +191,7 @@ pub const File = struct { const use_stage1 = build_options.is_stage1 and options.use_stage1; if (use_stage1 or options.emit == null) { return switch (options.object_format) { - .coff, .pe => &(try Coff.createEmpty(allocator, options)).base, + .coff => &(try Coff.createEmpty(allocator, options)).base, .elf => &(try Elf.createEmpty(allocator, options)).base, .macho => &(try MachO.createEmpty(allocator, options)).base, .wasm => &(try Wasm.createEmpty(allocator, options)).base, @@ -206,9 +206,10 @@ pub const File = struct { const use_lld = build_options.have_llvm and options.use_lld; // comptime known false when !have_llvm const sub_path = if (use_lld) blk: { if (options.module == null) { - // No point in opening a file, we would not write anything to it. Initialize with empty. + // No point in opening a file, we would not write anything to it. + // Initialize with empty. return switch (options.object_format) { - .coff, .pe => &(try Coff.createEmpty(allocator, options)).base, + .coff => &(try Coff.createEmpty(allocator, options)).base, .elf => &(try Elf.createEmpty(allocator, options)).base, .macho => &(try MachO.createEmpty(allocator, options)).base, .plan9 => &(try Plan9.createEmpty(allocator, options)).base, @@ -219,13 +220,16 @@ pub const File = struct { .raw => return error.RawObjectFormatUnimplemented, }; } - // Open a temporary object file, not the final output file because we want to link with LLD. - break :blk try std.fmt.allocPrint(allocator, "{s}{s}", .{ emit.sub_path, options.target.oFileExt() }); + // Open a temporary object file, not the final output file because we + // want to link with LLD. + break :blk try std.fmt.allocPrint(allocator, "{s}{s}", .{ + emit.sub_path, options.object_format.fileExt(options.target.cpu.arch), + }); } else emit.sub_path; errdefer if (use_lld) allocator.free(sub_path); const file: *File = switch (options.object_format) { - .coff, .pe => &(try Coff.openPath(allocator, sub_path, options)).base, + .coff => &(try Coff.openPath(allocator, sub_path, options)).base, .elf => &(try Elf.openPath(allocator, sub_path, options)).base, .macho => &(try MachO.openPath(allocator, sub_path, options)).base, .plan9 => &(try Plan9.openPath(allocator, sub_path, options)).base, |
