-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
ReleaseSmall macOS hello world binary 51K vs. only 33K with C #20468
Comments
Note that for "real" code, you should use Edit: That said, it seems like |
@alexrp Ah good point. I had hoped pub fn main() void{
@import("std").io.getStdErr().writer().writeAll("Hello\n") catch unreachable;
} Same binary size, same otool and nm output. |
Ok, that I can't explain. That seems odd. I guess this is why the mutex global variable is not completely eliminated though: Lines 85 to 104 in cb308ba
|
Zig Version
0.14.0-dev.130+cb308ba3a
Steps to Reproduce and Observed Behavior
Environment
I'm on macOS Sonoma 14.5 on MacBook Pro with the Apple M1 Pro chip.
Reproduce
Hello world in C compiled with clang is 33K:
Hello world in Zig is 51K:
Investigation
Here's my theory. The hello-c binary has no
__DATA
segment:On the other hand, hello-zig has an 80 byte
__DATA
segment, pushing the final__LINKEDIT
segment to offset 0xc000 for 16K page alignment:I'm not sure about the other sections, but let's look at
__data
for hello-c:And for hello-zig:
That
_Progress.stderr_mutex.0
looks suspicious to me. I believe it comes from here:zig/lib/std/Progress.zig
Line 1388 in cb308ba
But I'm not using std.Progress anywhere so I don't know how it makes it into the final binary.
Expected Behavior
Zig should be able to match the binary size of C/clang.
The text was updated successfully, but these errors were encountered: