Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does compilation with -g result in slower code?

I am using a package that is compiled using gcc -O3 -g.

Since some function calls to that code are the slowest part of my program I am wondering if the -g could be the culprit? Or should it not matter in terms of runtime?

like image 595
Frank Avatar asked Jun 07 '26 04:06

Frank


1 Answers

Since -O3 implies aggressive inlining, and -g implies avoiding inlining so that the debugger can have function addresses, those options are somewhat at odds. Nevertheless in general -O3 wins, and aside from a somewhat larger binary -- and the minor speed effects that might come from paging or nonlocality -- it should not make much of a difference.

like image 109
Ernest Friedman-Hill Avatar answered Jun 10 '26 02:06

Ernest Friedman-Hill



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!