build: remove ofmt from LibExeObjStep which is redundant with target.ofmt

This commit is contained in:
Jacob Young 2022-10-31 22:30:34 -04:00
parent 93d60d0de7
commit 757db665a7
3 changed files with 9 additions and 8 deletions

View File

@ -17,7 +17,7 @@ pub fn build(b: *Builder) !void {
b.setPreferredReleaseMode(.ReleaseFast); b.setPreferredReleaseMode(.ReleaseFast);
const test_step = b.step("test", "Run all the tests"); const test_step = b.step("test", "Run all the tests");
const mode = b.standardReleaseOptions(); const mode = b.standardReleaseOptions();
const target = b.standardTargetOptions(.{}); var target = b.standardTargetOptions(.{});
const single_threaded = b.option(bool, "single-threaded", "Build artifacts that run in single threaded mode"); const single_threaded = b.option(bool, "single-threaded", "Build artifacts that run in single threaded mode");
const use_zig_libcxx = b.option(bool, "use-zig-libcxx", "If libc++ is needed, use zig's bundled version, don't try to integrate with the system") orelse false; const use_zig_libcxx = b.option(bool, "use-zig-libcxx", "If libc++ is needed, use zig's bundled version, don't try to integrate with the system") orelse false;
@ -141,6 +141,10 @@ pub fn build(b: *Builder) !void {
break :blk 4; break :blk 4;
}; };
if (only_c) {
target.ofmt = .c;
}
const main_file: ?[]const u8 = mf: { const main_file: ?[]const u8 = mf: {
if (!have_stage1) break :mf "src/main.zig"; if (!have_stage1) break :mf "src/main.zig";
if (use_zig0) break :mf null; if (use_zig0) break :mf null;
@ -172,10 +176,6 @@ pub fn build(b: *Builder) !void {
test_cases.want_lto = false; test_cases.want_lto = false;
} }
if (only_c) {
exe.ofmt = .c;
}
const exe_options = b.addOptions(); const exe_options = b.addOptions();
exe.addOptions("build_options", exe_options); exe.addOptions("build_options", exe_options);

View File

@ -1622,7 +1622,6 @@ pub const LibExeObjStep = struct {
use_stage1: ?bool = null, use_stage1: ?bool = null,
use_llvm: ?bool = null, use_llvm: ?bool = null,
use_lld: ?bool = null, use_lld: ?bool = null,
ofmt: ?std.Target.ObjectFormat = null,
output_path_source: GeneratedFile, output_path_source: GeneratedFile,
output_lib_path_source: GeneratedFile, output_lib_path_source: GeneratedFile,
@ -2490,7 +2489,7 @@ pub const LibExeObjStep = struct {
} }
} }
if (self.ofmt) |ofmt| { if (self.target.ofmt) |ofmt| {
try zig_args.append(try std.fmt.allocPrint(builder.allocator, "-ofmt={s}", .{@tagName(ofmt)})); try zig_args.append(try std.fmt.allocPrint(builder.allocator, "-ofmt={s}", .{@tagName(ofmt)}));
} }

View File

@ -52,6 +52,9 @@ const test_targets = blk: {
}, },
.{ .{
.target = .{
.ofmt = .c,
},
.link_libc = true, .link_libc = true,
.backend = .stage2_c, .backend = .stage2_c,
}, },
@ -720,7 +723,6 @@ pub fn addPkgTests(
.stage2_c => { .stage2_c => {
these_tests.use_stage1 = false; these_tests.use_stage1 = false;
these_tests.use_llvm = false; these_tests.use_llvm = false;
these_tests.ofmt = .c;
}, },
else => { else => {
these_tests.use_stage1 = false; these_tests.use_stage1 = false;