Is a program compiled with -g gcc flag slower than the same program compiled without -g?

Posted by e271p314 on Stack Overflow See other posts from Stack Overflow or by e271p314
Published on 2014-06-09T09:12:06Z Indexed on 2014/06/09 9:24 UTC
Read the original article Hit count: 222

Filed under:
|
|
|

I'm compiling a program with -O3 for performance and -g for debug symbols (in case of crash I can use the core dump). One thing bothers me a lot, does the -g option results in a performance penalty? When I look on the output of the compilation with and without -g, I see that the output without -g is 80% smaller than the output of the compilation with -g. If the extra space goes for the debug symbols, I don't care about it (I guess) since this part is not used during runtime. But if for each instruction in the compilation output without -g I need to do 4 more instructions in the compilation output with -g than I certainly prefer to stop using -g option even at the cost of not being able to process core dumps.

How to know the size of the debug symbols section inside the program and in general does compilation with -g creates a program which runs slower than the same code compiled without -g?

© Stack Overflow or respective owner

Related posts about c++

Related posts about debugging