Commit 757db665a7

Jacob Young <jacobly0@users.noreply.github.com>
2022-11-01 03:30:34
build: remove `ofmt` from `LibExeObjStep` which is redundant with `target.ofmt`
1 parent 93d60d0
Changed files (3)
lib/std/build.zig
@@ -1622,7 +1622,6 @@ pub const LibExeObjStep = struct {
     use_stage1: ?bool = null,
     use_llvm: ?bool = null,
     use_lld: ?bool = null,
-    ofmt: ?std.Target.ObjectFormat = null,
 
     output_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)}));
         }
 
test/tests.zig
@@ -52,6 +52,9 @@ const test_targets = blk: {
         },
 
         .{
+            .target = .{
+                .ofmt = .c,
+            },
             .link_libc = true,
             .backend = .stage2_c,
         },
@@ -720,7 +723,6 @@ pub fn addPkgTests(
             .stage2_c => {
                 these_tests.use_stage1 = false;
                 these_tests.use_llvm = false;
-                these_tests.ofmt = .c;
             },
             else => {
                 these_tests.use_stage1 = false;
build.zig
@@ -17,7 +17,7 @@ pub fn build(b: *Builder) !void {
     b.setPreferredReleaseMode(.ReleaseFast);
     const test_step = b.step("test", "Run all the tests");
     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 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;
     };
 
+    if (only_c) {
+        target.ofmt = .c;
+    }
+
     const main_file: ?[]const u8 = mf: {
         if (!have_stage1) break :mf "src/main.zig";
         if (use_zig0) break :mf null;
@@ -172,10 +176,6 @@ pub fn build(b: *Builder) !void {
         test_cases.want_lto = false;
     }
 
-    if (only_c) {
-        exe.ofmt = .c;
-    }
-
     const exe_options = b.addOptions();
     exe.addOptions("build_options", exe_options);