From 846f72b57cb56f67cedaa2113c3ff7b8c548d979 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 5 Apr 2019 14:54:37 -0400 Subject: [PATCH] zig build: support single-threaded builds and fix the zig test suite not setting the --single-threaded flag --- std/build.zig | 8 +++++++- test/tests.zig | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/std/build.zig b/std/build.zig index f0c4330660..2bd4a9b08f 100644 --- a/std/build.zig +++ b/std/build.zig @@ -943,6 +943,7 @@ pub const LibExeObjStep = struct { exec_cmd_args: ?[]const ?[]const u8, name_prefix: []const u8, filter: ?[]const u8, + single_threaded: bool, root_src: ?[]const u8, out_h_filename: []const u8, @@ -1045,6 +1046,7 @@ pub const LibExeObjStep = struct { .disable_gen_h = false, .output_dir = null, .need_system_paths = false, + .single_threaded = false, }; self.computeOutFileNames(); return self; @@ -1206,7 +1208,7 @@ pub const LibExeObjStep = struct { pub fn setMainPkgPath(self: *LibExeObjStep, dir_path: []const u8) void { self.main_pkg_path = dir_path; } - + pub fn setDisableGenH(self: *LibExeObjStep, value: bool) void { self.disable_gen_h = value; } @@ -1411,6 +1413,10 @@ pub const LibExeObjStep = struct { zig_args.append("--strip") catch unreachable; } + if (self.single_threaded) { + try zig_args.append("--single-threaded"); + } + switch (self.build_mode) { builtin.Mode.Debug => {}, builtin.Mode.ReleaseSafe => zig_args.append("--release-safe") catch unreachable, diff --git a/test/tests.zig b/test/tests.zig index b1da0b6049..61fd0426f1 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -186,6 +186,7 @@ pub fn addPkgTests(b: *build.Builder, test_filter: ?[]const u8, root_src: []cons if (link_libc) "c" else "bare", if (single_threaded) "single" else "multi", )); + these_tests.single_threaded = single_threaded; these_tests.setFilter(test_filter); these_tests.setBuildMode(mode); if (!is_native) {