Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an option for gcc which discards -g flag?

I'm building a package which provides many makefiles, each makefile has hard coded in side something like

CFLAGS = -g -O2 -Wall ...
CXXFLAGS = -g -O2 -Wall ...

I want to discard -g option but I don't want to edit all makefiles (even not automatically with sed or something similar). The configure script which comes with the package doesn't have enable/disable debug option but I can pass it CFLAGS and CXXFLAGS variables and it concatenates their values to the CFLAGS and CXXFLAGS variables respectively which include the -g option.

Is there an option which will discard -g in case it is specified? Something like

gcc -option-im-looking-for -g file.c -o file

Will build the binary file without debug symbols. I don't want to strip the binary, I want it to be created stripped.

like image 691
e271p314 Avatar asked Oct 23 '13 12:10

e271p314


1 Answers

You could negate the effect of -g by adding -g0. Saying

gcc -g -g0 foo.c -o file.o

would produce a binary identical to one obtained by saying

gcc foo.c -o foo.o

Quoting man gcc:

   -glevel
   ...
        Level 0 produces no debug information at all.  Thus, -g0 negates
       -g.
like image 154
devnull Avatar answered Oct 09 '22 19:10

devnull