zig
zig copied to clipboard
`stack_check = false` is ignored
Zig Version
0.14.0-dev.367+a57479afc
Steps to Reproduce and Observed Behavior
main.zig
const std = @import("std");
pub fn main() void {
const a: [4096]u8 = undefined;
std.mem.doNotOptimizeAway(a);
}
build.zig
const std = @import("std");
pub fn build(b: *std.Build) void {
const exe = b.addExecutable(.{
.name = "stackCheck",
.root_source_file = b.path("src/main.zig"),
.target = b.host,
.optimize = .ReleaseFast,
});
exe.root_module.stack_check = false;
b.installArtifact(exe);
const emitAsm = b.addInstallFile(exe.getEmittedAsm(), "bin/asm.s");
b.getInstallStep().dependOn(&emitAsm.step);
}
Emitted assembly:
wWinMainCRTStartup:
.Lfunc_begin0:
.cv_func_id 0
.cv_file 1 "C:\\Program Files\\Zig\\lib\\std\\start.zig"
.cv_loc 0 1 365 0
.seh_proc wWinMainCRTStartup
push rbp
mov eax, 4144
.seh_pushreg rbp
call ___chkstk_ms
sub rsp, rax
.seh_stackalloc 4144
.seh_setframe rbp, 128
lea rbp, [rsp + 128]
.seh_endprologue
and rsp, -16
lea rax, [rsp + 48]
I'm on Windows 10. This happens at all optimization levels.
Expected Behavior
When exe.root_module.stack_check = false;, the emitted assembly should not contain call ___chkstk_ms.