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

HelloWorld binary size increased a lot in recent Zig versions #20711

Open
hronro opened this issue Jul 21, 2024 · 4 comments
Open

HelloWorld binary size increased a lot in recent Zig versions #20711

hronro opened this issue Jul 21, 2024 · 4 comments
Labels
contributor friendly This issue is limited in scope and/or knowledge of Zig internals. optimization regression It worked in a previous version of Zig, but stopped working.
Milestone

Comments

@hronro
Copy link

hronro commented Jul 21, 2024

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 hronro added the bug Observed behavior contradicts documented or intended behavior label Jul 21, 2024
@linusg
Copy link
Sponsor Contributor

linusg commented Jul 25, 2024

Possibly related: #20468

@andrewrk andrewrk added contributor friendly This issue is limited in scope and/or knowledge of Zig internals. optimization regression It worked in a previous version of Zig, but stopped working. and removed bug Observed behavior contradicts documented or intended behavior labels Jul 26, 2024
@andrewrk andrewrk added this to the 1.0.0 milestone Jul 26, 2024
@dotdot0
Copy link

dotdot0 commented Jul 28, 2024

Can I work on this one?

@RetroDev256
Copy link

Just adding a data point here - I have also noticed this - I have dabbled in programming very small programs in Zig, and can no longer find a way to make my programs less than ~4 KiB with Zig alone. I suspect some padding (and alignment) has been added to the sections.

@pavelverigo
Copy link
Contributor

Currently on 0.14.0-dev.1002+71a27ebd8:

ReleaseFast ReleaseSmall
5.1K 3.6K

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor friendly This issue is limited in scope and/or knowledge of Zig internals. optimization regression It worked in a previous version of Zig, but stopped working.
Projects
None yet
Development

No branches or pull requests

6 participants