Date: Tue, 11 Oct 2005 10:22:20 +1000 (EST) From: Bruce Evans <bde@zeta.org.au> To: Kris Kennaway <kris@obsecurity.org> Cc: freebsd-amd64@FreeBSD.org Subject: Re: /etc/make.conf flags for Intel Message-ID: <20051011090639.K69382@delplex.bde.org> In-Reply-To: <20051010174358.GA34176@xor.obsecurity.org> References: <BF6ED99E.2166%webmaster@machowto.com> <b41c75520510091438p11ac250am@mail.gmail.com> <20051010072456.GA52280@xor.obsecurity.org> <b41c75520510100046t17d1bd10m@mail.gmail.com> <20051010174358.GA34176@xor.obsecurity.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 10 Oct 2005, Kris Kennaway wrote: > On Mon, Oct 10, 2005 at 09:46:49AM +0200, Claus Guttesen wrote: >>>>> Hey, how should I tune my /etc/make.conf file for my Intel Xeon (EM64) Box? >>>> Change CFLAGS line from -O to -O2. >>> >>> It *is* the default. >> >> /usr/share/examples/etc/make.conf is set to -O. > > The setting in <sys.mk> trumps this documentation file, but you're > right, this should be updated there. Could you please send a PR? The example is correct. It shows how to change the default of "-O2 -fstrict-aliasing -pipe" to "-O -pipe". It would be less than useful to repeat the default in the examples or in /etc/make.conf. In the example, it would be less than useful because it gives a confusing example that should never be copied. In /etc/make.conf, it would be less than useful because any setting of CFLAGS there breaks overriding the setting of CFLAGS on the command line or in the environment, so setting of CFLAGS there should be avoided, especially almost-null ones which have no effect except to break the command line and environment settings. (The breakage is due to having to work around the bug that /etc/make.conf is included in sys.mk too late. CFLAGS should be set using "?=" like sys.mk does, but since /etc/make.conf is included after CFLAGS is set by that in sys.mk if not earlier, CFLAGS is surely set in /etc/make.conf so "?=" doesn't work there, so "=" must be used.) The example gave a useful variation of the default until rev.1.50 in 1997, but was bogus after that until the default was changed in 2004. The example is just missing comments saying that it gives a variation. In 1.49 it had a comment which indirectly said that the change is a variation indirectly by saying that it might be useful ("One, probably the most common, use could be #CFLAGS= -O -pipe"). That comment became nonsense in 1.50 but has been replaced by one that says nothing about what this setting might be useful for. It is a bug in sys.mk that -O2 is the default. If -O2 were the best general-purpose optimization level, then it would be spelled -O. -O2 still doesn't actually work. sys.mk has a hack, -fno-strict aliasing together with -O2, to make aliasing bugs in sources harmless. This is not documented in make.conf(5) or in the example of course. So -O2 isn't actually the default, and changing CFLAGS from -O (-pipe ...) to -O2 (-pipe ...) in /etc/make.conf has no effect except to lose the -fno-strict-aliasing hack. -pipe is also not documented in make.conf(5) so it can easily be lost, thus pessimizing compile time. It is present in the examples. >> Copy /usr/share/examples/etc/make.conf to /etc if make.conf is >> missing/empty and make the changes below. >> >> CPUTYPE=nocona >> CFLAGS= -O2 -pipe >> COPTFLAGS= -O2 -pipe > > COPTFLAGS=-O2 is a bad idea if your kernel panics and you need > assistance, because it often munges the debugging backtraces to the > point of uselessness. -O2 is also the default for the kernel, unless CC is icc or -DEBUG is defined. So setting COPTFLAGS as above has no effect except to mess up the icc and DEBUG cases and break overriding COPTFLAGS on the command line or in the environment. (Kernel bug: the DEBUG case only prevents munging the backtraces if the kernel was compiled with full debugging. -O2 should also be turned off for the DDB case, which would make it default to off in -current since DDB defaults to on.) Back to user and userland bugs: unlike for CFLAGS, there is no problem with using "?=" to set COPTFLAGS correctly in /etc/make.conf. Almost all the examples get this wrong by giving only an example using "=". -O2 is now safer to use for the kernel since the kernel is not general purpose and bugs in it are found quickly. It is just not very useful in the kernel because most kernel code doesn't benefit much from the optimizations done by -O2 and most systems shouldn't spend more than a few percent of their time in the kernel (except while idling). Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051011090639.K69382>