• Linus Torvalds's avatar
    gcc-12: disable '-Warray-bounds' universally for now · f0be87c4
    Linus Torvalds authored
    In commit 8b202ee2 ("s390: disable -Warray-bounds") the s390 people
    disabled the '-Warray-bounds' warning for gcc-12, because the new logic
    in gcc would cause warnings for their use of the S390_lowcore macro,
    which accesses absolute pointers.
    
    It turns out gcc-12 has many other issues in this area, so this takes
    that s390 warning disable logic, and turns it into a kernel build config
    entry instead.
    
    Part of the intent is that we can make this all much more targeted, and
    use this conflig flag to disable it in only particular configurations
    that cause problems, with the s390 case as an example:
    
            select GCC12_NO_ARRAY_BOUNDS
    
    and we could do that for other configuration cases that cause issues.
    
    Or we could possibly use the CONFIG_CC_NO_ARRAY_BOUNDS thing in a more
    targeted way, and disable the warning only for particular uses: again
    the s390 case as an example:
    
      KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_CC_NO_ARRAY_BOUNDS),-Wno-array-bounds)
    
    but this ends up just doing it globally in the top-level Makefile, since
    the current issues are spread fairly widely all over:
    
      KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
    
    We'll try to limit this later, since the gcc-12 problems are rare enough
    that *much* of the kernel can be built with it without disabling this
    warning.
    
    Cc: Kees Cook <keescook@chromium.org>
    Cc: Nathan Chancellor <nathan@kernel.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    f0be87c4
Makefile 64.1 KB