Subject: Re: optimizing compilation of netbsd-current
To: Perry E. Metzger <perry@piermont.com>
From: Frederick Bruckman <fredb@immanent.net>
List: netbsd-help
Date: 09/14/2003 23:22:03
On Sun, 14 Sep 2003, Perry E. Metzger wrote:

> Scott Zahn <scott@xeroxparc.net> writes:
>
> > Is there a
> > better way to specify gcc flags other than editing the 20 or so Makefiles
> > and configure scripts?  I already have CFLAGS and CPPFLAGS set in my
> > environment, but they don't seem to have any affect.
>
> The environment won't impact those, but you might try /etc/mk.conf
>
> However, I'm not sure you really want to be touching them...

Especially not ${CFLAGS}, since messing with that will surely break
the build. ${COPTS} has never been well-documented as a user option,
but it's always been the vehicle for tweaking the build. There's a
subtle pitfall there, as some optimizations increase the size of the
binaries, which breaks the installation kernels. The trick is to set
it with '?=' in ${MAKECONF}, like so...

.if ${MACHINE} == "mac68k"
COPTS?=	-m68020-40
.endif

so that the targets that set ${COPTS} themselves (currently only in
the installation kernels) will not be affected.

I should point out that setting "-O3" and various machine specific
optimizations over all the binaries is a great way to identify bugs in
the compiler that no one else has seen, if that's what you're trying
to do. If, on the other hand, you're trying to get a little more speed
on the slowest operations, it might be smarter to start with a clean
build with default options, then tweak likely suspects (like libc,
libcrypto, kernels), until you get the effect you're looking for.

Frederick