History

gcc-12: disable '-Warray-bounds' universally for now

In commit 8b202ee21839 ("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.

Linus Torvalds committed 4 years ago

Commit f0be87c1 parent 842c3b34 files · +12 −9Browse files

Unified · Split

4 files
  1. Makefile +1 −0
  2. arch/s390/Kconfig +1 −0
  3. arch/s390/Makefile +1 −9
  4. init/Kconfig +9 −0
Makefile+1−0
@@ -788,6 +788,7 @@ stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong · 787 unmodified lines
788KBUILD_CFLAGS += $(stackp-flags-y)788KBUILD_CFLAGS += $(stackp-flags-y)
789 789
790KBUILD_CFLAGS-$(CONFIG_WERROR) += -Werror790KBUILD_CFLAGS-$(CONFIG_WERROR) += -Werror
791KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
791KBUILD_CFLAGS += $(KBUILD_CFLAGS-y) $(CONFIG_CC_IMPLICIT_FALLTHROUGH)792KBUILD_CFLAGS += $(KBUILD_CFLAGS-y) $(CONFIG_CC_IMPLICIT_FALLTHROUGH)
792 793
793ifdef CONFIG_CC_IS_CLANG794ifdef CONFIG_CC_IS_CLANG
arch/s390/Kconfig+1−0
@@ -125,6 +125,7 @@ config S390 · 124 unmodified lines
125 select CLONE_BACKWARDS2125 select CLONE_BACKWARDS2
126 select DMA_OPS if PCI126 select DMA_OPS if PCI
127 select DYNAMIC_FTRACE if FUNCTION_TRACER127 select DYNAMIC_FTRACE if FUNCTION_TRACER
128 select GCC12_NO_ARRAY_BOUNDS
128 select GENERIC_ALLOCATOR129 select GENERIC_ALLOCATOR
129 select GENERIC_CPU_AUTOPROBE130 select GENERIC_CPU_AUTOPROBE
130 select GENERIC_CPU_VULNERABILITIES131 select GENERIC_CPU_VULNERABILITIES
arch/s390/Makefile+1−9
@@ -32,15 +32,7 @@ KBUILD_CFLAGS_DECOMPRESSOR += -fno-stack-protector · 31 unmodified lines
32KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, address-of-packed-member)32KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, address-of-packed-member)
33KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g)33KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g)
34KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))34KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))
35 35KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_CC_NO_ARRAY_BOUNDS),-Wno-array-bounds)
36ifdef CONFIG_CC_IS_GCC
37 ifeq ($(call cc-ifversion, -ge, 1200, y), y)
38 ifeq ($(call cc-ifversion, -lt, 1300, y), y)
39 KBUILD_CFLAGS += $(call cc-disable-warning, array-bounds)
40 KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, array-bounds)
41 endif
42 endif
43endif
44 36
45UTS_MACHINE := s390x37UTS_MACHINE := s390x
46STACK_SIZE := $(if $(CONFIG_KASAN),65536,16384)38STACK_SIZE := $(if $(CONFIG_KASAN),65536,16384)
init/Kconfig+9−0
@@ -885,6 +885,15 @@ config CC_IMPLICIT_FALLTHROUGH · 884 unmodified lines
885 default "-Wimplicit-fallthrough=5" if CC_IS_GCC && $(cc-option,-Wimplicit-fallthrough=5)885 default "-Wimplicit-fallthrough=5" if CC_IS_GCC && $(cc-option,-Wimplicit-fallthrough=5)
886 default "-Wimplicit-fallthrough" if CC_IS_CLANG && $(cc-option,-Wunreachable-code-fallthrough)886 default "-Wimplicit-fallthrough" if CC_IS_CLANG && $(cc-option,-Wunreachable-code-fallthrough)
887 887
888# Currently, disable gcc-12 array-bounds globally.
889# We may want to target only particular configurations some day.
890config GCC12_NO_ARRAY_BOUNDS
891 def_bool y
892
893config CC_NO_ARRAY_BOUNDS
894 bool
895 default y if CC_IS_GCC && GCC_VERSION >= 120000 && GCC_VERSION < 130000 && GCC12_NO_ARRAY_BOUNDS
896
888#897#
889# For architectures that know their GCC __int128 support is sound898# For architectures that know their GCC __int128 support is sound
890#899#

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t