Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there disadvantage in building with -g -O and strip vs. building only with -O

Tags:

c

gcc

I have a C code executable for Linux.

For release, I can have two options:

One is build with -g -O3, strip the debug (strip -g) and send the output as release. Second is build the release directly with -O3.

The advantage of the first option, if I understand correctly, is that I can use the exe before the stripping for remote debugging or for analyzing core dumps.

The question is if there is any disadvantages in this approachi.e., is there run time performance overhead of building with -g and then stripping

thanks.

like image 544
eran Avatar asked Jun 06 '11 08:06

eran


People also ask

What are the advantages and disadvantages of cast in situ concrete?

The advantages of this technology include the building's strength, insulation, and adaptability to a variety of building styles. Disadvantages include a higher labor need and increased costs. Formwork is needed to design the shape of cast-in-place concrete as it cures.


1 Answers

There is no run time performance hit for using -g. The debug info lives in a separate section of the executable, which wont even be loaded if you execute the file.

But you can separate debug info and executables if you wish (which still won't make any performance difference). My Gentoo Linux handles it this way, the reason is simply minimizing used disk space which allows me having all binaries on a small fast disk while still keeping the debug info, which is alomst never used, in a separate partition.

objcopy --only-keep-debug foo foo.debug
strip -g foo

Now you have a foo executable and a foo.debug which contains debug symbols.

like image 96
Gunther Piez Avatar answered Sep 28 '22 22:09

Gunther Piez