Subject: Re: misc/3300: Allow compiling with debug options
To: Simon J. Gerraty <sjg@quick.com.au>
From: Chris G. Demetriou <cgd@cs.cmu.edu>
List: netbsd-bugs
Date: 03/09/1997 02:44:34
> > the current defaults are quite reasonable, as far as I'm concerned.
> 
> I agree.  I'm not talking about changing defaults.  
>
> All I'm after is being able to make and install say /bin/sh with
> debugging info, without having to edit the Makefile, currently, short
> of running make CFLAGS="all the flags that are normally set..."  that
> is not possible - it should be.  And I _occasionally_ find I need to
> compile something without -O so that gdb can follow what is going on
> and/or not lead you astray.
> 
> So yes, the defaults are fine, but they should be just that -
> defaults. 

My point is: You're either trying to change the wrong things in the
wrong places, or you're not adequately explaining what you're trying
to do.


You've said that you want to be able to override -O with something
else for third-party programs.  To do that, you either override CFLAGS
with what you want, or use the appropriate application-provided
Makefile hook to do the right thing.  However, to do this, you've
proposed changing the CFLAGS definition so that you can easily add in
-g.  I say that that's the wrong solution, and outside of the domain
of problems we can reasonable solve.  Third-party makefiles really
have the last word here, and in my opinion we can't make any
reasonable change to the default behaviour to better support what you
want there.

You've said that you want to be able to get rid of stuff like the
standard use -Werror, saying that you don't want to do it sometimes
for sources in the master source tree, and you definitely don't want
to do it most of the time when compiling third-party sources.  An easy
mechanism to enable the former might be appropriate if it were ever
appropriate except in "weird" circumstances to compile sources from
the master source tree without -Werror.  However, it's not, and for
weird circumstances i'd say "just edit the Makefile until the problem
is fixed."  Realistically, if you have to build it once with special
flags, you'll probably have to build it more than once with those
flags.  And, of course, this is _irrelevant_ for third-party sources,
because they don't use the bsd.*.mk files and therefore don't get
-Werror from our make templates anyway.

Finally, for the case of adding "-g" to the default CFLAGS, if you
believe the "if you're doing it once, you'll probably want to do it
more than once" assertion, I'd say that the right way to do it is to
add "CFLAGS += -g" to the Makefile of the program(s) you're trying to
build.  It might make sense to add a variable to the bsd.*.mk
templates to explicitly add a few flags e.g. to enable debugging, but
it looks like COPTS is there already, and exists for that purpose (or
something similar).  In any case, no suggestion that you've proposed
in your PRs does this in a way that doesn't badly affect the
'standard' make rules (i.e. sys.mk).



Your PRs indicate that you're trying to do four things:

(1) remove -Werror when building certain system programs.  I'd say
that since all system programs should be built with -Werror, you
should have to modify a Makefile to do this.

(2) remove -Werror when building third-party programs.  As noted, this
is not a consequence of our make rules, to begin with.

(3) add debugging and/or change optimization flags for third-party
program builts.  As noted, this should be done 'the right way' for the
third-party program makefile(s) in question, and there's little we can
do here.

(4) add debugging and/or change optimization flags for certain system
programs.  If modifying the Makefiles isn't good enough for you (it
typically _is_ good enough for me, because of the "built it once, will
have to build it again" problem), then COPTS should do (which should
even take care of stuff like optimiation if you use -O0).

Therefore, I see all of those as being "taken care of."



cgd