Wed Aug 3 09:37:37 2022 UTC ()
sys: Build kernel with -Wno-type-limits.

The type-limits warning is actively harmful because it discourages
writing safe portable overflow detection logic which happens, on some
architectures, to be dead code.


(riastradh)
diff -r1.79 -r1.80 src/share/mk/bsd.kmodule.mk
diff -r1.293 -r1.294 src/sys/conf/Makefile.kern.inc

cvs diff -r1.79 -r1.80 src/share/mk/bsd.kmodule.mk (expand / switch to unified diff)

--- src/share/mk/bsd.kmodule.mk 2022/07/17 14:10:55 1.79
+++ src/share/mk/bsd.kmodule.mk 2022/08/03 09:37:36 1.80
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: bsd.kmodule.mk,v 1.79 2022/07/17 14:10:55 riastradh Exp $ 1# $NetBSD: bsd.kmodule.mk,v 1.80 2022/08/03 09:37:36 riastradh Exp $
2 2
3# We are not building this with PIE 3# We are not building this with PIE
4MKPIE=no 4MKPIE=no
5 5
6.include <bsd.init.mk> 6.include <bsd.init.mk>
7.include <bsd.klinks.mk> 7.include <bsd.klinks.mk>
8 8
9.if ${MKCTF:Uno} == "yes" 9.if ${MKCTF:Uno} == "yes"
10CFLAGS+= -g 10CFLAGS+= -g
11# Only need symbols for ctf, strip them after converting to CTF 11# Only need symbols for ctf, strip them after converting to CTF
12CTFFLAGS= -L VERSION 12CTFFLAGS= -L VERSION
13CTFMFLAGS= -t -L VERSION 13CTFMFLAGS= -t -L VERSION
14# Keep symbols if built with "-g" 14# Keep symbols if built with "-g"
@@ -26,26 +26,27 @@ realinstall: kmodinstall @@ -26,26 +26,27 @@ realinstall: kmodinstall
26KERN= $S/kern 26KERN= $S/kern
27MKLDSCRIPT?= no 27MKLDSCRIPT?= no
28 28
29CFLAGS+= -ffreestanding ${COPTS} 29CFLAGS+= -ffreestanding ${COPTS}
30CPPFLAGS+= -nostdinc -I. -I${.CURDIR} -isystem $S -isystem $S/arch 30CPPFLAGS+= -nostdinc -I. -I${.CURDIR} -isystem $S -isystem $S/arch
31CPPFLAGS+= -isystem ${S}/../common/include 31CPPFLAGS+= -isystem ${S}/../common/include
32CPPFLAGS+= -D_KERNEL -D_MODULE -DSYSCTL_INCLUDE_DESCR 32CPPFLAGS+= -D_KERNEL -D_MODULE -DSYSCTL_INCLUDE_DESCR
33 33
34CWARNFLAGS.clang+= -Wno-error=constant-conversion 34CWARNFLAGS.clang+= -Wno-error=constant-conversion
35 35
36# XXX until the kernel is fixed again... 36# XXX until the kernel is fixed again...
37CFLAGS+= -fno-strict-aliasing 37CFLAGS+= -fno-strict-aliasing
38CWARNFLAGS+= -Wno-pointer-sign -Wno-attributes 38CWARNFLAGS+= -Wno-pointer-sign -Wno-attributes
 39CWARNFLAGS+= -Wno-type-limits
39CWARNFLAGS.gcc+= ${GCC_NO_ADDR_OF_PACKED_MEMBER} 40CWARNFLAGS.gcc+= ${GCC_NO_ADDR_OF_PACKED_MEMBER}
40CWARNFLAGS.clang+= -Wno-error=address-of-packed-member 41CWARNFLAGS.clang+= -Wno-error=address-of-packed-member
41 42
42# XXX This is a workaround for platforms that have relative relocations 43# XXX This is a workaround for platforms that have relative relocations
43# that, when relocated by the module loader, result in addresses that 44# that, when relocated by the module loader, result in addresses that
44# overflow the size of the relocation (e.g. R_PPC_REL24 in powerpc). 45# overflow the size of the relocation (e.g. R_PPC_REL24 in powerpc).
45# The real solution to this involves generating trampolines for those 46# The real solution to this involves generating trampolines for those
46# relocations inside the loader and removing this workaround, as the 47# relocations inside the loader and removing this workaround, as the
47# resulting code would be much faster. 48# resulting code would be much faster.
48.if ${MACHINE_CPU} == "aarch64" 49.if ${MACHINE_CPU} == "aarch64"
49CFLAGS+= -march=armv8-a+nofp+nosimd 50CFLAGS+= -march=armv8-a+nofp+nosimd
50.elif ${MACHINE_CPU} == "arm" 51.elif ${MACHINE_CPU} == "arm"
51CFLAGS+= -fno-common -fno-unwind-tables 52CFLAGS+= -fno-common -fno-unwind-tables

