introduce new GCC 12 warning disables and use them in a few places

this introduces 4 new warning disable flags:

   CC_WNO_MISSING_TEMPLATE_KEYWORD
   CC_WNO_REGISTER
   CC_WNO_STRINGOP_OVERREAD
   CC_WNO_ARRAY_BOUNDS

and documents them in README.warnings.  of these, the string op
and array bounds are both problematic (real bugs) and also spurious
(not real bugs), and the other 2 are mostly temporary for older
3rd party code.

add some new uses of CC_WNO_STRINGOP_OVERFLOW.

fix m68k build for gallium and GCC 12.
This commit is contained in:
mrg 2023-08-08 06:27:31 +00:00
parent 53d5bb9a8a
commit 832d47522a
16 changed files with 125 additions and 18 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.inc,v 1.4 2021/05/30 01:56:58 joerg Exp $
# $NetBSD: Makefile.inc,v 1.5 2023/08/08 06:27:31 mrg Exp $
LLVM_TOPLEVEL:= ${.PARSEDIR}/..
NOSTATICLIB= yes
@ -10,3 +10,5 @@ CWARNFLAGS.gcc+= ${${HAVE_GCC:U0} >= 9:? -Wno-error=init-list-lifetime :}
LLVM_INCLUDE_OBJDIR!= cd ${LLVM_TOPLEVEL}/include && ${PRINTOBJDIR}
LLVM_MODULE_CACHE= ${LLVM_INCLUDE_OBJDIR}/module.cache-rt
CXXFLAGS+= ${CC_WNO_MISSING_TEMPLATE_KEYWORD}

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.16 2023/06/03 21:31:45 lukem Exp $
# $NetBSD: Makefile,v 1.17 2023/08/08 06:27:31 mrg Exp $
#
USE_FORT?= yes # data driven bugs?
@ -35,7 +35,8 @@ MLINKS+= libmagic.3 magic_open.3 \
INCS= magic.h
INCSDIR= /usr/include
COPTS.softmagic.c = -Wno-format-nonliteral
COPTS.softmagic.c+= -Wno-format-nonliteral
COPTS.readelf.c+= ${CC_WNO_MAYBE_UNINITIALIZED}
magic.c: magic.h
magic.h: magic.h.in

View File

@ -1,4 +1,4 @@
$NetBSD: README.warnings,v 1.3 2023/06/03 09:09:07 lukem Exp $
$NetBSD: README.warnings,v 1.4 2023/08/08 06:27:33 mrg Exp $
What to do about GCC warnings and NetBSD.
@ -22,6 +22,45 @@ modified for updates to warnings and new warnings.
COPTS.foo.c += ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}
COPTS.foo.c += ${CC_WNO_MAYBE_UNINITIALIZED}
COPTS.foo.c += ${CC_WNO_RETURN_LOCAL_ADDR}
COPTS.foo.c += ${CC_WNO_MISSING_TEMPLATE_KEYWORD}
COPTS.foo.c += ${CC_WNO_STRINGOP_OVERREAD}
COPTS.foo.c += ${CC_WNO_REGISTER}
COPTS.foo.c += ${CC_WNO_ARRAY_BOUNDS}
new GCC 12 warnings:
-Wno-missing-template-keyword
This warning trips on older C++ code, and should only be applyed to 3rd
party code.
bsd.own.mk variable: ${CC_WNO_MISSING_TEMPLATE_KEYWORD}
-Wno-stringop-overread
This warning triggers when array bounds appear to be exceeded. There
maybe some bugs related to this warning in GCC 12.
bsd.own.mk variable: ${CC_WNO_STRINGOP_OVERREAD}
-Wno-register
This warning triggers in C++17 mode where 'register' has been removed,
and should only be applied to 3rd party code.
bsd.own.mk variable: ${CC_WNO_REGISTER}
-Wno-array-bounds
This warning triggers with a number of code issues that tend to be real
problem but require careful adjustments to fix properly, when there are
platform related accesses beyond the immediately size and address of
known variables (real bugs to fix), but also may trigger when passing
C arrays vs C pointers to functions, often incorrectly. See
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110878
bsd.own.mk variable: ${CC_WNO_ARRAY_BOUNDS}
new GCC 10 warnings:

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.7 2023/07/15 21:24:46 rjs Exp $
# $NetBSD: Makefile,v 1.8 2023/08/08 06:27:31 mrg Exp $
# Link the mesa_dri_drivers mega driver.
@ -511,6 +511,9 @@ COPTS.brw_fs_copy_propagation.cpp+= -Wno-error=stack-protector
COPTS.brw_fs.cpp+= -Wno-error=stack-protector
COPTS.brw_fs_reg_allocate.cpp+= -Wno-error=stack-protector
COPTS.prog_opt_constant_fold.c+= ${CC_WNO_STRINGOP_OVERREAD}
COPTS.s_texfilter.c+= ${CC_WNO_STRINGOP_OVERREAD}
.include <bsd.lib.mk>
.else
.include <bsd.inc.mk>

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.6 2023/07/15 21:24:46 rjs Exp $
# $NetBSD: Makefile,v 1.7 2023/08/08 06:27:31 mrg Exp $
# Transparent struct/union broken
NOLINT=yes
@ -1215,8 +1215,17 @@ COPTS+= ${${ACTIVE_CC} == "clang":? -Wa,-Av8plus :}
COPTS.nir.c += -O1
.endif
# XXXGCC12
.if ${MACHINE_ARCH} == "m68k"
COPTS.st_glsl_to_tgsi.cpp += -O1
COPTS.vl_bicubic_filter.c += -O1
COPTS.nir_opt_algebraic.c += -Os -fno-jump-tables
.endif
COPTS.u_atomic.c+= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 10:? -Wno-builtin-declaration-mismatch :}
COPTS.prog_opt_constant_fold.c+= ${CC_WNO_STRINGOP_OVERREAD}
.include <bsd.lib.mk>
# Don't regenerate c files
.y.c:

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.22 2021/08/24 03:10:11 mrg Exp $
# $NetBSD: Makefile,v 1.23 2023/08/08 06:27:31 mrg Exp $
.include <bsd.own.mk>
@ -155,5 +155,8 @@ COPTS.arcsorter.cc+= -Wno-error
COPTS.sorter.cc+= -Wno-error
COPTS.tobezier.cc+= -Wno-error
COPTS.varray.cc+= ${CC_WNO_REGISTER}
COPTS.project.c+= ${CC_WNO_STRINGOP_OVERFLOW}
CWARNFLAGS.clang+= -Wno-parentheses -Wno-tautological-compare
CWARNFLAGS.clang+= -Wno-deprecated-register

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.15 2023/06/03 09:09:08 lukem Exp $
# $NetBSD: Makefile,v 1.16 2023/08/08 06:27:32 mrg Exp $
LIB= sqlite3
INCS= sqlite3.h sqlite3ext.h
@ -20,7 +20,11 @@ FILESDIR_sqlite3.pc= /usr/lib/pkgconfig
CLEANFILES+=sqlite3.pc
CWARNFLAGS.clang+= -Wno-error=implicit-int-float-conversion
COPTS.sqlite3.c+= ${CC_WNO_RETURN_LOCAL_ADDR}
COPTS.sqlite3.c+= ${CC_WNO_RETURN_LOCAL_ADDR} ${CC_WNO_STRINGOP_OVERFLOW}
COPTS.sqlite3.c+= ${CC_WNO_ARRAY_BOUNDS}
COPTS.sqlite3.c+= -Wno-error=misleading-indentation
COPTS.sqlite3.c+= -Wno-error=restrict
.include <bsd.own.mk>

