From owner-freebsd-questions@FreeBSD.ORG Sat Aug 19 02:40:26 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E165916A4E2 for ; Sat, 19 Aug 2006 02:40:25 +0000 (UTC) (envelope-from nikolas.britton@gmail.com) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.230]) by mx1.FreeBSD.org (Postfix) with ESMTP id F3FC643D88 for ; Sat, 19 Aug 2006 02:40:19 +0000 (GMT) (envelope-from nikolas.britton@gmail.com) Received: by wx-out-0506.google.com with SMTP id i27so867707wxd for ; Fri, 18 Aug 2006 19:40:19 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=mdL6VXNcRSmT8IBAOGcr809jlaJCDCyRIhkFolOtfHu5HwO3EKiScNl5aDDaxcAtsO+ZqlJjsSld3Uge4lHL1wtU0KL4furUbWWXAtdO1IPBT4ioDgmiFDoMl4Cc96loRY+sU3bjBOnh9mvrF2eGLhgx1rOCQameb6iU0ZoojSg= Received: by 10.70.13.1 with SMTP id 1mr5859217wxm; Fri, 18 Aug 2006 19:40:19 -0700 (PDT) Received: by 10.70.49.3 with HTTP; Fri, 18 Aug 2006 19:40:19 -0700 (PDT) Message-ID: Date: Fri, 18 Aug 2006 21:40:19 -0500 From: "Nikolas Britton" To: "Sean M." In-Reply-To: <20060818214624.13326.qmail@web52310.mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200608181800.k7II0tIg072158@lurza.secnetix.de> <20060818214624.13326.qmail@web52310.mail.yahoo.com> Cc: freebsd-questions@freebsd.org Subject: Re: GCC - Optimal Optimization X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Aug 2006 02:40:26 -0000 On 8/18/06, Sean M. wrote: > --- Oliver Fromme wrote: > > The default is "-O2 -fno-strict-aliasing -pipe". > > info gcc --index "optimize options" says the default is '-O0'. > That's true for stock GCC but FreeBSD (6.x) CFLAGS, COPTFLAGS, and CXXFLAGS defaults to "-O2 -fno-strict-aliasing -pipe". Try compiling a port without setting CFLAGS in /etc/make.conf and you will see what we mean. > > You said you don't want an increase in size. But that's > > exactly what -O3 (via inlining) and -funroll-loops do. > > If you want not to increase size, use the default flags. > > You could even use -Os, which instructs the compiler to > > optimize for small size (it's somewhere between -O and > > -O2). > > "-O3" was a typo, I meant "-O2". And I'm not against an absolute > increase in size, just a significant one (>10% is about where I'd start > to care) > -O2 is the default in FreeBSD 6.x maybe even in 5.5 too. Here's my make.conf, I run FreeBSD 6.1/i386 on an Athlon64 3200+: CPUTYPE?=athlon-xp CFLAGS+= -mtune=athlon64 COPTFLAGS+= -mtune=athlon64 .if ${.CURDIR:M*/devel/sdl1*} CFLAGS+= -O3 .endif Note that I don't have "-O2 -march=athlon-xp -mfpmath=sse -funroll-loops -pipe -ffast-math" etc. etc. in my conf file. The reason I don't have it in there is it breaks things! A better way to do this is on a port by port basis, that's what the .if block is for. Also note that I don't set CXXFLAGS. Why? because CXXFLAGS is set to whatever CFLAGS is set to. Also note the use of += and ?=, and the creative use of -mtune= to optimize the parts of the kernel, world, and ports that ignore CPUTYPE... BTW never put -march= in CFLAGS because it WILL break your system... Use CPUTYPE?= to set -march. > --- Nikolas Britton wrote: > > IIRC the Duron should be set to athlon or athlon-tbird. The athlon-4, > > athlon-xp, athlon-mp knobs should only be used on Athlons with a > > Palomino core or better, your Duron is to slow to be based off > > Palomino. Also -mfp-math=sse does nothing for you because your chip > > doesn't have full SSE support. > > No, athlon-xp is valid: > "The second-generation Duron, the "Morgan" core, was sold in speed > grades between 900 and 1300 MHz, and was based on the 180 nm "Palomino" > Athlon XP core." [wikipedia.org] > My bad. > And -mfp-math=sse actually does nothing because there's not supposed to > be a hyphen between "fp" and "math". > You will break your system if you use that unconditionally. Use the .if .endif block I showed you if you really feel like using it... and... you better benchmark before and after because you may actually be slowing down the app. -- BSD Podcasts @: http://bsdtalk.blogspot.com/ http://freebsdforall.blogspot.com/