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) {...@@ -372,6 +372,13 @@ const SOName = union(enum) {
372 yes: []const u8,372 yes: []const u8,
373};373};
374374
375const EmitBin = union(enum) {
376 no,
377 yes_default_path,
378 yes: []const u8,
379 yes_a_out,
380};
381
375const Emit = union(enum) {382const Emit = union(enum) {
376 no,383 no,
377 yes_default_path,384 yes_default_path,
...@@ -471,7 +478,7 @@ fn buildOutputType(...@@ -471,7 +478,7 @@ fn buildOutputType(
471 var time_report = false;478 var time_report = false;
472 var stack_report = false;479 var stack_report = false;
473 var show_builtin = false;480 var show_builtin = false;
474 var emit_bin: Emit = .yes_default_path;481 var emit_bin: EmitBin = .yes_default_path;
475 var emit_asm: Emit = .no;482 var emit_asm: Emit = .no;
476 var emit_llvm_ir: Emit = .no;483 var emit_llvm_ir: Emit = .no;
477 var emit_zir: Emit = .no;484 var emit_zir: Emit = .no;
...@@ -1284,7 +1291,7 @@ fn buildOutputType(...@@ -1284,7 +1291,7 @@ fn buildOutputType(
1284 switch (c_out_mode) {1291 switch (c_out_mode) {
1285 .link => {1292 .link => {
1286 output_mode = if (is_shared_lib) .Lib else .Exe;1293 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;
1288 enable_cache = true;1295 enable_cache = true;
1289 },1296 },
1290 .object => {1297 .object => {
...@@ -1498,6 +1505,11 @@ fn buildOutputType(...@@ -1498,6 +1505,11 @@ fn buildOutputType(
1498 },1505 },
1499 };1506 };
15001507
1508 const a_out_basename = switch (object_format) {
1509 .pe, .coff => "a.exe",
1510 else => "a.out",
1511 };
1512
1501 const emit_bin_loc: ?Compilation.EmitLoc = switch (emit_bin) {1513 const emit_bin_loc: ?Compilation.EmitLoc = switch (emit_bin) {
1502 .no => null,1514 .no => null,
1503 .yes_default_path => Compilation.EmitLoc{1515 .yes_default_path => Compilation.EmitLoc{
...@@ -1549,6 +1561,10 @@ fn buildOutputType(...@@ -1549,6 +1561,10 @@ fn buildOutputType(
1549 };1561 };
1550 }1562 }
1551 },1563 },
1564 .yes_a_out => Compilation.EmitLoc{
1565 .directory = null,
1566 .basename = a_out_basename,
1567 },
1552 };1568 };
15531569
1554 const default_h_basename = try std.fmt.allocPrint(arena, "{}.h", .{root_name});1570 const default_h_basename = try std.fmt.allocPrint(arena, "{}.h", .{root_name});
...@@ -1784,6 +1800,7 @@ fn buildOutputType(...@@ -1784,6 +1800,7 @@ fn buildOutputType(
1784 .print = comp.bin_file.options.emit.?.directory.path orelse ".",1800 .print = comp.bin_file.options.emit.?.directory.path orelse ".",
1785 },1801 },
1786 .yes => |full_path| break :blk .{ .update = full_path },1802 .yes => |full_path| break :blk .{ .update = full_path },
1803 .yes_a_out => break :blk .{ .update = a_out_basename },
1787 }1804 }
1788 };1805 };
17891806