On Tue May 31 11, Alexander Best wrote: > On Tue May 31 11, Garrett Cooper wrote: > > On May 31, 2011, at 3:46 AM, Alexander Best <arun...@freebsd.org> wrote: > > > > > On Tue May 31 11, Dimitry Andric wrote: > > >> On 2011-05-31 11:57, Alexander Best wrote: > > >> ... > > >>>>> however i've often read messages - mostly by bruce evans - claiming > > >>>>> that > > >>>>> anything greater than -O will in fact decrease a kernel's ability to > > >>>>> be > > >>>>> debugged just as well as a kernel with -O. > > >>>> The critical option when -O2 is used is -fno-omit-frame-pointers, > > >>>> since > > >>>> removing > > >>>> frame pointers makes debugging impossible (on i386). With -O2 code is > > >>>> moved around and > > >>>> removed, so debugging is more difficult, but can still provide useful > > >>>> information. > > >>> any reason we cannot use -O2 -fno-omit-frame-pointers > > >>> -fno-strict-aliasing > > >>> as > > >>> standard COPTFLAGS with debugging enabled for *all* archs? > > >> > > >> Most likely, the performance gain from -O2 is rather small, except for > > >> special cases, but the pain during debugging is increased a great deal. > > >> > > >> Even if you add frame pointers, with -O2 large pieces of code can be > > >> transformed, variables or even entire functions can be completely > > >> eliminated, and so on, making debugging much more difficult. > > > > > > *lol* we're moving in circles. so back to the beginning: why not use -O > > > for all archs, if debugging was enabled? for amd64 -O2 is always set, no > > > matter, if debugging is enabled or disabled. > > > > I don't know, but I've run into cases where gcc has inlined or shuffled > > around code on amd64 with -O2 -fno-strict-aliasing, so I changed my > > make.conf to use -O0 when DEBUG_FLAGS was defined. > > ...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? just like > -fno-strict-aliasing?
so how about the following patch? cheers. alex > > cheers. > alex > > > Thanks, > > -Garrett > -- > a13x -- a13x
diff --git a/sys/conf/Makefile.amd64 b/sys/conf/Makefile.amd64 index 5096829..f70f3de 100644 --- a/sys/conf/Makefile.amd64 +++ b/sys/conf/Makefile.amd64 @@ -31,13 +31,6 @@ S= ../../.. .endif .include "$S/conf/kern.pre.mk" -DDB_ENABLED!= grep DDB opt_ddb.h || true -DTR_ENABLED!= grep KDTRACE_FRAME opt_kdtrace.h || true -HWPMC_ENABLED!= grep HWPMC opt_hwpmc_hooks.h || true -.if !empty(DDB_ENABLED) || !empty(DTR_ENABLED) || !empty(HWPMC_ENABLED) -CFLAGS+= -fno-omit-frame-pointer -.endif - MKMODULESENV+= MACHINE=amd64 .if ${CC:T:Mclang} == "clang" diff --git a/sys/conf/Makefile.powerpc b/sys/conf/Makefile.powerpc index e4cd85f..04bc66b 100644 --- a/sys/conf/Makefile.powerpc +++ b/sys/conf/Makefile.powerpc @@ -37,11 +37,6 @@ INCLUDES+= -I$S/contrib/libfdt CFLAGS+= -msoft-float -DDB_ENABLED!= grep DDB opt_ddb.h || true -.if !empty(DDB_ENABLED) -CFLAGS+= -fno-omit-frame-pointer -.endif - %BEFORE_DEPEND %OBJS diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk index e9aa6e2..0314ada 100644 --- a/sys/conf/kern.pre.mk +++ b/sys/conf/kern.pre.mk @@ -24,26 +24,28 @@ 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 -frename-registers -pipe .else -_MINUS_O= -O2 +COPTFLAGS?= -O2 -pipe .endif -.if ${MACHINE_CPUARCH} == "amd64" -COPTFLAGS?=-O2 -frename-registers -pipe -.else -COPTFLAGS?=${_MINUS_O} -pipe + +.if !empty(COPTFLAGS:M-O[234sz]) && empty(COPTFLAGS:M-fno-strict-aliasing) +COPTFLAGS+= -fno-strict-aliasing .endif -.if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing) -COPTFLAGS+= -fno-strict-aliasing + +.if empty(COPTFLAGS:M-O0) && empty(COPTFLAGS:M-fno-omit-frame-pointer) +COPTFLAGS+= -fno-omit-frame-pointer .endif + .if !defined(NO_CPU_COPTFLAGS) -COPTFLAGS+= ${_CPUCFLAGS} +COPTFLAGS+= ${_CPUCFLAGS} .endif -C_DIALECT= -std=c99 -NOSTDINC= -nostdinc -INCLUDES= ${NOSTDINC} ${INCLMAGIC} -I. -I$S +C_DIALECT= -std=c99 +INCLUDES= -nostdinc ${INCLMAGIC} -I. -I$S # This hack lets us use the OpenBSD altq code without spamming a new # include path into contrib'ed source files. @@ -146,8 +148,7 @@ SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \ ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET} SYSTEM_DEP+= ${LDSCRIPT} -# MKMODULESENV is set here so that port makefiles can augment -# them. +# MKMODULESENV is set here so that port makefiles can augment them. MKMODULESENV+= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR} MKMODULESENV+= MACHINE_CPUARCH=${MACHINE_CPUARCH}
_______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"