aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.zig21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/main.zig b/src/main.zig
index 9654fc9565..0222d499fa 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -372,6 +372,13 @@ const SOName = union(enum) {
yes: []const u8,
};
+const EmitBin = union(enum) {
+ no,
+ yes_default_path,
+ yes: []const u8,
+ yes_a_out,
+};
+
const Emit = union(enum) {
no,
yes_default_path,
@@ -471,7 +478,7 @@ fn buildOutputType(
var time_report = false;
var stack_report = false;
var show_builtin = false;
- var emit_bin: Emit = .yes_default_path;
+ var emit_bin: EmitBin = .yes_default_path;
var emit_asm: Emit = .no;
var emit_llvm_ir: Emit = .no;
var emit_zir: Emit = .no;
@@ -1284,7 +1291,7 @@ fn buildOutputType(
switch (c_out_mode) {
.link => {
output_mode = if (is_shared_lib) .Lib else .Exe;
- emit_bin = .{ .yes = out_path orelse "a.out" };
+ emit_bin = if (out_path) |p| .{ .yes = p } else EmitBin.yes_a_out;
enable_cache = true;
},
.object => {
@@ -1498,6 +1505,11 @@ fn buildOutputType(
},
};
+ const a_out_basename = switch (object_format) {
+ .pe, .coff => "a.exe",
+ else => "a.out",
+ };
+
const emit_bin_loc: ?Compilation.EmitLoc = switch (emit_bin) {
.no => null,
.yes_default_path => Compilation.EmitLoc{
@@ -1549,6 +1561,10 @@ fn buildOutputType(
};
}
},
+ .yes_a_out => Compilation.EmitLoc{
+ .directory = null,
+ .basename = a_out_basename,
+ },
};
const default_h_basename = try std.fmt.allocPrint(arena, "{}.h", .{root_name});
@@ -1784,6 +1800,7 @@ fn buildOutputType(
.print = comp.bin_file.options.emit.?.directory.path orelse ".",
},
.yes => |full_path| break :blk .{ .update = full_path },
+ .yes_a_out => break :blk .{ .update = a_out_basename },
}
};