RFC: (Unconditionally) enable -fno-strict-overflow for kernel builds
Peter Wemm
peter at wemm.org
Sun Dec 1 04:54:11 UTC 2013
On Sat, Nov 30, 2013 at 8:38 PM, Eitan Adler <lists at eitanadler.com> wrote:
> On Sat, Nov 30, 2013 at 11:26 PM, Peter Wemm <peter at wemm.org> wrote:
>> On Sat, Nov 30, 2013 at 4:33 PM, Adrian Chadd <adrian at freebsd.org> wrote:
>> [..]
>>> Are you able to have clang/llvm/gcc tell us where/when code is relying
>>> on undefined behaviour? So we can, like, fix them?
>>
>> It wasn't all that long ago that we had this wonderful thing called
>> -Werror and had a clean kernel build.
>>
>> The problem is that gcc and clang have different warning sets. I seem
>> to recall we had -Werror on for gcc and off for clang. IMHO it would
>> be more useful to do it the other way around.
>
> Not all cases can be caught by static analysis. They would all be
> caught be the integer sanitizer. However, these have not yet been
> ported to FreeBSD.
>
I also missed the -Wno-error-tautological-compare setting. Oops.
I personally tweak my builds a little so that:
CC ../../../kern/kern_acct.c
CC ../../../kern/kern_clock.c
WARNING: kern_clock.c: enum pmc_event has too many values: 1669 > 1023
CC ../../../kern/kern_condvar.c
CC ../../../kern/kern_conf.c
CC ../../../kern/kern_cons.c
CC ../../../kern/kern_cpu.c
CC ../../../kern/kern_cpuset.c
../../../kern/kern_cpuset.c:637:16: warning: comparison of unsigned
expression < 0 is always false [-Wtautological-compare]
for (i = 0; i < (_NCPUWORDS - 1); i++) {
~ ^ ~~~~~~~~~~~~~~~~
1 warning generated.
CC ../../../kern/kern_context.c
CC ../../../kern/kern_descrip.c
CC ../../../kern/kern_dtrace.c
Warnings stand out nicely that way.
The diff is along these lines:
--- kern.pre.mk (revision 258784)
+++ kern.pre.mk (working copy)
@@ -126,12 +126,12 @@
# Optional linting. This can be overridden in /etc/make.conf.
LINTFLAGS= ${LINTOBJKERNFLAGS}
-NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
-NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
+NORMAL_C= @echo " CC ${.IMPSRC}" ; ${CC} -c ${CFLAGS} ${WERROR}
${PROF} ${.IMPSRC}
+NORMAL_S= @echo " AS ${.IMPSRC}" ; ${CC} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
-NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
+NORMAL_C_NOWERROR= @echo " CC_NOWERROR ${.IMPSRC}" ; ${CC} -c
${CFLAGS} ${PROF} ${.IMPSRC}
...
Unfortunately that interferes with my usual use of 'make -s' - silent.
--
Peter Wemm - peter at wemm.org; peter at FreeBSD.org; peter at yahoo-inc.com; KI6FJV
UTF-8: for when a ' just won\342\200\231t do.
More information about the freebsd-current
mailing list