Learning about Control of Optimization -- for dummies please

Scott Bennett bennett at cs.niu.edu
Wed Aug 5 12:39:23 UTC 2009


     On Wed, 5 Aug 2009 12:19:23 +0200 Roland Smith <rsmith at xs4all.nl> wrote:
>On Wed, Aug 05, 2009 at 10:54:07AM +0100, David Southwell wrote:
>> I have found http://docs.freebsd.org/info/gcc/gcc.info.Optimize_Options.html.
>> 
>> I am about to build a new kernel am starting to dig a bit deeper into things I 
>> have, until now, taken for granted.
>> 
>> The above link is very informative in technical terms about how to control 
>> optimization but I find it difficult to interpret the info in a way that tells 
>> me what might work best on my own system (Intel quad Core) with 8G of ram.
>
>The build system takes care of that, once you have set the correct
>CPUTYPE in /etc/make.conf. For a quad-core, set CPUTYPE=nocona. See
>make.conf(5), /usr/src/share/mk/bsd.cpu.mk and
>/usr/src/sys/conf/kern.pre.mk.

     As I read the man page for [g]cc, though, setting -march=nocona (which
is where the CPUTYPE information ends up in the cc commands) tells the
compiler which base instruction set to use and which model of instruction
scheduling to use, but to get the rest of the model-dependent features used,
he would still need to add "-mmmx -msse -msse2 -msse3" at a minimum for most
other compilations, though these would not be advisable for kernel
compilations.  I don't recall whether SSE4 instructions are in the Nocona/
Merom/Kentfield chips or first appear in the Core i7 series.  I don't think
the compiler versions available under FreeBSD support the SSE4 instructions,
though, so SSE4 doesn't matter anyway.
>
>Additionally, compiler settings for building the kernel can be set with
>COPTFLAGS in /etc/make.conf. Using anything other than -O or -O2 is
>not guaranteed to work. If you don't know what you are doing, do not use
>COPTFLAGS and stick with the defaults that the build system generates. 
>
     Right.  -O3 might royally screw a kernel in particular. :-)


                                  Scott Bennett, Comm. ASMELG, CFIAG
**********************************************************************
* Internet:       bennett at cs.niu.edu                              *
*--------------------------------------------------------------------*
* "A well regulated and disciplined militia, is at all times a good  *
* objection to the introduction of that bane of all free governments *
* -- a standing army."                                               *
*    -- Gov. John Hancock, New York Journal, 28 January 1790         *
**********************************************************************


More information about the freebsd-questions mailing list