Compiling without -g

Torbjorn Lindgren tl@funcom.com
Thu Jan 22 02:29:00 GMT 1998


On 19 Jan 1998, Joseph H. Buehler wrote:
> Jonathan Buzzard <jab@hex.prestel.co.uk> writes:
> > I grabed a copy of egcs-1.0.1 in order to get a better C++ compiler than
> > gcc-2.7.2. However without going round editting all the Makefiles is
> > there anyway to stop it using the -g flag everywhere as I am a little
> > short on disk space. 
> 
> Here's what I do sometimes:

There are multiple ways of doing that, the two standard ways I know of
doing it is:

1. Tell configure that you want -O2 by setting the CFLAGS environment
   variable before running configure. This will set both CFLAGS and
   CXXFLAGS in the generated Makefile to the specified flags, and these
   will then be passed downwards.

2. Override it when starting make by giving it specific CFLAGS and
   CXXFLAGS (both will probably be necessary here). These will be
   propagated downwards as usual (see 1).


Both these works with egcs AFAIK.

Example of method 1:
setenv CFLAGS -O2   (or export CFLAGS=-O2)
./configure --prefix=whatever ...
make

Example of method 2:
make CFLAGS=-O2 CXXFLAGS=-O2


Do note that both these will generate a compiler without debugging
information, if you run into trouble this can be a problem! 
(If the problem is repeatable it's not that bad)


> find -type f |
> 	xargs grep -l 'FLAGS[	 ]*=' |
> 	xargs perl -p -i -e 's#(-O\d?|-g)\b#-O#g if (/FLAGS\s*=/)'

But at least it's better than this :-)
*All* files? At least check the name against '[Mm]akefile' first.


> Still haven't been able to get egcs to compile under redhat 5.0,
> though...

egcs 1.0.1 compiles fine under RedHat 5.0. Several other people have also
reported that they had no problem compiling egcs 1.0.1 on RedHat 5.0
either.


-- 
Torbjörn Lindgren
E-mail: tl@funcom.com
If Santa ever DID deliver presents on Christmas Eve, he's dead now.




More information about the Gcc mailing list