From owner-freebsd-hackers@FreeBSD.ORG Mon Aug 23 13:39:38 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D36FB10656A4 for ; Mon, 23 Aug 2010 13:39:38 +0000 (UTC) (envelope-from rank1seeker@gmail.com) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id 688918FC15 for ; Mon, 23 Aug 2010 13:39:38 +0000 (UTC) Received: by wwf26 with SMTP id 26so995229wwf.31 for ; Mon, 23 Aug 2010 06:39:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=H2skkCUqFR9qvd0W5EyNl8K/g/2Mvkra0iVngpKvwCY=; b=eGIszGZIJFB22dE+4KxGM/sswUN++TsOPNmcp4zBGjXjsHIYehPVdfiVvAw5WEBpD/ SDCTb6Tar+lURQ/PL2/DazX41Iszq4fRizrBHOc6xZEdg3T/+B6QHIwJZ0QkhcfD3xRN 27dWWuzth0lyH9mRnKwjTDxdpePpLBQ7F+yPw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=v1Qoi3lnj7CJd6QA4M/qOOKrwsA0jfyiAUNGVXHePNqtrKb1NSktT9TJjOP4SuhAL2 s7r89BBmh4ecXBzd2KDo+quY+35N1U2JEHi7CYe8w4SZrZEJD+607eynRH5dDoGymfos b0mLFMfZ3JKw8sdNDjt7GA/uE9DmsvHk0HMZE= MIME-Version: 1.0 Received: by 10.216.1.18 with SMTP id 18mr1624719wec.24.1282570777372; Mon, 23 Aug 2010 06:39:37 -0700 (PDT) Received: by 10.216.58.144 with HTTP; Mon, 23 Aug 2010 06:39:37 -0700 (PDT) In-Reply-To: <861v9sue4g.fsf@gmail.com> References: <1008211213030.2000@smasher> <8639u822tx.fsf@gmail.com> <861v9sue4g.fsf@gmail.com> Date: Mon, 23 Aug 2010 15:39:37 +0200 Message-ID: From: "Domagoj S." To: freebsd-hackers@freebsd.org, Anonymous Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Subject: Re: intel i5 - core? or core2? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2010 13:39:39 -0000 On Sat, Aug 21, 2010 at 6:25 PM, Anonymous wrote: > "Domagoj S." 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} - &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