Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 31 May 2011 20:00:06 +0000
From:      Alexander Best <arundel@freebsd.org>
To:        Dimitry Andric <dim@FreeBSD.org>
Cc:        Garrett Cooper <yanegomi@gmail.com>, Bruce Cran <bruce@cran.org.uk>, "freebsd-toolchain@FreeBSD.ORG" <freebsd-toolchain@FreeBSD.ORG>, Pan Tsu <inyaoo@gmail.com>, "freebsd-hackers@FreeBSD.ORG" <freebsd-hackers@FreeBSD.ORG>
Subject:   Re: [rfc] a few kern.mk and bsd.sys.mk related changes
Message-ID:  <20110531200006.GA74380@freebsd.org>
In-Reply-To: <4DE53450.10109@FreeBSD.org>
References:  <20110527182906.GA31871@freebsd.org> <86oc2mlsey.fsf@gmail.com> <20110528182326.GA75447@freebsd.org> <20110528202619.GA27204@muon.cran.org.uk> <20110531095742.GA99888@freebsd.org> <4DE4C4CC.4020905@FreeBSD.org> <20110531104639.GA4218@freebsd.org> <24ADBA34-A5FC-4A67-8D6F-3BDAE158285C@gmail.com> <20110531143914.GA30260@freebsd.org> <4DE53450.10109@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--CE+1k2dSO48ffgeK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Tue May 31 11, Dimitry Andric wrote:
> On 2011-05-31 16:39, Alexander Best wrote:
> ...
> >...which leads me to the conclusion that -O should be set when DEBUG was
> >defined: an all ARCHS.
> >
> >right now -fno-omit-frame-pointer is only set on amd64 and powerpc, if the
> >kernel contains DDB, KDTRACE_FRAME or HWPMC. how about this behavior? 
> >shouldn't
> >-fno-omit-frame-pointer be set uncondtitionally on all archs?
> 
> No, not unconditionally on all archs.  Some arches have no problem
> debugging when gcc's frame pointer is turned off, namely arm, ia64,
> mips, powerpc and sparc, if I read the source correctly.
> 
> On these arches, even -O already sets -fomit-frame-pointer.
> 
> So, for all arches, if DEBUG is enabled, we could just use -O (as
> default only, if the user wants to override this for whatever reason, it
> should be honoured).
> 
> 
> >just like
> >-fno-strict-aliasing?
> 
> That should only be needed in combination with -O2, if that is the
> default optimization (e.g. if DEBUG is not enabled).  IMHO this option
> should not be forced, if users specify their own CFLAGS/COPTFLAGS.
> 
> Summarizing, I would suggest:
> 
> - If DEBUG is enabled, use plain -O by default, on all arches
> - If DEBUG is disabled, use -O2 -fno-strict-aliasing by default, on all
>   arches.

thanks for your suggestions. i've incorporated them into the patch.

one thing i'm unsure is: what should be done when the user *doesn't* define
DEBUG, but has DDB, KDTRACE_FRAME or HWPMC in his kernel config?

the current behavior is to set -fno-omit-frame-pointer on amd64 and powerpc.
i think this behavior shouldn't be change. even though the user didn't specify
DEBUG, the fact that he has those kernel options indicates that he wants to do
some kind of debugging imho.

cheers.
alex

ps: sorry for the extra whitespace changes!

-- 
a13x

--CE+1k2dSO48ffgeK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="kern.pre.mk.diff"

diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk
index e9aa6e2..e6beda8 100644
--- a/sys/conf/kern.pre.mk
+++ b/sys/conf/kern.pre.mk
@@ -24,18 +24,12 @@ OBJCOPY?=	objcopy
 SIZE?=		size
 
 .if defined(DEBUG)
-_MINUS_O=	-O
+COPTFLAGS?=	-O -pipe
 CTFFLAGS+=	-g
+.elif ${MACHINE_CPUARCH} == "amd64" && ${CC:T:Mclang} != "clang"
+COPTFLAGS?=	-O2 -fno-strict-aliasing -frename-registers -pipe
 .else
-_MINUS_O=	-O2
-.endif
-.if ${MACHINE_CPUARCH} == "amd64"
-COPTFLAGS?=-O2 -frename-registers -pipe
-.else
-COPTFLAGS?=${_MINUS_O} -pipe
-.endif
-.if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
-COPTFLAGS+= -fno-strict-aliasing
+COPTFLAGS?=	-O2 -fno-strict-aliasing -pipe
 .endif
 .if !defined(NO_CPU_COPTFLAGS)
 COPTFLAGS+= ${_CPUCFLAGS}

--CE+1k2dSO48ffgeK--



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