zig icon indicating copy to clipboard operation
zig copied to clipboard

HelloWorld binary size increased a lot in recent Zig versions

Open hronro opened this issue 1 year ago • 4 comments

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

Say we want to build a very simple HelloWorld program in x86_64 Linux:

const std = @import("std");

pub fn main() !void {
    std.debug.print("Hello World\n", .{});
}

Let's try to build them in different versions of Zig with different modes (all of them have enabled exe.strip = true; in build.zig), and here are the binary sizes of them:

Zig Version ReleaseFast ReleaseSmall
0.9.1 4.6K 4.6K
0.10.1 13K 8.5K
0.11.0 13K 8.7K
0.12.1 11K 9.0K
0.13.0 13K 13K

Expected Behavior

Binary size should not increase much compared to v0.9.1, at least in ReleaseSmall mode.

hronro avatar Jul 21 '24 16:07 hronro

Possibly related: #20468

linusg avatar Jul 25 '24 16:07 linusg

Can I work on this one?

dotdot0 avatar Jul 28 '24 10:07 dotdot0

Currently on 0.14.0-dev.1002+71a27ebd8:

ReleaseFast ReleaseSmall
5.1K 3.6K

pavelverigo avatar Aug 10 '24 18:08 pavelverigo

Maybe it would make sense to check the binary size as part of regression testing?

ar-qun avatar Sep 24 '24 07:09 ar-qun

Seems to have improved a lot?

~$ cat x.zig
const std = @import("std");

pub fn main() !void {
    std.debug.print("Hello World\n", .{});
}
~$ zig build-exe x.zig -target x86_64-linux -OReleaseSmall && wc -c x
5232 x

Oh https://github.com/ziglang/zig/issues/20711#issuecomment-2282244798 already said this

Well, I think this can be closed.

ghost avatar Dec 20 '24 04:12 ghost