diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-05-07 20:03:27 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-05-07 20:03:27 -0700 |
| commit | d577654e66e3a69592df2a37817260b59a2a190b (patch) | |
| tree | 77573b1d6986362eafadc5b93f009b155c351392 /src/main.zig | |
| parent | 81d5104e228dc30184b31158c1b36ec0ec371b0b (diff) | |
| download | zig-d577654e66e3a69592df2a37817260b59a2a190b.tar.gz zig-d577654e66e3a69592df2a37817260b59a2a190b.zip | |
stage2: fix stack overflow in `@setEvalBranchQuota` test case
Some of the reworkings in this branch put us over the limit, on Linux,
where the kernel disregards the fact that we ask for 16 MiB in the ELF
file. So we ask for more stack space in `main`.
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig index 01be971602..ae7c8995a3 100644 --- a/src/main.zig +++ b/src/main.zig @@ -180,6 +180,18 @@ pub fn mainArgs(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v defer log_scopes.deinit(gpa); + if (@import("builtin").target.os.tag == .linux) { + // Linux does not respect the stack size specified in the ELF, so we + // have to do this at runtime. TODO move this code to start.zig using + // the GNU_STACK program header. + std.os.setrlimit(.STACK, .{ + .cur = 16 * 1024 * 1024, + .max = 16 * 1024 * 1024, + }) catch |err| { + warn("unable to increase stack size to 16 MiB", .{}); + }; + } + const cmd = args[1]; const cmd_args = args[2..]; if (mem.eql(u8, cmd, "build-exe")) { |
