Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stack_check = false is ignored #20724

Open
LucasSantos91 opened this issue Jul 22, 2024 · 0 comments
Open

stack_check = false is ignored #20724

LucasSantos91 opened this issue Jul 22, 2024 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior os-windows
Milestone

Comments

@LucasSantos91
Copy link
Contributor

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.

@LucasSantos91 LucasSantos91 added the bug Observed behavior contradicts documented or intended behavior label Jul 22, 2024
@andrewrk andrewrk added this to the 0.15.0 milestone Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior os-windows
Projects
None yet
Development

No branches or pull requests

2 participants