vezel-dev / zig-sdk

An MSBuild SDK for building Zig, C, and C++ projects using the Zig compiler.

Home Page:https://docs.vezel.dev/zig-sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use `-O0` instead of `-Og` for `Debug` builds

alexrp opened this issue · comments

// These exact flags are treated specially by zig cc/c++. They
// activate Debug, ReleaseFast, ReleaseSafe, and ReleaseSmall
// respectively. This in turns activates a bunch of other
// mode-specific flags that we do not have to specify here as a
// result.
builder.AppendSwitch((_configuration, _releaseMode) switch
{
(ZigConfiguration.Debug, _) => "-Og",
(ZigConfiguration.Release, ZigReleaseMode.Fast) => "-O3",
(ZigConfiguration.Release, ZigReleaseMode.Safe) => "-O2 -fsanitize=undefined",
(ZigConfiguration.Release, ZigReleaseMode.Small) => "-Oz",
_ => throw new Exception(),
});

See: ziglang/zig#11949

Also review our use of -O3 vs -O2.