Code Bloat using GCC 3.2 on Linux
Wed Dec 15 14:11:00 GMT 2004
Thanks for that tip. I tried using -Os, but it dosn't help much.
The "bloat" is in all the object files, and the final executable. In
fact all binaries seem to be larger on Linux than on Windows.
I read the following document on templates:
>From this, is it correct to assume that since I'm using gcc 3.2 and ld
2.13, and since I'm working on an ELF system such as Linux, I don't
need to use any of the options that are specified (such as -frepo or
-fno-implicit-templates) because this version of ld would follow the
"Borland Model", and would automatically take care of "each template
instance occurs exactly once in the executable if it is needed, and
not at all otherwise" requirement?
Also, are there any "tools" that can be used to analyze generated code on Linux?
Thanks so much,
On Wed, 15 Dec 2004 13:24:26 +0100, Lars Segerlund
> If the 'bloat' is not in libraries, try -OS ( optimise small ).
> You have also some options like -fno-unrolling ( or something like that ).
> I don't know if you can use -OS with -O2 but try and se if it makes any difference.
> Also it would be nice to knoow where the 'bloat' is, perhaps you can have a look at the generated code with _S ( generates assembly for gcc ) and the corresponding flag for win.
> / regards, Lars Segerlund.
> On Wed, 15 Dec 2004 17:14:54 +0530
> Gaurav Jain <firstname.lastname@example.org> wrote:
> > Hi,
> > I have an application which is compiled using gcc 3.2 on linux. The
> > problem is that the same application compiled on Windows using MS
> > VC.net is much smaller in size (about 1/2) than that on linux. The
> > application uses mainly C++ code, has lots of exception handling and
> > templates.
> > I'm currently using the following options to compile my source files:
> > gcc -x c++ -O2 -fno-omit-frame-pointer -ffloat-store -fno-inline
> > -Wno-multichar -fexceptions -mcpu=pentium
> > and the following for linking:
> > gcc -rdynamic -lm -ldl -lpthread
> > I wish to know whether there are any gcc options that can be used to
> > combat the excessive code bloat using gcc on linux? Why should the
> > same code have 1/2 the size on Windows? What's the way to get the
> > MINIMUM possible size of an application using gcc 3.2 (even if it is
> > at the cost of some run-time performance)?
> > Any help would be highly useful.
> > TIA,
> > -Gaurav
More information about the Gcc-help