ReleaseSmall is not small anymore?

I just tried zig 0.16 in Windows and it turned out that the result binary file for the simplest test program is much larger then in the previous version with the same flags. I try this basic command to compile:

 zig build-exe main.zig -target x86_64-windows -O ReleaseSmall

In the version 0.15.2 the result exe file is 14Kb, in 0.16 – it is close to 500Kb. Maybe I missed something and now I need more flags for a minimal binary with dynamic linking to the system files? Can someone share their experience for creating small binaries?

2 Likes

tracked by https://codeberg.org/ziglang/zig/issues/31421

6 Likes

on 0.17.0-dev.1516+8a4b5424d, I found out that using @panic() in my code makes my dynamic library jumps from 2kb to 140kb.

You can reproduce these results using these two programs

export fn foo() void {
    unreachable;
}

and

export fn foo() void {
    @panic("panic");
}

and compiling them with zig build-lib main.zig -lc -dynamic -O ReleaseSmall

2 Likes