authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-12-16 21:37:15-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-12-16 21:37:15-07:00
log6dfe9cc83ea75a663b4f6dfa488b95950207a1cf
tree38a1b1d0f55210092f8df3b520b506391202b63e
parent8975fa5b38a791d318c0817afb636ba91ad8d038

zig cc: default to a.exe on windows

This matches Clang. Thanks to Abner Coimbre for pointing this out.

1 files changed, 19 insertions(+), 2 deletions(-)

src/main.zig+19-2
......@@ -372,6 +372,13 @@ const SOName = union(enum) {
372372 yes: []const u8,
373373};
374374
375const EmitBin = union(enum) {
376 no,
377 yes_default_path,
378 yes: []const u8,
379 yes_a_out,
380};
381
375382const Emit = union(enum) {
376383 no,
377384 yes_default_path,
......@@ -471,7 +478,7 @@ fn buildOutputType(
471478 var time_report = false;
472479 var stack_report = false;
473480 var show_builtin = false;
474 var emit_bin: Emit = .yes_default_path;
481 var emit_bin: EmitBin = .yes_default_path;
475482 var emit_asm: Emit = .no;
476483 var emit_llvm_ir: Emit = .no;
477484 var emit_zir: Emit = .no;
......@@ -1284,7 +1291,7 @@ fn buildOutputType(
12841291 switch (c_out_mode) {
12851292 .link => {
12861293 output_mode = if (is_shared_lib) .Lib else .Exe;
1287 emit_bin = .{ .yes = out_path orelse "a.out" };
1294 emit_bin = if (out_path) |p| .{ .yes = p } else EmitBin.yes_a_out;
12881295 enable_cache = true;
12891296 },
12901297 .object => {
......@@ -1498,6 +1505,11 @@ fn buildOutputType(
14981505 },
14991506 };
15001507
1508 const a_out_basename = switch (object_format) {
1509 .pe, .coff => "a.exe",
1510 else => "a.out",
1511 };
1512
15011513 const emit_bin_loc: ?Compilation.EmitLoc = switch (emit_bin) {
15021514 .no => null,
15031515 .yes_default_path => Compilation.EmitLoc{
......@@ -1549,6 +1561,10 @@ fn buildOutputType(
15491561 };
15501562 }
15511563 },
1564 .yes_a_out => Compilation.EmitLoc{
1565 .directory = null,
1566 .basename = a_out_basename,
1567 },
15521568 };
15531569
15541570 const default_h_basename = try std.fmt.allocPrint(arena, "{}.h", .{root_name});
......@@ -1784,6 +1800,7 @@ fn buildOutputType(
17841800 .print = comp.bin_file.options.emit.?.directory.path orelse ".",
17851801 },
17861802 .yes => |full_path| break :blk .{ .update = full_path },
1803 .yes_a_out => break :blk .{ .update = a_out_basename },
17871804 }
17881805 };
17891806