From owner-freebsd-current@FreeBSD.ORG Fri Dec 23 14:54:59 2011 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4B28E106566C; Fri, 23 Dec 2011 14:54:59 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 1ED3C8FC0A; Fri, 23 Dec 2011 14:54:59 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) by cyrus.watson.org (Postfix) with ESMTPSA id A1E4746B3C; Fri, 23 Dec 2011 09:54:58 -0500 (EST) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 2B8BFB962; Fri, 23 Dec 2011 09:54:58 -0500 (EST) From: John Baldwin To: freebsd-current@freebsd.org Date: Fri, 23 Dec 2011 09:37:08 -0500 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p8; KDE/4.5.5; amd64; ; ) References: <4EF34E52.2040905@FreeBSD.org> <20111223005932.GA65042@freebsd.org> <25FBBF23-CDFA-429E-966D-A90409D8F2BD@gmail.com> In-Reply-To: <25FBBF23-CDFA-429E-966D-A90409D8F2BD@gmail.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201112230937.08971.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 23 Dec 2011 09:54:58 -0500 (EST) Cc: Garrett Cooper , Alexander Best , Dimitry Andric , Benjamin Kaduk Subject: Re: [patch] Cleaning up amd64 kernel optimization options X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Dec 2011 14:54:59 -0000 On Thursday, December 22, 2011 9:51:47 pm Garrett Cooper wrote: > On Dec 22, 2011, at 4:59 PM, Alexander Best wrote: > > > On Thu Dec 22 11, Benjamin Kaduk wrote: > >> On Thu, 22 Dec 2011, Alexander Best wrote: > >> > >>> On Thu Dec 22 11, Dimitry Andric wrote: > >>>> Hi, > >>>> > >>>> I would like to ask some feedback on the attached patch, which cleans up > >>>> the kernel optimization options for amd64. This was touched upon > >>>> earlier by Alexander Best in freebsd-toolchain, here: > >>> > >>> i've been using such settings for a few months now and haven't noticed any > >>> problems. > >>> > >>> however bruce evans raised a good point (in a private mail). when you > >>> compile a > >>> kernel without debugging enabled, -O2 is the default. if you experience > >>> issues, > >>> and enable debugging, -O0 now becomes the default. in case the problems > >>> with > >>> the kernel were caused by the -O2 option and aren't present with the -O0 > >>> option, the newly built kernel with debugging enabled will not help you > >>> fix the > >>> problems. in that case you would need to set -O2 explicitly in CFLAGS. his > >>> exact words were: > >>> > >>> " > >>> I don't like -O2 for anything. However, if it is only a default, it is > >>> not a problem provided it can be canceled easily. And for debugging, you > >>> want the default to be the same as without debugging, so that (by default) > >>> you debug the same code that caused the problem. > >>> " > >>> > >>> however i don't think this is fixable. using -O0 for debuggable and > >>> non-debuggable kernels will cause too much of a slowdown. > >>> > >>> having -O2 as the default flag for non-debuggable kernels and -O2 -g for > >>> debuggable kernels might cause situations, where debugging isn't possible, > >>> where with -O0 -g it would have been. > >>> > >>> so i guess although bruces concerns are valid, they are impossible to > >>> solve. > >> > >> Where does -O0 come in? I only see talk of -O (i.e. -O1) versus -O2. > > > > sorry. of course i meant -O: > > > > .if defined(DEBUG) > > _MINUS_O= -O > > CTFFLAGS+= -g > > .else > > [..] > > Back in the 7.x days, I ran into some code that wasn't easily to debug because the compiler optimized things out with -O2 by inlining and otherwise shifting around code, so setting breakpoints in gdb became difficult. So from that point on I've gotten into the habit of doing -O explicitly in make.conf if DEBUG_FLAGS was specified. Just a thought.. I still leave -O2 in, but what I do is this: make DEBUG_FLAGS="-g -fno-inline" Just adding -fno-inline makes a world of difference. -- John Baldwin