Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Aug 2010 15:39:37 +0200
From:      "Domagoj S." <rank1seeker@gmail.com>
To:        freebsd-hackers@freebsd.org, Anonymous <swell.k@gmail.com>
Subject:   Re: intel i5 - core? or core2?
Message-ID:  <AANLkTikcPauECZRK9NNA6xDuDD=mw0Cnmccbvmif_qSH@mail.gmail.com>
In-Reply-To: <861v9sue4g.fsf@gmail.com>
References:  <1008211213030.2000@smasher> <8639u822tx.fsf@gmail.com> <AANLkTim_6DJq5d_DRzkV6Gf883oJt0UngDXhc8OkTWEc@mail.gmail.com> <861v9sue4g.fsf@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Aug 21, 2010 at 6:25 PM, Anonymous <swell.k@gmail.com> wrote:
> "Domagoj S." <rank1seeker@gmail.com> writes:
>
>> 8.1 RELEASE =A032bit
>>
>> # gcc --version
>> gcc (GCC) 4.2.1 20070719 =A0[FreeBSD]
>>
>> As per: =A0http://gcc.gnu.org/gcc-4.2/changes.html
>> core2 is supported
>
> It's not! `core' and `core2' for -mtune/-march introduced since gcc43.

Ups!
I've been confusing FreeBSD's 'CPUTYPE' with gcc's '-march=3D'


> BTW, while clang in base (on /head) supports -march=3Dcore2 it's still
> better to stick to -march=3Dnative, e.g. on my box
>
> =A0CPU: Intel(R) Core(TM)2 Duo CPU =A0 =A0 E8400 =A0@ 3.00GHz (3177.07-MH=
z K8-class CPU)
>
> `native' on clang implies `penryn', not a `core2'. While `native' on
> gcc45 implies `core2' + extra cflags[1].
>
> [1] -mcx16 -msahf -msse4.1 --param l1-cache-size=3D32 --param l1-cache-li=
ne-size=3D64 --param l2-cache-size=3D6144
>

I see..., so I should always go against FBSD devs and ensure that
gcc's arg '-march=3D' is always populated by value 'native'?
That is, gcc should alone determine CPU? Not a human user and then
setting "discovered" CPU type in CPUTYPE?


> You can populate MACHINE_CPU directly, e.g.
>
> =A0CPUTYPE ?=3D native
> =A0MACHINE_CPU !=3D echo ${MACHINE_ARCH}; ${CC} -E -dM -v -march=3D${CPUT=
YPE} - </dev/null 2>&1 \
> =A0 =A0 =A0 =A0| awk '/SSE|MMX/ && !/MATH/ { FS=3D"__"; gsub("_",".",$$2)=
; print tolower($$2) }'
> =A0MACHINE_CPU +=3D i486 i586 i686
>
> Note sure how well it'll work for cross-arch compilation, though.

Setting CPUTYPE will populate MACHINE_CPU.
Then I can ensure gcc's arg '-march=3Dnative' by setting:
CFLAGS=3D-O2 -pipe -march=3Dnative

But CPUTYPE will also append it's own '-march=3D', so to stop it:
NO_CPU_CFLAGS=3Dyes

I've also saw recommendation to add:
COPTFLAGS=3D-O2 -pipe -march=3Dnative
NO_CPU_COPTFLAGS=3Dyes

But I didn't see that CPUTYPE, has ever set COPTFLAGS?


So now I am totally confused with all this options?
What is the right way?


>> CPUTYPE?=3Dnative is nowhere mentioned "in FreeBSD"
>
> That cruft in bsd.cpu.mk was written in pre-gcc4 days, i.e. when it
> didn't support -march=3Dnative. Besides, if not maintained to accommodate
> for newer gcc's from ports those aliases are more harmful than
> useful. And not much code uses MACHINE_CPU in base anyway, only
> libcrypto and libz.
>

So if I decide to use a latest compiler from ports, I MUST avoid usage
of CPUTYPE?

Finally, should I use latest gcc compiler from ports, to build world &
kernel, with:
CFLAGS=3D-O2 -pipe -march=3Dnative
COPTFLAGS=3D-O2 -pipe -march=3Dnative
MACHINE_CPU=3D???


And a, regarding speed, please in percentage and taking regular binary
install from .iso, as a speed of value 100%, to be compared against.
What kind of gain, is compared to compilation from source:
a) Without any variables set in /etc/make.conf or passed on CMD
b) Only CPUTYPE var set, as officially recommended
c) Appending CFLAGS, NO_CPU_CFLAGS ... to b)
d) Using latest gcc from ports



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTikcPauECZRK9NNA6xDuDD=mw0Cnmccbvmif_qSH>