authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2022-10-31 22:30:34-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2022-11-01 20:38:37-04:00
log757db665a79d7885d1c8f83df65a25adc7af9a69
tree402a2b41204af488a1b68e97123452ac881531bb
parent93d60d0de76e5dca666682e51589c0819eed2507

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


3 files changed, 9 insertions(+), 8 deletions(-)

build.zig+5-5
...@@ -17,7 +17,7 @@ pub fn build(b: *Builder) !void {...@@ -17,7 +17,7 @@ pub fn build(b: *Builder) !void {
17 b.setPreferredReleaseMode(.ReleaseFast);17 b.setPreferredReleaseMode(.ReleaseFast);
18 const test_step = b.step("test", "Run all the tests");18 const test_step = b.step("test", "Run all the tests");
19 const mode = b.standardReleaseOptions();19 const mode = b.standardReleaseOptions();
20 const target = b.standardTargetOptions(.{});20 var target = b.standardTargetOptions(.{});
21 const single_threaded = b.option(bool, "single-threaded", "Build artifacts that run in single threaded mode");21 const single_threaded = b.option(bool, "single-threaded", "Build artifacts that run in single threaded mode");
22 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;22 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;
2323
...@@ -141,6 +141,10 @@ pub fn build(b: *Builder) !void {...@@ -141,6 +141,10 @@ pub fn build(b: *Builder) !void {
141 break :blk 4;141 break :blk 4;
142 };142 };
143143
144 if (only_c) {
145 target.ofmt = .c;
146 }
147
144 const main_file: ?[]const u8 = mf: {148 const main_file: ?[]const u8 = mf: {
145 if (!have_stage1) break :mf "src/main.zig";149 if (!have_stage1) break :mf "src/main.zig";
146 if (use_zig0) break :mf null;150 if (use_zig0) break :mf null;
...@@ -172,10 +176,6 @@ pub fn build(b: *Builder) !void {...@@ -172,10 +176,6 @@ pub fn build(b: *Builder) !void {
172 test_cases.want_lto = false;176 test_cases.want_lto = false;
173 }177 }
174178
175 if (only_c) {
176 exe.ofmt = .c;
177 }
178
179 const exe_options = b.addOptions();179 const exe_options = b.addOptions();
180 exe.addOptions("build_options", exe_options);180 exe.addOptions("build_options", exe_options);
181181
lib/std/build.zig+1-2
...@@ -1622,7 +1622,6 @@ pub const LibExeObjStep = struct {...@@ -1622,7 +1622,6 @@ pub const LibExeObjStep = struct {
1622 use_stage1: ?bool = null,1622 use_stage1: ?bool = null,
1623 use_llvm: ?bool = null,1623 use_llvm: ?bool = null,
1624 use_lld: ?bool = null,1624 use_lld: ?bool = null,
1625 ofmt: ?std.Target.ObjectFormat = null,
16261625
1627 output_path_source: GeneratedFile,1626 output_path_source: GeneratedFile,
1628 output_lib_path_source: GeneratedFile,1627 output_lib_path_source: GeneratedFile,
...@@ -2490,7 +2489,7 @@ pub const LibExeObjStep = struct {...@@ -2490,7 +2489,7 @@ pub const LibExeObjStep = struct {
2490 }2489 }
2491 }2490 }
24922491
2493 if (self.ofmt) |ofmt| {2492 if (self.target.ofmt) |ofmt| {
2494 try zig_args.append(try std.fmt.allocPrint(builder.allocator, "-ofmt={s}", .{@tagName(ofmt)}));2493 try zig_args.append(try std.fmt.allocPrint(builder.allocator, "-ofmt={s}", .{@tagName(ofmt)}));
2495 }2494 }
24962495
test/tests.zig+3-1
...@@ -52,6 +52,9 @@ const test_targets = blk: {...@@ -52,6 +52,9 @@ const test_targets = blk: {
52 },52 },
5353
54 .{54 .{
55 .target = .{
56 .ofmt = .c,
57 },
55 .link_libc = true,58 .link_libc = true,
56 .backend = .stage2_c,59 .backend = .stage2_c,
57 },60 },
...@@ -720,7 +723,6 @@ pub fn addPkgTests(...@@ -720,7 +723,6 @@ pub fn addPkgTests(
720 .stage2_c => {723 .stage2_c => {
721 these_tests.use_stage1 = false;724 these_tests.use_stage1 = false;
722 these_tests.use_llvm = false;725 these_tests.use_llvm = false;
723 these_tests.ofmt = .c;
724 },726 },
725 else => {727 else => {
726 these_tests.use_stage1 = false;728 these_tests.use_stage1 = false;