From 832d47522ae32d4fa46b33101d352a7e96407cbc Mon Sep 17 00:00:00 2001 From: mrg Date: Tue, 8 Aug 2023 06:27:31 +0000 Subject: [PATCH] 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. --- external/apache2/llvm/librt/Makefile.inc | 4 ++- external/bsd/file/lib/Makefile | 5 +-- external/gpl3/gcc/README.warnings | 41 +++++++++++++++++++++- external/mit/xorg/lib/dri.old/Makefile | 5 ++- external/mit/xorg/lib/gallium.old/Makefile | 11 +++++- external/mit/xorg/lib/libGLU/Makefile | 5 ++- external/public-domain/sqlite/lib/Makefile | 8 +++-- share/mk/bsd.own.mk | 6 +++- sys/arch/hppa/conf/Makefile.hppa | 5 ++- sys/conf/copts.mk | 19 +++++++++- tests/lib/libc/string/Makefile | 5 ++- tests/lib/libc/sys/Makefile | 5 ++- tests/sys/crypto/aes/Makefile | 13 ++++++- usr.bin/pkill/Makefile | 4 ++- usr.sbin/mrouted/Makefile | 3 +- usr.sbin/traceroute/Makefile | 4 ++- 16 files changed, 125 insertions(+), 18 deletions(-) diff --git a/external/apache2/llvm/librt/Makefile.inc b/external/apache2/llvm/librt/Makefile.inc index fc66467f3a86..cf9f25d32e05 100644 --- a/external/apache2/llvm/librt/Makefile.inc +++ b/external/apache2/llvm/librt/Makefile.inc @@ -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} diff --git a/external/bsd/file/lib/Makefile b/external/bsd/file/lib/Makefile index d903b157b317..5194bc530194 100644 --- a/external/bsd/file/lib/Makefile +++ b/external/bsd/file/lib/Makefile @@ -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 diff --git a/external/gpl3/gcc/README.warnings b/external/gpl3/gcc/README.warnings index 10c203da9360..ae7eac61435a 100644 --- a/external/gpl3/gcc/README.warnings +++ b/external/gpl3/gcc/README.warnings @@ -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,8 +22,47 @@ 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: GCC 10 switched the default from "-fcommon" to "-fno-common", diff --git a/external/mit/xorg/lib/dri.old/Makefile b/external/mit/xorg/lib/dri.old/Makefile index effcbfaf6570..7cb496a529c6 100644 --- a/external/mit/xorg/lib/dri.old/Makefile +++ b/external/mit/xorg/lib/dri.old/Makefile @@ -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 .else .include diff --git a/external/mit/xorg/lib/gallium.old/Makefile b/external/mit/xorg/lib/gallium.old/Makefile index 3fec2a60682f..55b2fe3d1c1a 100644 --- a/external/mit/xorg/lib/gallium.old/Makefile +++ b/external/mit/xorg/lib/gallium.old/Makefile @@ -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 # Don't regenerate c files .y.c: diff --git a/external/mit/xorg/lib/libGLU/Makefile b/external/mit/xorg/lib/libGLU/Makefile index e7a7571e1490..6ac47363df0c 100644 --- a/external/mit/xorg/lib/libGLU/Makefile +++ b/external/mit/xorg/lib/libGLU/Makefile @@ -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 @@ -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 diff --git a/external/public-domain/sqlite/lib/Makefile b/external/public-domain/sqlite/lib/Makefile index 4273bee7c5e1..145df7a070e2 100644 --- a/external/public-domain/sqlite/lib/Makefile +++ b/external/public-domain/sqlite/lib/Makefile @@ -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 diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index 911314e44b97..35bf2297f9e5 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -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 diff --git a/sys/arch/hppa/conf/Makefile.hppa b/sys/arch/hppa/conf/Makefile.hppa index ef758ce1455f..3c9c87f20d14 100644 --- a/sys/arch/hppa/conf/Makefile.hppa +++ b/sys/arch/hppa/conf/Makefile.hppa @@ -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 ## diff --git a/sys/conf/copts.mk b/sys/conf/copts.mk index 0a8fa4b22a63..a904520b7791 100644 --- a/sys/conf/copts.mk +++ b/sys/conf/copts.mk @@ -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 diff --git a/tests/lib/libc/string/Makefile b/tests/lib/libc/string/Makefile index 12ea5c1dfb0d..127850b198dd 100644 --- a/tests/lib/libc/string/Makefile +++ b/tests/lib/libc/string/Makefile @@ -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 @@ -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 diff --git a/tests/lib/libc/sys/Makefile b/tests/lib/libc/sys/Makefile index 181026a01b99..21e66aa74946 100644 --- a/tests/lib/libc/sys/Makefile +++ b/tests/lib/libc/sys/Makefile @@ -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 diff --git a/tests/sys/crypto/aes/Makefile b/tests/sys/crypto/aes/Makefile index 054933d887fc..fe569c19684d 100644 --- a/tests/sys/crypto/aes/Makefile +++ b/tests/sys/crypto/aes/Makefile @@ -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 @@ -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 diff --git a/usr.bin/pkill/Makefile b/usr.bin/pkill/Makefile index e91803324df6..82c5cecc3f5e 100644 --- a/usr.bin/pkill/Makefile +++ b/usr.bin/pkill/Makefile @@ -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 diff --git a/usr.sbin/mrouted/Makefile b/usr.sbin/mrouted/Makefile index 1a4192e29ae2..f399cc16270c 100644 --- a/usr.sbin/mrouted/Makefile +++ b/usr.sbin/mrouted/Makefile @@ -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 @@ -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 diff --git a/usr.sbin/traceroute/Makefile b/usr.sbin/traceroute/Makefile index 1ae6cb81073a..94e7190a55e6 100644 --- a/usr.sbin/traceroute/Makefile +++ b/usr.sbin/traceroute/Makefile @@ -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