Clang generated binary sizes

When I use gcc to compile a C++ project I'm currently working on, the
final executable size is 4MB.
When I use clang++ to compile the exact same code, the final executable
size is 7MB.

The optimization flags used are -O3 -funroll-loops and -funswitch-loops.

How can I go about diagnosing this bloat?

I'm not sure it's necessarily bloat, but you can try to find out what's going on
by looking at the code generated. I'd particularly look at inlining of functions
as we may be doing more inlining than in your version of gcc. Otherwise you'll
just need to look at the sizes of various functions and see why they're


I would start by comparing the sizes of individual .o files. If you
can find one that differs noticeably from GCC, that might give a clue.
It would also be interesting to know what the -O2 numbers are.

- Daniel