Why is a Rust executable large?
I've been playing around with a tool to answer the more generic question: why is my binary (written in C, C++, Rust, etc) so large?<p>We use CPU profilers to tell us why our programs are slow.  My tool is intended to be a <i>size</i> profiler: why is my program big?<p>It turns out there are some really interesting analyses and visualizations you can perform to answer this question.<p>A few direct comments on the article:<p>- I do not recommend stripping your binaries completely!  Use "strip --strip-debug" instead (or just don't compile with -g).  You should realize that debug information and the symbol table are two separate things.  The debug information is much larger (4x or more) and much less essential.  If you strip debug information but keep the symbol table, you can still get backtraces.<p>- I don't believe -Wl,--gc-sections has any effect unless you also compile with -ffunction-sections and/or -fdata-sections, which these examples for C/C++ do not.<p>If you care about binary size in C or C++ you should probably be compiling with -ffunction-sections/-fdata-sections/-Wl,--gc-sections these days.  Sadly, these are not the default.