optimization levels for 6-STABLE build{kernel,world}

Oliver Fromme olli at lurza.secnetix.de
Wed Sep 13 03:56:45 PDT 2006


Pete Slagle wrote:
 > Oliver Fromme wrote:
 > > Marc G. Fournier wrote:
 > > > What are ppl currently using for CFLAGS/COPTFLAGS in /etc/make.conf for 
 > > > building kernel/world?  I know awhile back it wasn't recommended to go 
 > > > above -O2, for instance, but suspect that has changed ... ?
 > > 
 > > The best optimization is probably to not override the
 > > defaults at all, because they're already pretty optimal.
 > > In fact, by overriding the defaults there's a good chance
 > > to make things worse.  :-)
 > > 
 > > The default CFLAGS are "-O2 -pipe -fno-strict-aliasing".
 > > Anything above -O2 isn't supported, and using -O2 without
 > > -fno-strict-aliasing also isn't supported (and will create
 > > broken code for some programs).  A common mistake is to
 > > specify CFLAGS="-O2 -pipe" and omit -fno-strict-aliasing.
 > > That'll shot you in the foot sooner or later.
 > 
 > /etc/make.conf on most of my 6.1 machines contains (in part) this:
 > 
 >    CFLAGS=    -O2 -pipe -fno-strict-aliasing

Which is exactly the default, so there's no reason to
specify it at all.

If, at some point in the future, the default changes
(e.g. -O3 is considered "good and safe", or any other
-fno-xxx option becomes necessary with -O2), then you
won't benefit from it, because you override it.

 >    COPTFLAGS= -O2 -pipe

As Ruslan explained, -fno-strict-aliasing will be added
automatically in the case of COPTFLAGS if necessary.

So my recommendation is still:  Don't override CFLAGS
or COPTFLAGS.  Chances are that you make things worse,
now or at some point in the future.

 > Just to be completely clear, are you saying that this
 > 
 >    CFLAGS=    -O2 -pipe -fno-strict-aliasing
 >    COPTFLAGS= -O2 -pipe -fno-strict-aliasing
 > 
 > would be better in the general case?

In the general case, it would be better to remove those
two lines completely.  :-)

Best regards
   Oliver

-- 
Oliver Fromme,  secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

(On the statement print "42 monkeys" + "1 snake":)  By the way,
both perl and Python get this wrong.  Perl gives 43 and Python
gives "42 monkeys1 snake", when the answer is clearly "41 monkeys
and 1 fat snake".        -- Jim Fulton


More information about the freebsd-stable mailing list