A way of some kind to discover whats taking up the most in zig exe size?

the emitted zig executable of my project is rather large considering its a small project still, 43 MB in debug mode, 32 MB for fast mode.

is there some tool that lets me look into the executable and get human-readable information on whats taking space? preferably in descending order.

2 Likes

The same way you examine any other EXE, independent of source language, for the target you’re using (which you haven’t mentioned).

1 Like

On Linux, nm --size-sort <filename> will list out all the symbols in your file sorted by size (biggest at the bottom).

2 Likes

Bloaty McBloatface (yes it was really called that at one time) is pretty good, also lets you create diffs:

Docs: bloaty/doc/using.md at main · google/bloaty · GitHub

6 Likes

also consider using exe.strip = true if you for example don’t care about having good stack traces.

If I remember correctly some people also manually strip the exe with external tools in such a way that you can re-add the symbol information later again, but I don’t have practical experience with that.

I think on windows that info is separate from the exe in the .pdb file anyway, so there it is already stored in a way where you don’t have to deploy the debug info and can access it separately.

1 Like