After examination of the assembly code it seems that in fact a lot of the size is debug info about local variables. So, please read my first mail with respect to that too, not just line number info! From `man gcc` it seems that local vars and line numbers are the only two differences between -g2 and -g1. Here I uploaded the generated assembly file with -O2 -g2: http://download.tuxfamily.org/eigen/benchmark-g2.s.gz And here is the file generated by -O2 -g1: http://download.tuxfamily.org/eigen/benchmark-g1.s.gz So do you have an idea how to prevent the 20x difference in code size between -g1 and -g2 ? Cheers, Benoit On Sunday 08 June 2008 17:25:58 Benoît Jacob wrote: > Hi List, > > I am developing a C++ pure-template-library, with a lot of meta-programming > (expression templates). > > With the default debugging level (-g2), the produced executable has a huge > size. Like, 300 kb for a simple program. > > With -g1, the executable size is much more reasonable -- less than 150% of > the size obtained with -g0. > > I believe that the main difference between -g1 and -g2 is that -g2 enables > source-code-line-number information. Also, "nm" tells me that there are > very few symbols (function names) in my executables. > > I would like to do either of the following: > > 1) tell gcc to only emit line-number info for these lines of code that > actually produce code in the executable, after optimization. > > 2) tell gcc to just not emit any line-number info for the code inside my > template lib. Something like (I know that Pragma doesn't exist!): > _Pragma("dont_emit_line_number_info"); > #include<MyTemplateLib/Headers> > _Pragma("end_of_dont_emit_line_number_info"); > > Is any of that possible? Do you see anything else that might help limit the > size of code generated by -g2? > > Of course the users of my lib want to use -g2 not -g1 when compiling their > own app! > > Thanks a lot in advance for any help, > > Benoit
Attachment:
signature.asc
Description: This is a digitally signed message part.