diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-11-30 19:19:13 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-11-30 19:21:29 -0700 |
| commit | 40f5e5dfc60ef94e61cc6a83547f3e82b401054c (patch) | |
| tree | ffe5c86a062964c660741eb41c0cfd67179f66d7 /src/Compilation.zig | |
| parent | 89afd4bd33c72c2e608974d182f4624078da3a7f (diff) | |
| download | zig-40f5e5dfc60ef94e61cc6a83547f3e82b401054c.tar.gz zig-40f5e5dfc60ef94e61cc6a83547f3e82b401054c.zip | |
CLI: introduce -fsingle-threaded/-fno-single-threaded
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: #10143
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 29d101e61e..d1af993cbe 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -705,9 +705,9 @@ pub const InitOptions = struct { use_lld: ?bool = null, use_clang: ?bool = null, use_stage1: ?bool = null, + single_threaded: ?bool = null, rdynamic: bool = false, strip: bool = false, - single_threaded: bool = false, function_sections: bool = false, is_native_os: bool, is_native_abi: bool, @@ -1116,7 +1116,11 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { const include_compiler_rt = options.want_compiler_rt orelse needs_c_symbols; - const single_threaded = options.single_threaded or target_util.isSingleThreaded(options.target); + const must_single_thread = target_util.isSingleThreaded(options.target); + const single_threaded = options.single_threaded orelse must_single_thread; + if (must_single_thread and !single_threaded) { + return error.TargetRequiresSingleThreaded; + } const llvm_cpu_features: ?[*:0]const u8 = if (build_options.have_llvm and use_llvm) blk: { var buf = std.ArrayList(u8).init(arena); |
