zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 757db665a79d7885d1c8f83df65a25adc7af9a69 (tree)
parent 93d60d0de76e5dca666682e51589c0819eed2507
Author: Jacob Young <jacobly0@users.noreply.github.com>
Date:   Mon, 31 Oct 2022 22:30:34 -0400

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

Diffstat:
Mbuild.zig | 10+++++-----
Mlib/std/build.zig | 3+--
Mtest/tests.zig | 4+++-
3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/build.zig b/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); diff --git a/lib/std/build.zig b/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)})); } diff --git a/test/tests.zig b/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;