Subject: Problems with system makefiles and optimization flags
To: None <tech-toolchain@netbsd.org>
From: Jason R Thorpe <thorpej@wasabisystems.com>
List: tech-toolchain
Date: 11/06/2002 19:31:03
Revision 1.57 of <sys.mk> introduced a new "DBG" variable to hold
default CFLAGS.  This is broken for a couple of reasons:

	1. <sys.mk> contains the default rules for ALL Makefiles,
	   not just the NetBSD source tree Makefiles, i.e. random
	   3rd party programs with their own Makefiles are allowed
	   by POSIX to use default rules, which are provided by
	   <sys.mk>.  The "DBG" variable intrudes on the namespace.

	2. The kernel and userland Makefiles now use completely
	   different variables for holding the optimization flags.

In addition, the way people are using the "cpuflags" package is
causing problems -- people are setting CFLAGS in such a way that
all optimization is being disabled as a result.

...and there's yet another problem.  In some environments, it's
necessary to pass the "CPU flags" (e.g. "-mcpu=xscale" or
"-mcpu=r4400 -mips2") when processing assembler files (.S) because
these options have an impact on which CPP symbols are defined when
the .S file is processed.  In order to do this, the flags need to
also be added to AFLAGS.

What I'd like to do is add a .CPU_FLAGS variable that <sys.mk> and
the kernel Makefiles can use to add these flags to CFLAGS and AFLAGS.
The . prefix is to keep it out of the namespace that random 3rd party
Makefiles might use.  I would also like to remove the DBG variable
from <sys.mk>.

Comments?

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>