Skip to content

Commit 610347e

Browse files
committed
Merge tag 'Wstringop-overflow-for-6.8-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux
Pull stringop-overflow warning update from Gustavo A. R. Silva: "Enable -Wstringop-overflow globally. I waited for the release of -rc1 to run a final build-test on top of it before sending this pull request. Fortunatelly, after building 358 kernels overnight (basically all supported archs with a wide variety of configs), no more warnings have surfaced! :) Thus, we are in a good position to enable this compiler option for all versions of GCC that support it, with the exception of GCC-11, which appears to have some issues with this option [1]" Link: https://lore.kernel.org/lkml/b3c99290-40bc-426f-b3d2-1aa903f95c4e@embeddedor.com/ [1] * tag 'Wstringop-overflow-for-6.8-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux: init: Kconfig: Disable -Wstringop-overflow for GCC-11 Makefile: Enable -Wstringop-overflow globally
2 parents 0f0d819 + a5e0ace commit 610347e

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,10 @@ NOSTDINC_FLAGS += -nostdinc
986986
# perform bounds checking.
987987
KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3)
988988

989+
#Currently, disable -Wstringop-overflow for GCC 11, globally.
990+
KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-option, -Wno-stringop-overflow)
991+
KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow)
992+
989993
# disable invalid "can't wrap" optimizations for signed / pointers
990994
KBUILD_CFLAGS += -fno-strict-overflow
991995

init/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,18 @@ config CC_NO_ARRAY_BOUNDS
876876
bool
877877
default y if CC_IS_GCC && GCC_VERSION >= 110000 && GCC11_NO_ARRAY_BOUNDS
878878

879+
# Currently, disable -Wstringop-overflow for GCC 11, globally.
880+
config GCC11_NO_STRINGOP_OVERFLOW
881+
def_bool y
882+
883+
config CC_NO_STRINGOP_OVERFLOW
884+
bool
885+
default y if CC_IS_GCC && GCC_VERSION >= 110000 && GCC_VERSION < 120000 && GCC11_NO_STRINGOP_OVERFLOW
886+
887+
config CC_STRINGOP_OVERFLOW
888+
bool
889+
default y if CC_IS_GCC && !CC_NO_STRINGOP_OVERFLOW
890+
879891
#
880892
# For architectures that know their GCC __int128 support is sound
881893
#

scripts/Makefile.extrawarn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable)
9797
KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned)
9898
KBUILD_CFLAGS += $(call cc-option, -Wformat-overflow)
9999
KBUILD_CFLAGS += $(call cc-option, -Wformat-truncation)
100-
KBUILD_CFLAGS += $(call cc-option, -Wstringop-overflow)
101100
KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation)
102101

103102
KBUILD_CPPFLAGS += -Wundef
@@ -113,7 +112,6 @@ KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
113112
KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
114113
KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
115114
KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
116-
KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
117115
KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
118116

119117
ifdef CONFIG_CC_IS_CLANG

0 commit comments

Comments
 (0)