aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuuk de Gram <luuk@degram.dev>2022-08-23 12:45:12 +0200
committerAndrew Kelley <andrew@ziglang.org>2022-08-29 18:23:14 -0400
commitfffece1533d37b917c6e301c984c1cb3eb0040e4 (patch)
treef36bab534acfbf1362a48b5adeafb0a799913b09
parentd2d42cf7ba5d965786d4bfb2fdc61dbd9a0d2ae5 (diff)
downloadzig-fffece1533d37b917c6e301c984c1cb3eb0040e4.tar.gz
zig-fffece1533d37b917c6e301c984c1cb3eb0040e4.zip
wasm-lld: set stack size to 1MB by default
Regardless of the build mode (build-exe, build-lib), always set the default stack size to 1MB. Previously, this was only done when using build-exe, making the inconsistancy confusing. The user can still override this behavior by providing the `--stack <size>` flag.
-rw-r--r--src/link/Wasm.zig21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig
index 727f329f4b..e20703cb2b 100644
--- a/src/link/Wasm.zig
+++ b/src/link/Wasm.zig
@@ -2836,24 +2836,19 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !
try argv.append(entry);
}
- if (self.base.options.output_mode == .Exe) {
- // Increase the default stack size to a more reasonable value of 1MB instead of
- // the default of 1 Wasm page being 64KB, unless overridden by the user.
- try argv.append("-z");
- const stack_size = self.base.options.stack_size_override orelse 1048576;
- const arg = try std.fmt.allocPrint(arena, "stack-size={d}", .{stack_size});
- try argv.append(arg);
+ // Increase the default stack size to a more reasonable value of 1MB instead of
+ // the default of 1 Wasm page being 64KB, unless overridden by the user.
+ try argv.append("-z");
+ const stack_size = self.base.options.stack_size_override orelse wasm.page_size * 16;
+ const arg = try std.fmt.allocPrint(arena, "stack-size={d}", .{stack_size});
+ try argv.append(arg);
+ if (self.base.options.output_mode == .Exe) {
if (self.base.options.wasi_exec_model == .reactor) {
// Reactor execution model does not have _start so lld doesn't look for it.
try argv.append("--no-entry");
}
- } else {
- if (self.base.options.stack_size_override) |stack_size| {
- try argv.append("-z");
- const arg = try std.fmt.allocPrint(arena, "stack-size={d}", .{stack_size});
- try argv.append(arg);
- }
+ } else if (self.base.options.entry == null) {
try argv.append("--no-entry"); // So lld doesn't look for _start.
}
try argv.appendSlice(&[_][]const u8{