View File

@ -1,4 +1,4 @@
# $NetBSD: bsd.own.mk,v 1.1351 2023/08/08 03:44:12 mrg Exp $
# $NetBSD: bsd.own.mk,v 1.1352 2023/08/08 06:27:32 mrg Exp $
# This needs to be before bsd.init.mk
.if defined(BSD_MK_COMPAT_FILE)
@ -700,6 +700,10 @@ CC_WNO_MAYBE_UNINITIALIZED= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 10:? -W
CC_WNO_RETURN_LOCAL_ADDR= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 10:? -Wno-return-local-addr :}
CC_WNO_STRINGOP_OVERFLOW= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 7:? -Wno-stringop-overflow :}
CC_WNO_STRINGOP_TRUNCATION= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 8:? -Wno-stringop-truncation :}
CC_WNO_MISSING_TEMPLATE_KEYWORD=${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 12:? -Wno-missing-template-keyword :}
CC_WNO_STRINGOP_OVERREAD= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 12:? -Wno-stringop-overread :}
CC_WNO_REGISTER= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 12:? -Wno-register :}
CC_WNO_ARRAY_BOUNDS= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 12:? -Wno-array-bounds :}
# For each ${MACHINE_CPU}, list the ports that use it.
MACHINES.aarch64= evbarm

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.hppa,v 1.8 2020/09/14 16:13:18 skrll Exp $
# $NetBSD: Makefile.hppa,v 1.9 2023/08/08 06:27:32 mrg Exp $
# Makefile for NetBSD
#
@ -87,6 +87,9 @@ com_gsc.o clock.o pdc.o autoconf.o machdep.o: Makefile
## (7) misc settings
##
# GCC 12 gets this wrong
COPTS.pdc.c+= ${CC_WNO_ARRAY_BOUNDS}
##
## (8) config(8) generated machinery
##

View File

