[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-hackers
Subject:    Re: [rfc] a few kern.mk and bsd.sys.mk related changes
From:       Alexander Best <arundel () freebsd ! org>
Date:       2011-05-31 20:00:06
Message-ID: 20110531200006.GA74380 () freebsd ! org
[Download RAW message or body]

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

["kern.pre.mk.diff" (text/plain)]

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}


_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic