| author | |
| committer | |
| log | f69650a4788c57ec20348e9c002884ba39339d1c |
| tree | f371e3bc00656c8aacba0dda88141eb97bb41179 |
| parent | b811a99af9b5549fd0f0940dafddc63040af01ac |
This is convenient for debugging purposes, as well as simplifying the
caching system since executable basenames will not conflict with their
corresponding object files.6 files changed, 24 insertions(+), 22 deletions(-)
lib/std/build.zig+1| ... | ... | @@ -1384,6 +1384,7 @@ pub const LibExeObjStep = struct { |
| 1384 | 1384 | } |
| 1385 | 1385 | |
| 1386 | 1386 | fn computeOutFileNames(self: *LibExeObjStep) void { |
| 1387 | // TODO make this call std.zig.binNameAlloc | |
| 1387 | 1388 | switch (self.kind) { |
| 1388 | 1389 | .Obj => { |
| 1389 | 1390 | self.out_filename = self.builder.fmt("{}{}", .{ self.name, self.target.oFileExt() }); |
lib/std/target.zig+11-8| ... | ... | @@ -483,13 +483,6 @@ pub const Target = struct { |
| 483 | 483 | else => false, |
| 484 | 484 | }; |
| 485 | 485 | } |
| 486 | ||
| 487 | pub fn oFileExt(abi: Abi) [:0]const u8 { | |
| 488 | return switch (abi) { | |
| 489 | .msvc => ".obj", | |
| 490 | else => ".o", | |
| 491 | }; | |
| 492 | } | |
| 493 | 486 | }; |
| 494 | 487 | |
| 495 | 488 | pub const ObjectFormat = enum { |
| ... | ... | @@ -1142,8 +1135,18 @@ pub const Target = struct { |
| 1142 | 1135 | return linuxTripleSimple(allocator, self.cpu.arch, self.os.tag, self.abi); |
| 1143 | 1136 | } |
| 1144 | 1137 | |
| 1138 | pub fn oFileExt_cpu_arch_abi(cpu_arch: Cpu.Arch, abi: Abi) [:0]const u8 { | |
| 1139 | if (cpu_arch.isWasm()) { | |
| 1140 | return ".o.wasm"; | |
| 1141 | } | |
| 1142 | switch (abi) { | |
| 1143 | .msvc => return ".obj", | |
| 1144 | else => return ".o", | |
| 1145 | } | |
| 1146 | } | |
| 1147 | ||
| 1145 | 1148 | pub fn oFileExt(self: Target) [:0]const u8 { |
| 1146 | return self.abi.oFileExt(); | |
| 1149 | return oFileExt_cpu_arch_abi(self.cpu.arch, self.abi); | |
| 1147 | 1150 | } |
| 1148 | 1151 | |
| 1149 | 1152 | pub fn exeFileExtSimple(cpu_arch: Cpu.Arch, os_tag: Os.Tag) [:0]const u8 { |
lib/std/zig.zig+9-11| ... | ... | @@ -79,13 +79,7 @@ pub fn binNameAlloc(allocator: *std.mem.Allocator, options: BinNameOptions) erro |
| 79 | 79 | const target = options.target; |
| 80 | 80 | switch (options.object_format orelse target.getObjectFormat()) { |
| 81 | 81 | .coff, .pe => switch (options.output_mode) { |
| 82 | .Exe => { | |
| 83 | const suffix = switch (target.os.tag) { | |
| 84 | .uefi => ".efi", | |
| 85 | else => ".exe", | |
| 86 | }; | |
| 87 | return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, suffix }); | |
| 88 | }, | |
| 82 | .Exe => return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, target.exeFileExt() }), | |
| 89 | 83 | .Lib => { |
| 90 | 84 | const suffix = switch (options.link_mode orelse .Static) { |
| 91 | 85 | .Static => ".lib", |
| ... | ... | @@ -93,7 +87,7 @@ pub fn binNameAlloc(allocator: *std.mem.Allocator, options: BinNameOptions) erro |
| 93 | 87 | }; |
| 94 | 88 | return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, suffix }); |
| 95 | 89 | }, |
| 96 | .Obj => return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, target.abi.oFileExt() }), | |
| 90 | .Obj => return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, target.oFileExt() }), | |
| 97 | 91 | }, |
| 98 | 92 | .elf => switch (options.output_mode) { |
| 99 | 93 | .Exe => return allocator.dupe(u8, root_name), |
| ... | ... | @@ -113,7 +107,7 @@ pub fn binNameAlloc(allocator: *std.mem.Allocator, options: BinNameOptions) erro |
| 113 | 107 | }, |
| 114 | 108 | } |
| 115 | 109 | }, |
| 116 | .Obj => return std.fmt.allocPrint(allocator, "{s}.o", .{root_name}), | |
| 110 | .Obj => return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, target.oFileExt() }), | |
| 117 | 111 | }, |
| 118 | 112 | .macho => switch (options.output_mode) { |
| 119 | 113 | .Exe => return allocator.dupe(u8, root_name), |
| ... | ... | @@ -124,9 +118,13 @@ pub fn binNameAlloc(allocator: *std.mem.Allocator, options: BinNameOptions) erro |
| 124 | 118 | }; |
| 125 | 119 | return std.fmt.allocPrint(allocator, "{s}{s}{s}", .{ target.libPrefix(), root_name, suffix }); |
| 126 | 120 | }, |
| 127 | .Obj => return std.fmt.allocPrint(allocator, "{s}.o", .{root_name}), | |
| 121 | .Obj => return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, target.oFileExt() }), | |
| 122 | }, | |
| 123 | .wasm => switch (options.output_mode) { | |
| 124 | .Exe => return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, target.exeFileExt() }), | |
| 125 | .Obj => return std.fmt.allocPrint(allocator, "{s}{s}", .{ root_name, target.oFileExt() }), | |
| 126 | .Lib => return std.fmt.allocPrint(allocator, "{s}.wasm", .{root_name}), | |
| 128 | 127 | }, |
| 129 | .wasm => return std.fmt.allocPrint(allocator, "{s}.wasm", .{root_name}), | |
| 130 | 128 | .c => return std.fmt.allocPrint(allocator, "{s}.c", .{root_name}), |
| 131 | 129 | .hex => return std.fmt.allocPrint(allocator, "{s}.ihex", .{root_name}), |
| 132 | 130 | .raw => return std.fmt.allocPrint(allocator, "{s}.bin", .{root_name}), |
lib/std/zig/cross_target.zig+1-1| ... | ... | @@ -466,7 +466,7 @@ pub const CrossTarget = struct { |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | pub fn oFileExt(self: CrossTarget) [:0]const u8 { |
| 469 | return self.getAbi().oFileExt(); | |
| 469 | return Target.oFileExt_cpu_arch_abi(self.getCpuArch(), self.getAbi()); | |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | pub fn exeFileExt(self: CrossTarget) [:0]const u8 { |
src/Compilation.zig+1-1| ... | ... | @@ -1520,7 +1520,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void { |
| 1520 | 1520 | comp.bin_file.options.root_name |
| 1521 | 1521 | else |
| 1522 | 1522 | mem.split(c_source_basename, ".").next().?; |
| 1523 | const o_basename = try std.fmt.allocPrint(arena, "{}{}", .{ o_basename_noext, comp.getTarget().oFileExt() }); | |
| 1523 | const o_basename = try std.fmt.allocPrint(arena, "{s}{s}", .{ o_basename_noext, comp.getTarget().oFileExt() }); | |
| 1524 | 1524 | |
| 1525 | 1525 | const digest = if (!comp.disable_c_depfile and try man.hit()) man.final() else blk: { |
| 1526 | 1526 | var argv = std.ArrayList([]const u8).init(comp.gpa); |
src/link.zig+1-1| ... | ... | @@ -176,7 +176,7 @@ pub const File = struct { |
| 176 | 176 | }; |
| 177 | 177 | } |
| 178 | 178 | // Open a temporary object file, not the final output file because we want to link with LLD. |
| 179 | break :blk try std.fmt.allocPrint(allocator, "{}{}", .{ emit.sub_path, options.target.oFileExt() }); | |
| 179 | break :blk try std.fmt.allocPrint(allocator, "{s}{s}", .{ emit.sub_path, options.target.oFileExt() }); | |
| 180 | 180 | } else emit.sub_path; |
| 181 | 181 | errdefer if (use_lld) allocator.free(sub_path); |
| 182 | 182 |