# make.conf configurations and cpu types



## badaei (Jan 10, 2011)

Hello,

I am looking to optimizing my source compilations. I note the setting CPUTYPE?=

with the following options for INTEL CPUs:


```
core2 core nocona pentium4m pentium4 prescott pentium3m pentium3 pentium-m pentium2
```

I am using an Intel Xeon X3440 processor. How do I determine what to use? I could not find a resource on the web linking the connection between processor type and these options. I get the vague sense from reading online that I may want to use "nocona" but I am not sure about it. As always, any guidance or hints are appreciated.

I am particularly interested in this as a follow up on building my kernel as well as future optimizations applied to compiled ports.


----------



## badaei (Jan 10, 2011)

Also, one quick follow up. I see some people add the '?' to "CPUTYPE" and others don't.

Is it CPUTYPE=foobar

or

Is it CPUTYPE?=foobar

maybe these questions seem silly but I could not a reference that elaborated on this.


----------



## User23 (Jan 10, 2011)

from

/usr/share/examples/etc/make.conf


```
# The CPUTYPE variable controls which processor should be targeted for
# generated code.  This controls processor-specific optimizations in
# certain code (currently only OpenSSL) as well as modifying the value
# of CFLAGS to contain the appropriate optimization directive to gcc.
# The automatic setting of CFLAGS may be overridden using the
# NO_CPU_CFLAGS variable below.
# Currently the following CPU types are recognized:
#   Intel x86 architecture:
#       (AMD CPUs)      opteron athlon64 athlon-mp athlon-xp athlon-4
#                       athlon-tbird athlon k8 k6-3 k6-2 k6 k5
#       (Intel CPUs)    core2 core nocona pentium4m pentium4 prescott
#                       pentium3m pentium3 pentium-m pentium2
#                       pentiumpro pentium-mmx pentium i486 i386
#       (Via CPUs)      c3 c3-2
#   Alpha/AXP architecture: ev67 ev6 pca56 ev56 ev5 ev45 ev4
#   AMD64 architecture: opteron, athlon64, nocona, prescott, core2
#   Intel ia64 architecture: itanium2, itanium
#
[B]# (?= allows to buildworld for a different CPUTYPE.)[/B]
#
#CPUTYPE?=pentium3
#NO_CPU_CFLAGS=         # Don't add -march=<cpu> to CFLAGS automatically
#NO_CPU_COPTFLAGS=      # Don't add -march=<cpu> to COPTFLAGS automatically
```


----------



## badaei (Jan 10, 2011)

I see, so from my understanding, I can have BOTH cputype=foobar and cputype?=foobar in the same make.conf file and the one without the '?' is used for all compiles except the kernel and the one with '?' used just for the kernel. 

Now if only I could figure out how to determine the right cputype for my cpu processor (Intel X3440). A Google search brings up this post to this forum!

Thanks for any suggestions


----------



## wblock@ (Jan 10, 2011)

badaei said:
			
		

> I see, so from my understanding, I can have BOTH cputype=foobar and cputype?=foobar in the same make.conf file and the one without the '?' is used for all compiles except the kernel and the one with '?' used just for the kernel.



Err, no.

`% man make | less '+/\?='`



> Now if only I could figure out how to determine the right cputype for my cpu processor (Intel X3440).




```
CPUTYPE?=native
```

There's a script to detect specific cputype: http://www.pixelbeat.org/scripts/gcccpuopt
It says my core2 system should use CPUTYPE?=pentium-m.  I guess I could benchmark it and see if that's faster than core2, which translates to prescott with the current system gcc.


----------



## badaei (Jan 10, 2011)

The output of gcccpuopt was:


```
Warning: Your compiler supports the -march=native option which you may prefer
Warning: The optimum *32 bit* architecture is reported
Warning: Newer versions of GCC better support your CPU with -march=core2
-m32 -march=pentium-m -mfpmath=sse
```

This is a 64-bit machine so that won't work. I did a Google search looking to understand more about the cputype?=native setting. I came across this link, telling people *not* to use native.

http://lists.freebsd.org/pipermail/freebsd-bugs/2007-May/024348.html

Not sure if this is relevant but my kernel configuration file has this setting in it


```
cpu HAMMER
```

for reference, I have an Intel Xeon x3440 cpu.

Thanks for sharing knowledge thus far.


----------



## badaei (Jan 10, 2011)

I wonder if just using


```
COPTFLAGS= -O -pipe
```

is the best option. What "cputype" is set if you set nothing anyway? What is the default action?


----------



## wblock@ (Jan 10, 2011)

That's odd.  What happened to dandelion's post?

CPUTYPE unspecified appears to be "generic".

As far as that email message goes, read the comments on the patch for PR conf/112997.


----------



## badaei (Jan 10, 2011)

Executing


```
gcc -v -x c -E -mtune=native /dev/null -o /dev/null 2>&1 | grep mtune | sed -e 's/.*mtune=//'
```

Returns "generic" on my x3440 machine. Out of curiosity I ran this on my MacBook Air and it return "native -m64".

It seems safe to say that I should leave cputype alone and commented it out of my make.conf for the Intel x3440, unless someone out there knows better. Thanks everyone for your input.


----------



## SirDice (Jan 11, 2011)

badaei said:
			
		

> I wonder if just using
> 
> 
> ```
> ...



The best option is to leave those flags alone.


----------



## User23 (Jan 11, 2011)

badaei said:
			
		

> Executing
> 
> 
> ```
> ...



For myself i used


```
CPUTYPE?=core2
```

with two Intel(R) Xeon(R) CPU E5620, and dont recognized any problems so far.

So my opinion is, it is safe to use. But leave compiler flags untouched, like SirDice said.


----------



## danbi (Jan 12, 2011)

Does the current base gcc optimize anything sufficiently different to warrant playing with CPUTYPE? Especially on amd64 systems?


----------



## UNIXgod (Jan 12, 2011)

danbi said:
			
		

> Does the current base gcc optimize anything sufficiently different to warrant playing with CPUTYPE? Especially on amd64 systems?



mine is set to core2

it still compiles with nocona. There is a switch somewhere as we are still on an older version of gcc. This will change in the future just use core2 as it's what it should be set to anyways.


----------

