Best practices

Hi clangers
is there any best practices which can be used to to reduce disk footprints of executable and lib generated by clangs,
Usually binaries generated by clang is larger than those of gcc.


I can confirm that Clang's record WRT codegen size is quite far from good. The main problems I've identified are:
- excessive inlining (even with -Os)
- template bloat
- no support for fno-inline, -fno-inline-functions or -finline-limit

Here are some related tickets by me (you can find some tips how to "minimize damage"):

By others:

These don't help either:

...from the date of the tickets and lack of response one can only deduce that this is of no or very low priority to Clang developers (or in "bitch mode": they only care about synthetic benchmarks and not about real world behaviour)... :confused:

If this is the case, Too bad.

I seriously doubt that synthetic benchmarks are very much valued. They are nice to expose pathological behaviors, but not much beyond that.

It just seems that this is of lower priority than other stuff (C++11 support !!) and that you just happen to care more about that the average user.

Still, this is an open source project, so if nobody deals with it and you happen to really need it, maybe you could delve into it yourself or try to find someone to do it for you ? (maybe even a contractor) The community is generally welcoming to developers, so don’t be shy :slight_smile:

– Matthieu

Yup, I agree with your last point as this is open source project. Unfortunately, I use for clang for our open source project, so unable to afford someone, who can do it for us.
So unless someone volunteers to do it. People will be inclined to use clang for development build but at the time of release, we will resort to gcc.

For what it's worth, in my experience clang produces about 10% smaller
code than gcc (relative to 4.2/mac and 4.4/linux). Admittedly, this is
at -O2, not at -Os.