# $NetBSD: copts.mk,v 1.15 2025/11/24 16:27:28 nia Exp $ # MI per-file compiler options required. # Use -Wno-error=foo when the ultimate goal is to fix this warning # with code change, and use -Wno-foo when the warning is bad. .ifndef _SYS_CONF_COPTS_MK_ _SYS_CONF_COPTS_MK_=1 COPTS.pf.c+= ${CC_WNO_IMPLICIT_FALLTHROUGH} COPTS.radeon_cs.c+= ${CC_WNO_IMPLICIT_FALLTHROUGH} COPTS.via_dmablit.c+= ${CC_WNO_IMPLICIT_FALLTHROUGH} .if defined(HAVE_GCC) && ${HAVE_GCC} >= 8 && ${ACTIVE_CC} == "gcc" && \ (${MACHINE_ARCH} == "mipseb" || ${MACHINE_ARCH} == "mipsel") COPTS.linux_machdep.c+= -Wno-error=unused-but-set-variable .endif .if defined(HAVE_GCC) && ${HAVE_GCC} >= 10 && ${ACTIVE_CC} == "gcc" COPTS.ath.c+= -Wno-error=enum-conversion COPTS.dpt.c+= ${CC_WNO_ADDRESS_OF_PACKED_MEMBER} COPTS.ffs_appleufs.c+= ${CC_WNO_ADDRESS_OF_PACKED_MEMBER} # These are wrong. The code explicitly avoids this case. COPTS.in_pcb.c+= ${CC_WNO_RETURN_LOCAL_ADDR} COPTS.in6_pcb.c+= ${CC_WNO_RETURN_LOCAL_ADDR} # Also seems wrong. 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_4x32_subr.c+= ${CC_WNO_ARRAY_BOUNDS} COPTS.aes_ssse3_subr.c+=${CC_WNO_ARRAY_BOUNDS} COPTS.aes_via.c+= ${CC_WNO_ARRAY_BOUNDS} .endif # Here's an example of the bogus gcc warning -- it's bogus because # while a parameter declarator of `const uint8_t[static 16]' means that # the input must have _at least_ 16 elements, it doesn't mean that the # input must have _at most_ 16 elements, yet gcc is interpreting it the # latter way on code where we have a run-time test of the buffer's # actual length to verify it is long enough before reading more than 16 # bytes out of it: # # In file included from ./machine/endian.h:3, # from /home/riastradh/netbsd/current/src/sys/sys/types.h:98, # from /home/riastradh/netbsd/current/src/sys/crypto/aes/aes_bear64.c:32: # In function 'le32dec', # inlined from 'aesbear64_cbc_dec.part.0' at /home/riastradh/netbsd/current/src/sys/crypto/aes/aes_bear64.c:315:9: # /home/riastradh/netbsd/current/src/sys/sys/endian.h:220:9: error: array subscript [12, 2305843009213693951] is outside array bounds of 'const uint8_t[16]' {aka 'const unsigned char[16]'} [-Werror=array-bounds=] # 220 | __builtin_memcpy(&u, buf, sizeof(u)); \ # | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # /home/riastradh/netbsd/current/src/sys/sys/endian.h:228:1: note: in expansion of macro '__GEN_ENDIAN_DEC' # 228 | __GEN_ENDIAN_DEC(32, le) # | ^~~~~~~~~~~~~~~~ # /home/riastradh/netbsd/current/src/sys/crypto/aes/aes_bear64.c: In function 'aesbear64_cbc_dec.part.0': # /home/riastradh/netbsd/current/src/sys/crypto/aes/aes_bear64.c:229:59: note: at offset 48 into object 'in' of size [0, 16] # 229 | aesbear64_cbc_dec(const struct aesdec *dec, const uint8_t in[static 16], # | ~~~~~~~~~~~~~~^~~~~~~~~~~~~ COPTS.aes_bear64.c+= ${CC_WNO_ARRAY_BOUNDS} ${CC_WNO_STRINGOP_OVERFLOW} ${CC_WNO_STRINGOP_OVERREAD} .endif