cvs diff -r1.293 -r1.294 src/sys/conf/Makefile.kern.inc (expand / switch to unified diff)

--- src/sys/conf/Makefile.kern.inc 2022/01/06 17:05:32 1.293
+++ src/sys/conf/Makefile.kern.inc 2022/08/03 09:37:37 1.294
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile.kern.inc,v 1.293 2022/01/06 17:05:32 christos Exp $ 1# $NetBSD: Makefile.kern.inc,v 1.294 2022/08/03 09:37:37 riastradh Exp $
2# 2#
3# This file contains common `MI' targets and definitions and it is included 3# This file contains common `MI' targets and definitions and it is included
4# at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}. 4# at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}.
5# 5#
6# Each target in this file should be protected with `if !target(target)' 6# Each target in this file should be protected with `if !target(target)'
7# or `if !commands(target)' and each variable should only be conditionally 7# or `if !commands(target)' and each variable should only be conditionally
8# assigned `VAR ?= VALUE', so that everything can be overridden. 8# assigned `VAR ?= VALUE', so that everything can be overridden.
9# 9#
10# DEBUG is set to -g if debugging. 10# DEBUG is set to -g if debugging.
11# PROF is set to -pg if profiling. 11# PROF is set to -pg if profiling.
12# 12#
13# To specify debugging, add the config line: makeoptions DEBUG="-g" 13# To specify debugging, add the config line: makeoptions DEBUG="-g"
14# A better way is to specify -g only for a few files. 14# A better way is to specify -g only for a few files.
@@ -72,26 +72,27 @@ CPPFLAGS+= -std=gnu99 @@ -72,26 +72,27 @@ CPPFLAGS+= -std=gnu99
72CPPFLAGS+= -DKERNEL_DIR 72CPPFLAGS+= -DKERNEL_DIR
73.endif 73.endif
74DEFCOPTS?= -O2 74DEFCOPTS?= -O2
75COPTS?= ${DEFCOPTS} 75COPTS?= ${DEFCOPTS}
76DBG= # might contain unwanted -Ofoo 76DBG= # might contain unwanted -Ofoo
77CWARNFLAGS+= -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith 77CWARNFLAGS+= -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith
78CWARNFLAGS+= -Wmissing-prototypes -Wstrict-prototypes 78CWARNFLAGS+= -Wmissing-prototypes -Wstrict-prototypes
79CWARNFLAGS+= -Wold-style-definition 79CWARNFLAGS+= -Wold-style-definition
80CWARNFLAGS+= -Wswitch -Wshadow 80CWARNFLAGS+= -Wswitch -Wshadow
81CWARNFLAGS+= -Wcast-qual -Wwrite-strings 81CWARNFLAGS+= -Wcast-qual -Wwrite-strings
82CWARNFLAGS+= -Wno-unreachable-code 82CWARNFLAGS+= -Wno-unreachable-code
83#CWARNFLAGS+= -Wc++-compat -Wno-error=c++-compat 83#CWARNFLAGS+= -Wc++-compat -Wno-error=c++-compat
84CWARNFLAGS+= -Wno-pointer-sign -Wno-attributes 84CWARNFLAGS+= -Wno-pointer-sign -Wno-attributes
 85CWARNFLAGS+= -Wno-type-limits
85. if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64" || \ 86. if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64" || \
86 ${MACHINE_ARCH} == "sparc64" || ${MACHINE} == "prep" 87 ${MACHINE_ARCH} == "sparc64" || ${MACHINE} == "prep"
87CWARNFLAGS+= -Wextra -Wno-unused-parameter 88CWARNFLAGS+= -Wextra -Wno-unused-parameter
88. endif 89. endif
89. if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64" 90. if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64"
90CWARNFLAGS+= -Wold-style-definition 91CWARNFLAGS+= -Wold-style-definition
91. endif 92. endif
92# Add -Wno-sign-compare. -Wsign-compare is included in -Wall as of GCC 3.3, 93# Add -Wno-sign-compare. -Wsign-compare is included in -Wall as of GCC 3.3,
93# but our sources aren't up for it yet. 94# but our sources aren't up for it yet.
94CWARNFLAGS+= -Wno-sign-compare 95CWARNFLAGS+= -Wno-sign-compare
95 96
96CWARNFLAGS.clang+= -Wno-unknown-pragmas -Wno-conversion \ 97CWARNFLAGS.clang+= -Wno-unknown-pragmas -Wno-conversion \
97 -Wno-self-assign -Wno-error=address-of-packed-member \ 98 -Wno-self-assign -Wno-error=address-of-packed-member \