| author | |
| committer | |
| log | 40f5e5dfc60ef94e61cc6a83547f3e82b401054c |
| tree | ffe5c86a062964c660741eb41c0cfd67179f66d7 |
| parent | 89afd4bd33c72c2e608974d182f4624078da3a7f |
Previously there was only `--single-threaded`.
This flag now matches other boolean flags, instead of only being able to
opt in to single-threaded builds, you can now force multi-threaded
builds. Currently this only has the possibility to emit an error
message, but it is a better user experience to understand why one cannot
choose to enable threads in some cases.
This is breaking change to the CLI.
Related: #101433 files changed, 20 insertions(+), 10 deletions(-)
lib/std/build.zig+8-5| ... | @@ -1442,6 +1442,7 @@ pub const LibExeObjStep = struct { | ... | @@ -1442,6 +1442,7 @@ pub const LibExeObjStep = struct { |
| 1442 | emit_docs: bool = false, | 1442 | emit_docs: bool = false, |
| 1443 | emit_h: bool = false, | 1443 | emit_h: bool = false, |
| 1444 | bundle_compiler_rt: ?bool = null, | 1444 | bundle_compiler_rt: ?bool = null, |
| 1445 | single_threaded: ?bool = null, | ||
| 1445 | disable_stack_probing: bool, | 1446 | disable_stack_probing: bool, |
| 1446 | disable_sanitize_c: bool, | 1447 | disable_sanitize_c: bool, |
| 1447 | sanitize_thread: bool, | 1448 | sanitize_thread: bool, |
| ... | @@ -1456,7 +1457,6 @@ pub const LibExeObjStep = struct { | ... | @@ -1456,7 +1457,6 @@ pub const LibExeObjStep = struct { |
| 1456 | exec_cmd_args: ?[]const ?[]const u8, | 1457 | exec_cmd_args: ?[]const ?[]const u8, |
| 1457 | name_prefix: []const u8, | 1458 | name_prefix: []const u8, |
| 1458 | filter: ?[]const u8, | 1459 | filter: ?[]const u8, |
| 1459 | single_threaded: bool, | ||
| 1460 | test_evented_io: bool = false, | 1460 | test_evented_io: bool = false, |
| 1461 | code_model: std.builtin.CodeModel = .default, | 1461 | code_model: std.builtin.CodeModel = .default, |
| 1462 | wasi_exec_model: ?std.builtin.WasiExecModel = null, | 1462 | wasi_exec_model: ?std.builtin.WasiExecModel = null, |
| ... | @@ -1649,7 +1649,6 @@ pub const LibExeObjStep = struct { | ... | @@ -1649,7 +1649,6 @@ pub const LibExeObjStep = struct { |
| 1649 | .sanitize_thread = false, | 1649 | .sanitize_thread = false, |
| 1650 | .rdynamic = false, | 1650 | .rdynamic = false, |
| 1651 | .output_dir = null, | 1651 | .output_dir = null, |
| 1652 | .single_threaded = false, | ||
| 1653 | .override_dest_dir = null, | 1652 | .override_dest_dir = null, |
| 1654 | .installed_path = null, | 1653 | .installed_path = null, |
| 1655 | .install_step = null, | 1654 | .install_step = null, |
| ... | @@ -2376,9 +2375,6 @@ pub const LibExeObjStep = struct { | ... | @@ -2376,9 +2375,6 @@ pub const LibExeObjStep = struct { |
| 2376 | try zig_args.append("-z"); | 2375 | try zig_args.append("-z"); |
| 2377 | try zig_args.append("notext"); | 2376 | try zig_args.append("notext"); |
| 2378 | } | 2377 | } |
| 2379 | if (self.single_threaded) { | ||
| 2380 | try zig_args.append("--single-threaded"); | ||
| 2381 | } | ||
| 2382 | 2378 | ||
| 2383 | if (self.libc_file) |libc_file| { | 2379 | if (self.libc_file) |libc_file| { |
| 2384 | try zig_args.append("--libc"); | 2380 | try zig_args.append("--libc"); |
| ... | @@ -2420,6 +2416,13 @@ pub const LibExeObjStep = struct { | ... | @@ -2420,6 +2416,13 @@ pub const LibExeObjStep = struct { |
| 2420 | try zig_args.append("-fno-compiler-rt"); | 2416 | try zig_args.append("-fno-compiler-rt"); |
| 2421 | } | 2417 | } |
| 2422 | } | 2418 | } |
| 2419 | if (self.single_threaded) |single_threaded| { | ||
| 2420 | if (single_threaded) { | ||
| 2421 | try zig_args.append("-fsingle-threaded"); | ||
| 2422 | } else { | ||
| 2423 | try zig_args.append("-fno-single-threaded"); | ||
| 2424 | } | ||
| 2425 | } | ||
| 2423 | if (self.disable_stack_probing) { | 2426 | if (self.disable_stack_probing) { |
| 2424 | try zig_args.append("-fno-stack-check"); | 2427 | try zig_args.append("-fno-stack-check"); |
| 2425 | } | 2428 | } |
src/Compilation.zig+6-2| ... | @@ -705,9 +705,9 @@ pub const InitOptions = struct { | ... | @@ -705,9 +705,9 @@ pub const InitOptions = struct { |
| 705 | use_lld: ?bool = null, | 705 | use_lld: ?bool = null, |
| 706 | use_clang: ?bool = null, | 706 | use_clang: ?bool = null, |
| 707 | use_stage1: ?bool = null, | 707 | use_stage1: ?bool = null, |
| 708 | single_threaded: ?bool = null, | ||
| 708 | rdynamic: bool = false, | 709 | rdynamic: bool = false, |
| 709 | strip: bool = false, | 710 | strip: bool = false, |
| 710 | single_threaded: bool = false, | ||
| 711 | function_sections: bool = false, | 711 | function_sections: bool = false, |
| 712 | is_native_os: bool, | 712 | is_native_os: bool, |
| 713 | is_native_abi: bool, | 713 | is_native_abi: bool, |
| ... | @@ -1116,7 +1116,11 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { | ... | @@ -1116,7 +1116,11 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { |
| 1116 | 1116 | ||
| 1117 | const include_compiler_rt = options.want_compiler_rt orelse needs_c_symbols; | 1117 | const include_compiler_rt = options.want_compiler_rt orelse needs_c_symbols; |
| 1118 | 1118 | ||
| 1119 | const single_threaded = options.single_threaded or target_util.isSingleThreaded(options.target); | 1119 | const must_single_thread = target_util.isSingleThreaded(options.target); |
| 1120 | const single_threaded = options.single_threaded orelse must_single_thread; | ||
| 1121 | if (must_single_thread and !single_threaded) { | ||
| 1122 | return error.TargetRequiresSingleThreaded; | ||
| 1123 | } | ||
| 1120 | 1124 | ||
| 1121 | const llvm_cpu_features: ?[*:0]const u8 = if (build_options.have_llvm and use_llvm) blk: { | 1125 | const llvm_cpu_features: ?[*:0]const u8 = if (build_options.have_llvm and use_llvm) blk: { |
| 1122 | var buf = std.ArrayList(u8).init(arena); | 1126 | var buf = std.ArrayList(u8).init(arena); |
src/main.zig+6-3| ... | @@ -369,8 +369,9 @@ const usage_build_generic = | ... | @@ -369,8 +369,9 @@ const usage_build_generic = |
| 369 | \\ -fno-Clang Prevent using Clang as the C/C++ compilation backend | 369 | \\ -fno-Clang Prevent using Clang as the C/C++ compilation backend |
| 370 | \\ -fstage1 Force using bootstrap compiler as the codegen backend | 370 | \\ -fstage1 Force using bootstrap compiler as the codegen backend |
| 371 | \\ -fno-stage1 Prevent using bootstrap compiler as the codegen backend | 371 | \\ -fno-stage1 Prevent using bootstrap compiler as the codegen backend |
| 372 | \\ -fsingle-threaded Code assumes there is only one thread | ||
| 373 | \\ -fno-single-threaded Code may not assume there is only one thread | ||
| 372 | \\ --strip Omit debug symbols | 374 | \\ --strip Omit debug symbols |
| 373 | \\ --single-threaded Code assumes it is only used single-threaded | ||
| 374 | \\ -ofmt=[mode] Override target object format | 375 | \\ -ofmt=[mode] Override target object format |
| 375 | \\ elf Executable and Linking Format | 376 | \\ elf Executable and Linking Format |
| 376 | \\ c C source code | 377 | \\ c C source code |
| ... | @@ -564,12 +565,12 @@ fn buildOutputType( | ... | @@ -564,12 +565,12 @@ fn buildOutputType( |
| 564 | var provided_name: ?[]const u8 = null; | 565 | var provided_name: ?[]const u8 = null; |
| 565 | var link_mode: ?std.builtin.LinkMode = null; | 566 | var link_mode: ?std.builtin.LinkMode = null; |
| 566 | var dll_export_fns: ?bool = null; | 567 | var dll_export_fns: ?bool = null; |
| 568 | var single_threaded: ?bool = null; | ||
| 567 | var root_src_file: ?[]const u8 = null; | 569 | var root_src_file: ?[]const u8 = null; |
| 568 | var version: std.builtin.Version = .{ .major = 0, .minor = 0, .patch = 0 }; | 570 | var version: std.builtin.Version = .{ .major = 0, .minor = 0, .patch = 0 }; |
| 569 | var have_version = false; | 571 | var have_version = false; |
| 570 | var compatibility_version: ?std.builtin.Version = null; | 572 | var compatibility_version: ?std.builtin.Version = null; |
| 571 | var strip = false; | 573 | var strip = false; |
| 572 | var single_threaded = false; | ||
| 573 | var function_sections = false; | 574 | var function_sections = false; |
| 574 | var watch = false; | 575 | var watch = false; |
| 575 | var debug_compile_errors = false; | 576 | var debug_compile_errors = false; |
| ... | @@ -1129,8 +1130,10 @@ fn buildOutputType( | ... | @@ -1129,8 +1130,10 @@ fn buildOutputType( |
| 1129 | emit_bin = .no; | 1130 | emit_bin = .no; |
| 1130 | } else if (mem.eql(u8, arg, "--strip")) { | 1131 | } else if (mem.eql(u8, arg, "--strip")) { |
| 1131 | strip = true; | 1132 | strip = true; |
| 1132 | } else if (mem.eql(u8, arg, "--single-threaded")) { | 1133 | } else if (mem.eql(u8, arg, "-fsingle-threaded")) { |
| 1133 | single_threaded = true; | 1134 | single_threaded = true; |
| 1135 | } else if (mem.eql(u8, arg, "-fno-single-threaded")) { | ||
| 1136 | single_threaded = false; | ||
| 1134 | } else if (mem.eql(u8, arg, "-ffunction-sections")) { | 1137 | } else if (mem.eql(u8, arg, "-ffunction-sections")) { |
| 1135 | function_sections = true; | 1138 | function_sections = true; |
| 1136 | } else if (mem.eql(u8, arg, "--eh-frame-hdr")) { | 1139 | } else if (mem.eql(u8, arg, "--eh-frame-hdr")) { |