public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Limiting code size with -g2 with c++ template lib
@ 2008-06-08 15:26 Benoît Jacob
  2008-06-08 15:55 ` Benoît Jacob
  0 siblings, 1 reply; 2+ messages in thread
From: Benoît Jacob @ 2008-06-08 15:26 UTC (permalink / raw)
  To: gcc-help

[-- Attachment #1: Type: text/plain, Size: 1251 bytes --]

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 #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Limiting code size with -g2 with c++ template lib
  2008-06-08 15:26 Limiting code size with -g2 with c++ template lib Benoît Jacob
@ 2008-06-08 15:55 ` Benoît Jacob
  0 siblings, 0 replies; 2+ messages in thread
From: Benoît Jacob @ 2008-06-08 15:55 UTC (permalink / raw)
  To: gcc-help

[-- Attachment #1: Type: text/plain, Size: 2006 bytes --]

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 #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-06-08 15:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-08 15:26 Limiting code size with -g2 with c++ template lib Benoît Jacob
2008-06-08 15:55 ` Benoît Jacob

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).