aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Compilation.zig2
-rw-r--r--src/main.zig27
-rw-r--r--src/target.zig5
3 files changed, 26 insertions, 8 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index fe13df8097..4e0a36d652 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -1029,7 +1029,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
const include_compiler_rt = options.want_compiler_rt orelse needs_c_symbols;
- const must_single_thread = options.target.isWasm() and !options.linker_shared_memory;
+ 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;
diff --git a/src/main.zig b/src/main.zig
index 4726d3e308..1b4a93eb45 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -2428,15 +2428,28 @@ fn buildOutputType(
link_libcpp = true;
}
- if (target_info.target.cpu.arch.isWasm() and linker_shared_memory) {
- if (output_mode == .Obj) {
- fatal("shared memory is not allowed in object files", .{});
+ if (target_info.target.cpu.arch.isWasm()) blk: {
+ if (single_threaded == null) {
+ single_threaded = true;
}
+ if (linker_shared_memory) {
+ if (output_mode == .Obj) {
+ fatal("shared memory is not allowed in object files", .{});
+ }
- if (!target_info.target.cpu.features.isEnabled(@intFromEnum(std.Target.wasm.Feature.atomics)) or
- !target_info.target.cpu.features.isEnabled(@intFromEnum(std.Target.wasm.Feature.bulk_memory)))
- {
- fatal("'atomics' and 'bulk-memory' features must be enabled to use shared memory", .{});
+ if (!target_info.target.cpu.features.isEnabled(@intFromEnum(std.Target.wasm.Feature.atomics)) or
+ !target_info.target.cpu.features.isEnabled(@intFromEnum(std.Target.wasm.Feature.bulk_memory)))
+ {
+ fatal("'atomics' and 'bulk-memory' features must be enabled to use shared memory", .{});
+ }
+ break :blk;
+ }
+
+ // Single-threaded is the default for WebAssembly, so only when the user specified `-fno_single-threaded`
+ // can they enable multithreaded WebAssembly builds.
+ const is_single_threaded = single_threaded.?;
+ if (!is_single_threaded) {
+ fatal("'-fno-single-threaded' requires the linker feature shared-memory to be enabled using '--shared-memory'", .{});
}
}
diff --git a/src/target.zig b/src/target.zig
index 28833428a7..f07dcc43d2 100644
--- a/src/target.zig
+++ b/src/target.zig
@@ -207,6 +207,11 @@ pub fn supports_fpic(target: std.Target) bool {
return target.os.tag != .windows and target.os.tag != .uefi;
}
+pub fn isSingleThreaded(target: std.Target) bool {
+ _ = target;
+ return false;
+}
+
/// Valgrind supports more, but Zig does not support them yet.
pub fn hasValgrindSupport(target: std.Target) bool {
switch (target.cpu.arch) {