Skip to content

Commit 28bc20d

Browse files
sravnborgmichal42
authored andcommitted
kbuild: implement several W= levels
Building a kernel with "make W=1" produces far too much noise to be useful. Divide the warning options in three groups: W=1 - warnings that may be relevant and does not occur too often W=2 - warnings that occur quite often but may still be relevant W=3 - the more obscure warnings, can most likely be ignored When building the whole kernel, those levels produce: W=1 - 4859 warnings W=2 - 1394 warnings W=3 - 86666 warnings respectively. Warnings have been counted with Geert's script at http://www.kernel.org/pub/linux/kernel/people/geert/linux-log/linux-log-summary.pl Many warnings occur from .h files so fixing one file may have a nice effect on the total number of warnings. With these changes I am actually tempted to try W=1 now and then. Previously there was just too much noise. Borislav: - make the W= levels exclusive - move very noisy and making little sense for the kernel warnings to W=3 - drop -Woverlength-strings due to useless warning message - copy explanatory text for the different warning levels to 'make help' - recount warnings per level Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Borislav Petkov <bp@alien8.de> Cc: Dave Jones <davej@redhat.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Michal Marek <mmarek@suse.cz>
1 parent 40df759 commit 28bc20d

2 files changed

Lines changed: 44 additions & 29 deletions

File tree

‎Makefile‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ ifeq ("$(origin O)", "command line")
103103
endif
104104

105105
ifeq ("$(origin W)", "command line")
106-
export KBUILD_ENABLE_EXTRA_GCC_CHECKS := 1
106+
export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)
107107
endif
108108

109109
# That's our default target when none is given on the command line
@@ -1274,7 +1274,11 @@ help:
12741274
@echo ' make O=dir [targets] Locate all output files in "dir", including .config'
12751275
@echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)'
12761276
@echo ' make C=2 [targets] Force check of all c source with $$CHECK'
1277-
@echo ' make W=1 [targets] Enable extra gcc checks'
1277+
@echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where'
1278+
@echo ' 1: warnings which may be relevant and do not occur too often'
1279+
@echo ' 2: warnings which occur quite often but may still be relevant'
1280+
@echo ' 3: more obscure warnings, can most likely be ignored'
1281+
12781282
@echo ''
12791283
@echo 'Execute "make" or "make all" to build all targets marked with [*] '
12801284
@echo 'For further info see the ./README file'

‎scripts/Makefile.build‎

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,36 +51,47 @@ ifeq ($(KBUILD_NOPEDANTIC),)
5151
endif
5252

5353
#
54-
# make W=1 settings
54+
# make W=... settings
5555
#
56-
# $(call cc-option... ) handles gcc -W.. options which
56+
# W=1 - warnings that may be relevant and does not occur too often
57+
# W=2 - warnings that occur quite often but may still be relevant
58+
# W=3 - the more obscure warnings, can most likely be ignored
59+
#
60+
# $(call cc-option, -W...) handles gcc -W.. options which
5761
# are not supported by all versions of the compiler
5862
ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS
59-
KBUILD_EXTRA_WARNINGS := -Wextra
60-
KBUILD_EXTRA_WARNINGS += -Wunused -Wno-unused-parameter
61-
KBUILD_EXTRA_WARNINGS += -Waggregate-return
62-
KBUILD_EXTRA_WARNINGS += -Wbad-function-cast
63-
KBUILD_EXTRA_WARNINGS += -Wcast-qual
64-
KBUILD_EXTRA_WARNINGS += -Wcast-align
65-
KBUILD_EXTRA_WARNINGS += -Wconversion
66-
KBUILD_EXTRA_WARNINGS += -Wdisabled-optimization
67-
KBUILD_EXTRA_WARNINGS += -Wlogical-op
68-
KBUILD_EXTRA_WARNINGS += -Wmissing-declarations
69-
KBUILD_EXTRA_WARNINGS += -Wmissing-format-attribute
70-
KBUILD_EXTRA_WARNINGS += $(call cc-option, -Wmissing-include-dirs,)
71-
KBUILD_EXTRA_WARNINGS += -Wmissing-prototypes
72-
KBUILD_EXTRA_WARNINGS += -Wnested-externs
73-
KBUILD_EXTRA_WARNINGS += -Wold-style-definition
74-
KBUILD_EXTRA_WARNINGS += $(call cc-option, -Woverlength-strings,)
75-
KBUILD_EXTRA_WARNINGS += -Wpacked
76-
KBUILD_EXTRA_WARNINGS += -Wpacked-bitfield-compat
77-
KBUILD_EXTRA_WARNINGS += -Wpadded
78-
KBUILD_EXTRA_WARNINGS += -Wpointer-arith
79-
KBUILD_EXTRA_WARNINGS += -Wredundant-decls
80-
KBUILD_EXTRA_WARNINGS += -Wshadow
81-
KBUILD_EXTRA_WARNINGS += -Wswitch-default
82-
KBUILD_EXTRA_WARNINGS += $(call cc-option, -Wvla,)
83-
KBUILD_CFLAGS += $(KBUILD_EXTRA_WARNINGS)
63+
warning-1 := -Wextra -Wunused -Wno-unused-parameter
64+
warning-1 += -Wmissing-declarations
65+
warning-1 += -Wmissing-format-attribute
66+
warning-1 += -Wmissing-prototypes
67+
warning-1 += -Wold-style-definition
68+
warning-1 += $(call cc-option, -Wmissing-include-dirs)
69+
70+
warning-2 := -Waggregate-return
71+
warning-2 += -Wcast-align
72+
warning-2 += -Wdisabled-optimization
73+
warning-2 += -Wnested-externs
74+
warning-2 += -Wshadow
75+
warning-2 += $(call cc-option, -Wlogical-op)
76+
77+
warning-3 := -Wbad-function-cast
78+
warning-3 += -Wcast-qual
79+
warning-3 += -Wconversion
80+
warning-3 += -Wpacked
81+
warning-3 += -Wpadded
82+
warning-3 += -Wpointer-arith
83+
warning-3 += -Wredundant-decls
84+
warning-3 += -Wswitch-default
85+
warning-3 += $(call cc-option, -Wpacked-bitfield-compat)
86+
warning-3 += $(call cc-option, -Wvla)
87+
88+
warning := $(warning-$(KBUILD_ENABLE_EXTRA_GCC_CHECKS))
89+
90+
ifeq ("$(warning)","")
91+
$(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown)
92+
endif
93+
94+
KBUILD_CFLAGS += $(warning)
8495
endif
8596

8697
include scripts/Makefile.lib

0 commit comments

Comments
 (0)