@ -1,4 +1,4 @@
# $NetBSD: copts.mk,v 1.10 2023/06/03 21:30:21 lukem Exp $
# $NetBSD: copts.mk,v 1.11 2023/08/08 06:27:32 mrg Exp $
# MI per-file compiler options required.
@ -29,4 +29,21 @@ COPTS.in6_pcb.c+= ${CC_WNO_RETURN_LOCAL_ADDR}
COPTS.magma.c+= ${CC_WNO_MAYBE_UNINITIALIZED}
.endif
# Some of these indicate a potential GCC bug:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110878
.if defined(HAVE_GCC) && ${HAVE_GCC} >= 12 && ${ACTIVE_CC} == "gcc" && \
(${MACHINE_ARCH} == "aarch64" || ${MACHINE_ARCH} == "aarch64eb")
COPTS.aes_armv8.c+= ${CC_WNO_STRINGOP_OVERREAD} ${CC_WNO_STRINGOP_OVERFLOW}
COPTS.aes_neon.c+= ${CC_WNO_STRINGOP_OVERREAD} ${CC_WNO_STRINGOP_OVERFLOW} -flax-vector-conversions
COPTS.aes_neon_subr.c+= ${CC_WNO_ARRAY_BOUNDS} -flax-vector-conversions
COPTS.chacha_neon.c+= -flax-vector-conversions
.endif
.if ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "i386"
COPTS.aes_ni.c+= ${CC_WNO_STRINGOP_OVERREAD} ${CC_WNO_STRINGOP_OVERFLOW}
COPTS.aes_sse2_subr.c+= ${CC_WNO_ARRAY_BOUNDS}
COPTS.aes_ssse3_subr.c+=${CC_WNO_ARRAY_BOUNDS}
COPTS.aes_via.c+= ${CC_WNO_ARRAY_BOUNDS}
.endif
.endif

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.14 2023/06/03 09:09:15 lukem Exp $
# $NetBSD: Makefile,v 1.15 2023/08/08 06:27:32 mrg Exp $
.include <bsd.own.mk>
@ -30,4 +30,7 @@ TESTS_C+= t_swab
WARNS= 4
# Explicitly tries to test this case
COPTS.t_strlen.c+= ${CC_WNO_STRINGOP_OVERREAD}
.include <bsd.test.mk>

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.73 2023/06/03 08:52:59 lukem Exp $
# $NetBSD: Makefile,v 1.74 2023/08/08 06:27:32 mrg Exp $
MKMAN= no
@ -156,4 +156,7 @@ WARNS= 4
CWARNFLAGS.gcc+= ${CC_WNO_ADDRESS_OF_PACKED_MEMBER} \
${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 8:? -Wno-error=deprecated :}
# Explicitly breaks this
COPTS.t_wait.c+= ${CC_WNO_ARRAY_BOUNDS} ${CC_WNO_STRINGOP_OVERFLOW}
.include <bsd.test.mk>

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.6 2020/09/08 17:35:27 jakllsch Exp $
# $NetBSD: Makefile,v 1.7 2023/08/08 06:27:32 mrg Exp $
.include <bsd.own.mk>
@ -80,4 +80,15 @@ SRCS.t_aes+= aes_via.c
WARNS= 5
# Many of these are probably GCC bugs, see
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110878
COPTS.aes_armv8.c+= ${CC_WNO_STRINGOP_OVERREAD} ${CC_WNO_STRINGOP_OVERFLOW}
COPTS.aes_bear.c+= ${CC_WNO_STRINGOP_OVERFLOW} ${CC_WNO_ARRAY_BOUNDS}
COPTS.aes_neon_subr.c+= ${CC_WNO_ARRAY_BOUNDS}
COPTS.aes_ni.c+= ${CC_WNO_STRINGOP_OVERREAD} ${CC_WNO_STRINGOP_OVERFLOW}
COPTS.aes_sse2_subr.c+= ${CC_WNO_ARRAY_BOUNDS}
COPTS.aes_ssse3_subr.c+=${CC_WNO_ARRAY_BOUNDS}
COPTS.aes_via.c+= ${CC_WNO_ARRAY_BOUNDS}
.include <bsd.test.mk>

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.4 2010/12/06 21:16:54 mrg Exp $
# $NetBSD: Makefile,v 1.5 2023/08/08 06:27:32 mrg Exp $
PROG= pkill
@ -10,4 +10,6 @@ LINKS+= ${BINDIR}/pkill ${BINDIR}/prenice
MLINKS+=pkill.1 pgrep.1
MLINKS+=pkill.1 prenice.1
COPTS.pkill.c+= ${CC_WNO_STRINGOP_OVERFLOW}
.include <bsd.prog.mk>

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.19 2023/06/03 09:09:22 lukem Exp $
# $NetBSD: Makefile,v 1.20 2023/08/08 06:27:33 mrg Exp $
# from: Id: Makefile,v 1.5 1993/06/24 05:11:16 deering Exp
.include <bsd.own.mk>
@ -19,5 +19,6 @@ CWARNFLAGS.gcc+= ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}
COPTS.cfparse.c+= ${CC_WNO_STRINGOP_TRUNCATION}
COPTS.vif.c+= ${CC_WNO_STRINGOP_TRUNCATION}
COPTS.route.c+= ${CC_WNO_ARRAY_BOUNDS}
.include <bsd.prog.mk>

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.22 2021/02/03 06:49:18 roy Exp $
# $NetBSD: Makefile,v 1.23 2023/08/08 06:27:33 mrg Exp $
USE_FORT?= yes # network client
@ -30,4 +30,6 @@ SANITIZER_RENAME_SYMBOL.rump+= getifaddrs
AWKS= median.awk mean.awk
COPTS.traceroute.c+= ${CC_WNO_ARRAY_BOUNDS}
.include <bsd.prog.mk>