From: Jef D. <jef...@ho...> - 2008-05-28 08:30:20
|
Brian Dessent wrote: > Jef Driesen wrote: > >> I tried compiling with CFLAGS='-gdwarf-2', but the size reduction is >> only about 10KB (for both the object files and the final dll). I also >> tried with CFLAGS='-g0' to disable debug info, and the size reduction is >> now around 40KB. So I don't think the debug info is the problem here. > > You said already that stripping the DLL eliminates the discrepancy, and > that amounts to nothing more than removing sections containing debug > info. So of course it's the debug info. > > Note that changing CFLAGS only affects the debug info generated for your > objects. You also have to consider that you may be linking with a > library with STABS debug data when linking the DLL -- things such as > libmingw, libmingwex, and the dllcrt2.o startup code all contain code > that is linked into your DLL and all can have debug info depending on > how they were built. > > The contents of the file is not a mystery. Use objdump -h to see the > sections and their sizes. For example, if you build your objects > without -g and you still see .stab/.stabstr and/or .debug_* sections, > you know that you're pulling in debug data from those other sources. I checked, and there are indeed .stab and .stabstr sections present. So now that I know where the size increase is coming from, how do I avoid it? Is there a compiler flag to automatically strip the produced binary? I tried CFLAGS='-s', but it only strips the object files, thus producing exactly the same result as with CFLAGS='-g0'. >>> Note that this has nothing to do with Dwarf-2 exception handling, using >>> -gdwarf-2 does not affect EH -- that cannot be switched at runtime, it >>> is configured when the compiler is built. >> This is a C project, not C++, so I don't think EH has anything to do >> with it. > > I never said that EH had anything to do with your size issue, I just > wanted to make it clear for the archives that selecting Dwarf-2 vs STABS > for the debug format has nothing to do with choosing Dwarf-2 vs SJLJ for > the EH method. Then I just misunderstood you. |