authorgravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2022-08-23 12:45:12+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-29 18:23:14-04:00
logfffece1533d37b917c6e301c984c1cb3eb0040e4
treef36bab534acfbf1362a48b5adeafb0a799913b09
parentd2d42cf7ba5d965786d4bfb2fdc61dbd9a0d2ae5

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.

1 files changed, 8 insertions(+), 13 deletions(-)

src/link/Wasm.zig+8-13
...@@ -2836,24 +2836,19 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !...@@ -2836,24 +2836,19 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !
2836 try argv.append(entry);2836 try argv.append(entry);
2837 }2837 }
28382838
2839 if (self.base.options.output_mode == .Exe) {2839 // Increase the default stack size to a more reasonable value of 1MB instead of
2840 // Increase the default stack size to a more reasonable value of 1MB instead of2840 // the default of 1 Wasm page being 64KB, unless overridden by the user.
2841 // the default of 1 Wasm page being 64KB, unless overridden by the user.2841 try argv.append("-z");
2842 try argv.append("-z");2842 const stack_size = self.base.options.stack_size_override orelse wasm.page_size * 16;
2843 const stack_size = self.base.options.stack_size_override orelse 1048576;2843 const arg = try std.fmt.allocPrint(arena, "stack-size={d}", .{stack_size});
2844 const arg = try std.fmt.allocPrint(arena, "stack-size={d}", .{stack_size});2844 try argv.append(arg);
2845 try argv.append(arg);
28462845
2846 if (self.base.options.output_mode == .Exe) {
2847 if (self.base.options.wasi_exec_model == .reactor) {2847 if (self.base.options.wasi_exec_model == .reactor) {
2848 // Reactor execution model does not have _start so lld doesn't look for it.2848 // Reactor execution model does not have _start so lld doesn't look for it.
2849 try argv.append("--no-entry");2849 try argv.append("--no-entry");
2850 }2850 }
2851 } else {2851 } else if (self.base.options.entry == null) {
2852 if (self.base.options.stack_size_override) |stack_size| {
2853 try argv.append("-z");
2854 const arg = try std.fmt.allocPrint(arena, "stack-size={d}", .{stack_size});
2855 try argv.append(arg);
2856 }
2857 try argv.append("--no-entry"); // So lld doesn't look for _start.2852 try argv.append("--no-entry"); // So lld doesn't look for _start.
2858 }2853 }
2859 try argv.appendSlice(&[_][]const u8{2854 try argv.appendSlice(&[_][]const u8{