* [PATCH v3 1/2] kbuild: refactor scripts/Makefile.extrawarn
@ 2019-08-31 16:25 Masahiro Yamada
2019-08-31 16:25 ` [PATCH v3 2/2] kbuild: rename KBUILD_ENABLE_EXTRA_GCC_CHECKS to KBUILD_EXTRA_WARN Masahiro Yamada
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Masahiro Yamada @ 2019-08-31 16:25 UTC (permalink / raw)
To: linux-kbuild
Cc: Nick Desaulniers, Nathan Chancellor, Sedat Dilek,
Masahiro Yamada, Michal Marek, clang-built-linux, linux-kernel
Instead of the warning-[123] magic, let's accumulate compiler options
to KBUILD_CFLAGS directly as the top Makefile does. I think this makes
easier to understand what is going on in this file.
This commit slightly changes the behavior, I think all of which are OK.
[1] Currently, cc-option calls are needlessly evaluated. For example,
warning-3 += $(call cc-option, -Wpacked-bitfield-compat)
needs evaluating only when W=3, but it is actually evaluated for
W=1, W=2 as well. With this commit, only relevant cc-option calls
will be evaluated. This is a slight optimization.
[2] Currently, unsupported level like W=4 is checked by:
$(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown)
This will no longer be checked, but I do not think it is a big
deal.
[3] Currently, 4 Clang warnings (Winitializer-overrides, Wformat,
Wsign-compare, Wformat-zero-length) are shown by any of W=1, W=2,
and W=3. With this commit, they will be warned only by W=1. I
think this is a more correct behavior since each warning belongs
to only one group.
For understanding this commit correctly:
We have 3 warning groups, W=1, W=2, and W=3. You may think W=3 has a
higher level than W=1, but they are actually independent. If you like,
you can combine them like W=13. To enable all the warnings, you can
pass W=123. It is shown by 'make help', but not noticed much. Since we
support W= combination, there should not exist intersection among the
three groups. If we enable Winitializer-overrides for W=1, we do not
need to for W=2 or W=3. This is the reason why I think the change [3]
makes sense.
The documentation says -Winitializer-overrides is enabled by default.
(https://clang.llvm.org/docs/DiagnosticsReference.html#winitializer-overrides)
We negate it by passing -Wno-initializer-overrides for the normal
build, but we do not do that for W=1. This means, W=1 effectively
enables -Winitializer-overrides by the clang's default. The same for
the other three.
Add comments in case people are confused with the code.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
Acked-by: Nick Desaulniers <ndesaulniers@google.com>
Acked-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
---
Changes in v3:
- Added yet more comments.
Fix grammatical mistake 'does' -> 'do'.
Changes in v2:
- Added comments and more commit log
| 106 ++++++++++++++++++++-----------------
1 file changed, 56 insertions(+), 50 deletions(-)
--git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index a74ce2e3c33e..d226c5fb13e2 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -1,14 +1,9 @@
# SPDX-License-Identifier: GPL-2.0
# ==========================================================================
-#
# make W=... settings
#
-# 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
-#
-# $(call cc-option, -W...) handles gcc -W.. options which
-# are not supported by all versions of the compiler
+# There are three warning groups enabled by W=1, W=2, W=3.
+# They are independent, and can be combined like W=12 or W=123.
# ==========================================================================
KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
@@ -17,58 +12,69 @@ ifeq ("$(origin W)", "command line")
export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)
endif
-ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS
-warning- := $(empty)
+#
+# W=1 - warnings which may be relevant and do not occur too often
+#
+ifneq ($(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
-warning-1 := -Wextra -Wunused -Wno-unused-parameter
-warning-1 += -Wmissing-declarations
-warning-1 += -Wmissing-format-attribute
-warning-1 += -Wmissing-prototypes
-warning-1 += -Wold-style-definition
-warning-1 += -Wmissing-include-dirs
-warning-1 += $(call cc-option, -Wunused-but-set-variable)
-warning-1 += $(call cc-option, -Wunused-const-variable)
-warning-1 += $(call cc-option, -Wpacked-not-aligned)
-warning-1 += $(call cc-option, -Wstringop-truncation)
+KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter
+KBUILD_CFLAGS += -Wmissing-declarations
+KBUILD_CFLAGS += -Wmissing-format-attribute
+KBUILD_CFLAGS += -Wmissing-prototypes
+KBUILD_CFLAGS += -Wold-style-definition
+KBUILD_CFLAGS += -Wmissing-include-dirs
+KBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable)
+KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable)
+KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned)
+KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation)
# The following turn off the warnings enabled by -Wextra
-warning-1 += -Wno-missing-field-initializers
-warning-1 += -Wno-sign-compare
-
-warning-2 += -Wcast-align
-warning-2 += -Wdisabled-optimization
-warning-2 += -Wnested-externs
-warning-2 += -Wshadow
-warning-2 += $(call cc-option, -Wlogical-op)
-warning-2 += -Wmissing-field-initializers
-warning-2 += -Wsign-compare
-warning-2 += $(call cc-option, -Wmaybe-uninitialized)
-warning-2 += $(call cc-option, -Wunused-macros)
-
-warning-3 := -Wbad-function-cast
-warning-3 += -Wcast-qual
-warning-3 += -Wconversion
-warning-3 += -Wpacked
-warning-3 += -Wpadded
-warning-3 += -Wpointer-arith
-warning-3 += -Wredundant-decls
-warning-3 += -Wswitch-default
-warning-3 += $(call cc-option, -Wpacked-bitfield-compat)
-
-warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
-warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
-warning += $(warning-$(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
-
-ifeq ("$(strip $(warning))","")
- $(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown)
-endif
+KBUILD_CFLAGS += -Wno-missing-field-initializers
+KBUILD_CFLAGS += -Wno-sign-compare
-KBUILD_CFLAGS += $(warning)
else
+# Some diagnostics enabled by default are noisy.
+# Suppress them by using -Wno... except for W=1.
+
ifdef CONFIG_CC_IS_CLANG
KBUILD_CFLAGS += -Wno-initializer-overrides
KBUILD_CFLAGS += -Wno-format
KBUILD_CFLAGS += -Wno-sign-compare
KBUILD_CFLAGS += -Wno-format-zero-length
endif
+
+endif
+
+#
+# W=2 - warnings which occur quite often but may still be relevant
+#
+ifneq ($(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
+
+KBUILD_CFLAGS += -Wcast-align
+KBUILD_CFLAGS += -Wdisabled-optimization
+KBUILD_CFLAGS += -Wnested-externs
+KBUILD_CFLAGS += -Wshadow
+KBUILD_CFLAGS += $(call cc-option, -Wlogical-op)
+KBUILD_CFLAGS += -Wmissing-field-initializers
+KBUILD_CFLAGS += -Wsign-compare
+KBUILD_CFLAGS += $(call cc-option, -Wmaybe-uninitialized)
+KBUILD_CFLAGS += $(call cc-option, -Wunused-macros)
+
+endif
+
+#
+# W=3 - more obscure warnings, can most likely be ignored
+#
+ifneq ($(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
+
+KBUILD_CFLAGS += -Wbad-function-cast
+KBUILD_CFLAGS += -Wcast-qual
+KBUILD_CFLAGS += -Wconversion
+KBUILD_CFLAGS += -Wpacked
+KBUILD_CFLAGS += -Wpadded
+KBUILD_CFLAGS += -Wpointer-arith
+KBUILD_CFLAGS += -Wredundant-decls
+KBUILD_CFLAGS += -Wswitch-default
+KBUILD_CFLAGS += $(call cc-option, -Wpacked-bitfield-compat)
+
endif
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v3 2/2] kbuild: rename KBUILD_ENABLE_EXTRA_GCC_CHECKS to KBUILD_EXTRA_WARN
2019-08-31 16:25 [PATCH v3 1/2] kbuild: refactor scripts/Makefile.extrawarn Masahiro Yamada
@ 2019-08-31 16:25 ` Masahiro Yamada
2019-09-03 5:37 ` Nathan Chancellor
2019-09-03 21:50 ` Nick Desaulniers
2019-09-04 21:46 ` [PATCH v3 1/2] kbuild: refactor scripts/Makefile.extrawarn Arnd Bergmann
2019-09-07 2:29 ` Masahiro Yamada
2 siblings, 2 replies; 12+ messages in thread
From: Masahiro Yamada @ 2019-08-31 16:25 UTC (permalink / raw)
To: linux-kbuild
Cc: Nick Desaulniers, Nathan Chancellor, Sedat Dilek,
Masahiro Yamada, Jonathan Corbet, Michal Marek,
clang-built-linux, linux-doc, linux-kernel
KBUILD_ENABLE_EXTRA_GCC_CHECKS started as a switch to add extra warning
options for GCC, but now it is a historical misnomer since we use it
also for Clang, DTC, and even kernel-doc.
Rename it to more sensible, and shorter KBUILD_EXTRA_WARN.
For the backward compatibility, KBUILD_ENABLE_EXTRA_GCC_CHECKS is still
supported (but not advertised in the documentation).
I also fixed up 'make help', and updated the documentation.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
Changes in v3:
- new patch
Changes in v2: None
Documentation/kbuild/kbuild.rst | 14 +++++++++-----
Makefile | 2 +-
scripts/Makefile.build | 2 +-
| 13 +++++++++----
scripts/Makefile.lib | 4 ++--
scripts/genksyms/Makefile | 2 +-
6 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/Documentation/kbuild/kbuild.rst b/Documentation/kbuild/kbuild.rst
index 62f9d86c082c..f1e5dce86af7 100644
--- a/Documentation/kbuild/kbuild.rst
+++ b/Documentation/kbuild/kbuild.rst
@@ -105,6 +105,15 @@ The output directory can also be specified using "O=...".
Setting "O=..." takes precedence over KBUILD_OUTPUT.
+KBUILD_EXTRA_WARN
+-----------------
+Specify the extra build checks. The same value can be assigned by passing
+W=... from the command line.
+
+See `make help` for the list of the supported values.
+
+Setting "W=..." takes precedence over KBUILD_EXTRA_WARN.
+
KBUILD_DEBARCH
--------------
For the deb-pkg target, allows overriding the normal heuristics deployed by
@@ -241,11 +250,6 @@ To get all available archs you can also specify all. E.g.::
$ make ALLSOURCE_ARCHS=all tags
-KBUILD_ENABLE_EXTRA_GCC_CHECKS
-------------------------------
-If enabled over the make command line with "W=1", it turns on additional
-gcc -W... options for more extensive build-time checking.
-
KBUILD_BUILD_TIMESTAMP
----------------------
Setting this to a date string overrides the timestamp used in the
diff --git a/Makefile b/Makefile
index 06e1e21c0f45..016d72eb3ddf 100644
--- a/Makefile
+++ b/Makefile
@@ -1538,7 +1538,7 @@ help:
@echo ' make C=1 [targets] Check re-compiled c source with $$CHECK (sparse by default)'
@echo ' make C=2 [targets] Force check of all c source with $$CHECK'
@echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections'
- @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where'
+ @echo ' make W=n [targets] Enable extra checks, n=1,2,3 where'
@echo ' 1: warnings which may be relevant and do not occur too often'
@echo ' 2: warnings which occur quite often but may still be relevant'
@echo ' 3: more obscure warnings, can most likely be ignored'
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 2a21ca86b720..f72aba64d611 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -85,7 +85,7 @@ else ifeq ($(KBUILD_CHECKSRC),2)
cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $<
endif
-ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),)
+ifneq ($(KBUILD_EXTRA_WARN),)
cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $<
endif
--git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index d226c5fb13e2..53eb7e0c6a5a 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -8,14 +8,19 @@
KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
+# backward compatibility
+KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)
+
ifeq ("$(origin W)", "command line")
- export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)
+ KBUILD_EXTRA_WARN := $(W)
endif
+export KBUILD_EXTRA_WARN
+
#
# W=1 - warnings which may be relevant and do not occur too often
#
-ifneq ($(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
+ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter
KBUILD_CFLAGS += -Wmissing-declarations
@@ -48,7 +53,7 @@ endif
#
# W=2 - warnings which occur quite often but may still be relevant
#
-ifneq ($(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
+ifneq ($(findstring 2, $(KBUILD_EXTRA_WARN)),)
KBUILD_CFLAGS += -Wcast-align
KBUILD_CFLAGS += -Wdisabled-optimization
@@ -65,7 +70,7 @@ endif
#
# W=3 - more obscure warnings, can most likely be ignored
#
-ifneq ($(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
+ifneq ($(findstring 3, $(KBUILD_EXTRA_WARN)),)
KBUILD_CFLAGS += -Wbad-function-cast
KBUILD_CFLAGS += -Wcast-qual
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 7ab17712ab24..df83967268ba 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -248,7 +248,7 @@ quiet_cmd_gzip = GZIP $@
DTC ?= $(objtree)/scripts/dtc/dtc
# Disable noisy checks by default
-ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
+ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
DTC_FLAGS += -Wno-unit_address_vs_reg \
-Wno-unit_address_format \
-Wno-avoid_unnecessary_addr_size \
@@ -259,7 +259,7 @@ DTC_FLAGS += -Wno-unit_address_vs_reg \
-Wno-pci_device_reg
endif
-ifneq ($(findstring 2,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
+ifneq ($(findstring 2,$(KBUILD_EXTRA_WARN)),)
DTC_FLAGS += -Wnode_name_chars_strict \
-Wproperty_name_chars_strict
endif
diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile
index baf44ed0a93a..78629f515e78 100644
--- a/scripts/genksyms/Makefile
+++ b/scripts/genksyms/Makefile
@@ -12,7 +12,7 @@ genksyms-objs := genksyms.o parse.tab.o lex.lex.o
#
# Just in case, run "$(YACC) --version" without suppressing stderr
# so that 'bison: not found' will be displayed if it is missing.
-ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
+ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
quiet_cmd_bison_no_warn = $(quiet_cmd_bison)
cmd_bison_no_warn = $(YACC) --version >/dev/null; \
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v3 2/2] kbuild: rename KBUILD_ENABLE_EXTRA_GCC_CHECKS to KBUILD_EXTRA_WARN
2019-08-31 16:25 ` [PATCH v3 2/2] kbuild: rename KBUILD_ENABLE_EXTRA_GCC_CHECKS to KBUILD_EXTRA_WARN Masahiro Yamada
@ 2019-09-03 5:37 ` Nathan Chancellor
2019-09-03 21:50 ` Nick Desaulniers
1 sibling, 0 replies; 12+ messages in thread
From: Nathan Chancellor @ 2019-09-03 5:37 UTC (permalink / raw)
To: Masahiro Yamada
Cc: linux-kbuild, Nick Desaulniers, Sedat Dilek, Jonathan Corbet,
Michal Marek, clang-built-linux, linux-doc, linux-kernel
On Sun, Sep 01, 2019 at 01:25:55AM +0900, Masahiro Yamada wrote:
> KBUILD_ENABLE_EXTRA_GCC_CHECKS started as a switch to add extra warning
> options for GCC, but now it is a historical misnomer since we use it
> also for Clang, DTC, and even kernel-doc.
>
> Rename it to more sensible, and shorter KBUILD_EXTRA_WARN.
>
> For the backward compatibility, KBUILD_ENABLE_EXTRA_GCC_CHECKS is still
> supported (but not advertised in the documentation).
>
> I also fixed up 'make help', and updated the documentation.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 2/2] kbuild: rename KBUILD_ENABLE_EXTRA_GCC_CHECKS to KBUILD_EXTRA_WARN
2019-08-31 16:25 ` [PATCH v3 2/2] kbuild: rename KBUILD_ENABLE_EXTRA_GCC_CHECKS to KBUILD_EXTRA_WARN Masahiro Yamada
2019-09-03 5:37 ` Nathan Chancellor
@ 2019-09-03 21:50 ` Nick Desaulniers
2019-09-04 6:58 ` Sedat Dilek
1 sibling, 1 reply; 12+ messages in thread
From: Nick Desaulniers @ 2019-09-03 21:50 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Linux Kbuild mailing list, Nathan Chancellor, Sedat Dilek,
Jonathan Corbet, Michal Marek, clang-built-linux, linux-doc,
LKML
On Sat, Aug 31, 2019 at 9:26 AM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> KBUILD_ENABLE_EXTRA_GCC_CHECKS started as a switch to add extra warning
> options for GCC, but now it is a historical misnomer since we use it
> also for Clang, DTC, and even kernel-doc.
Thanks for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
>
> Rename it to more sensible, and shorter KBUILD_EXTRA_WARN.
>
> For the backward compatibility, KBUILD_ENABLE_EXTRA_GCC_CHECKS is still
> supported (but not advertised in the documentation).
>
> I also fixed up 'make help', and updated the documentation.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
> Changes in v3:
> - new patch
>
> Changes in v2: None
>
> Documentation/kbuild/kbuild.rst | 14 +++++++++-----
> Makefile | 2 +-
> scripts/Makefile.build | 2 +-
> scripts/Makefile.extrawarn | 13 +++++++++----
> scripts/Makefile.lib | 4 ++--
> scripts/genksyms/Makefile | 2 +-
> 6 files changed, 23 insertions(+), 14 deletions(-)
>
> diff --git a/Documentation/kbuild/kbuild.rst b/Documentation/kbuild/kbuild.rst
> index 62f9d86c082c..f1e5dce86af7 100644
> --- a/Documentation/kbuild/kbuild.rst
> +++ b/Documentation/kbuild/kbuild.rst
> @@ -105,6 +105,15 @@ The output directory can also be specified using "O=...".
>
> Setting "O=..." takes precedence over KBUILD_OUTPUT.
>
> +KBUILD_EXTRA_WARN
> +-----------------
> +Specify the extra build checks. The same value can be assigned by passing
> +W=... from the command line.
> +
> +See `make help` for the list of the supported values.
> +
> +Setting "W=..." takes precedence over KBUILD_EXTRA_WARN.
> +
> KBUILD_DEBARCH
> --------------
> For the deb-pkg target, allows overriding the normal heuristics deployed by
> @@ -241,11 +250,6 @@ To get all available archs you can also specify all. E.g.::
>
> $ make ALLSOURCE_ARCHS=all tags
>
> -KBUILD_ENABLE_EXTRA_GCC_CHECKS
> -------------------------------
> -If enabled over the make command line with "W=1", it turns on additional
> -gcc -W... options for more extensive build-time checking.
> -
> KBUILD_BUILD_TIMESTAMP
> ----------------------
> Setting this to a date string overrides the timestamp used in the
> diff --git a/Makefile b/Makefile
> index 06e1e21c0f45..016d72eb3ddf 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1538,7 +1538,7 @@ help:
> @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK (sparse by default)'
> @echo ' make C=2 [targets] Force check of all c source with $$CHECK'
> @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections'
> - @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where'
> + @echo ' make W=n [targets] Enable extra checks, n=1,2,3 where'
> @echo ' 1: warnings which may be relevant and do not occur too often'
> @echo ' 2: warnings which occur quite often but may still be relevant'
> @echo ' 3: more obscure warnings, can most likely be ignored'
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 2a21ca86b720..f72aba64d611 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -85,7 +85,7 @@ else ifeq ($(KBUILD_CHECKSRC),2)
> cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $<
> endif
>
> -ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),)
> +ifneq ($(KBUILD_EXTRA_WARN),)
> cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $<
> endif
>
> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> index d226c5fb13e2..53eb7e0c6a5a 100644
> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -8,14 +8,19 @@
>
> KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
>
> +# backward compatibility
> +KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)
> +
> ifeq ("$(origin W)", "command line")
> - export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)
> + KBUILD_EXTRA_WARN := $(W)
> endif
>
> +export KBUILD_EXTRA_WARN
> +
> #
> # W=1 - warnings which may be relevant and do not occur too often
> #
> -ifneq ($(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
> +ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
>
> KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter
> KBUILD_CFLAGS += -Wmissing-declarations
> @@ -48,7 +53,7 @@ endif
> #
> # W=2 - warnings which occur quite often but may still be relevant
> #
> -ifneq ($(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
> +ifneq ($(findstring 2, $(KBUILD_EXTRA_WARN)),)
>
> KBUILD_CFLAGS += -Wcast-align
> KBUILD_CFLAGS += -Wdisabled-optimization
> @@ -65,7 +70,7 @@ endif
> #
> # W=3 - more obscure warnings, can most likely be ignored
> #
> -ifneq ($(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
> +ifneq ($(findstring 3, $(KBUILD_EXTRA_WARN)),)
>
> KBUILD_CFLAGS += -Wbad-function-cast
> KBUILD_CFLAGS += -Wcast-qual
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 7ab17712ab24..df83967268ba 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -248,7 +248,7 @@ quiet_cmd_gzip = GZIP $@
> DTC ?= $(objtree)/scripts/dtc/dtc
>
> # Disable noisy checks by default
> -ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
> +ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
> DTC_FLAGS += -Wno-unit_address_vs_reg \
> -Wno-unit_address_format \
> -Wno-avoid_unnecessary_addr_size \
> @@ -259,7 +259,7 @@ DTC_FLAGS += -Wno-unit_address_vs_reg \
> -Wno-pci_device_reg
> endif
>
> -ifneq ($(findstring 2,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
> +ifneq ($(findstring 2,$(KBUILD_EXTRA_WARN)),)
> DTC_FLAGS += -Wnode_name_chars_strict \
> -Wproperty_name_chars_strict
> endif
> diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile
> index baf44ed0a93a..78629f515e78 100644
> --- a/scripts/genksyms/Makefile
> +++ b/scripts/genksyms/Makefile
> @@ -12,7 +12,7 @@ genksyms-objs := genksyms.o parse.tab.o lex.lex.o
> #
> # Just in case, run "$(YACC) --version" without suppressing stderr
> # so that 'bison: not found' will be displayed if it is missing.
> -ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
> +ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
>
> quiet_cmd_bison_no_warn = $(quiet_cmd_bison)
> cmd_bison_no_warn = $(YACC) --version >/dev/null; \
> --
> 2.17.1
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 2/2] kbuild: rename KBUILD_ENABLE_EXTRA_GCC_CHECKS to KBUILD_EXTRA_WARN
2019-09-03 21:50 ` Nick Desaulniers
@ 2019-09-04 6:58 ` Sedat Dilek
2019-09-04 8:07 ` Sedat Dilek
0 siblings, 1 reply; 12+ messages in thread
From: Sedat Dilek @ 2019-09-04 6:58 UTC (permalink / raw)
To: Nick Desaulniers
Cc: Masahiro Yamada, Linux Kbuild mailing list, Nathan Chancellor,
Jonathan Corbet, Michal Marek, clang-built-linux, linux-doc,
LKML
On Tue, Sep 3, 2019 at 11:50 PM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Sat, Aug 31, 2019 at 9:26 AM Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
> >
> > KBUILD_ENABLE_EXTRA_GCC_CHECKS started as a switch to add extra warning
> > options for GCC, but now it is a historical misnomer since we use it
> > also for Clang, DTC, and even kernel-doc.
>
> Thanks for the patch!
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
>
Thanks for the patch.
I like the backward compatibility and am OK with pointing to 'make
--help' for the documentation part (KISS - Keep It Simple and
Short/Stupid).
Reviewed-by: Sedat Dilek <sedat.dilek@gmail.com>
- Sedat -
> >
> > Rename it to more sensible, and shorter KBUILD_EXTRA_WARN.
> >
> > For the backward compatibility, KBUILD_ENABLE_EXTRA_GCC_CHECKS is still
> > supported (but not advertised in the documentation).
> >
> > I also fixed up 'make help', and updated the documentation.
> >
> > Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> > ---
> >
> > Changes in v3:
> > - new patch
> >
> > Changes in v2: None
> >
> > Documentation/kbuild/kbuild.rst | 14 +++++++++-----
> > Makefile | 2 +-
> > scripts/Makefile.build | 2 +-
> > scripts/Makefile.extrawarn | 13 +++++++++----
> > scripts/Makefile.lib | 4 ++--
> > scripts/genksyms/Makefile | 2 +-
> > 6 files changed, 23 insertions(+), 14 deletions(-)
> >
> > diff --git a/Documentation/kbuild/kbuild.rst b/Documentation/kbuild/kbuild.rst
> > index 62f9d86c082c..f1e5dce86af7 100644
> > --- a/Documentation/kbuild/kbuild.rst
> > +++ b/Documentation/kbuild/kbuild.rst
> > @@ -105,6 +105,15 @@ The output directory can also be specified using "O=...".
> >
> > Setting "O=..." takes precedence over KBUILD_OUTPUT.
> >
> > +KBUILD_EXTRA_WARN
> > +-----------------
> > +Specify the extra build checks. The same value can be assigned by passing
> > +W=... from the command line.
> > +
> > +See `make help` for the list of the supported values.
> > +
> > +Setting "W=..." takes precedence over KBUILD_EXTRA_WARN.
> > +
> > KBUILD_DEBARCH
> > --------------
> > For the deb-pkg target, allows overriding the normal heuristics deployed by
> > @@ -241,11 +250,6 @@ To get all available archs you can also specify all. E.g.::
> >
> > $ make ALLSOURCE_ARCHS=all tags
> >
> > -KBUILD_ENABLE_EXTRA_GCC_CHECKS
> > -------------------------------
> > -If enabled over the make command line with "W=1", it turns on additional
> > -gcc -W... options for more extensive build-time checking.
> > -
> > KBUILD_BUILD_TIMESTAMP
> > ----------------------
> > Setting this to a date string overrides the timestamp used in the
> > diff --git a/Makefile b/Makefile
> > index 06e1e21c0f45..016d72eb3ddf 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1538,7 +1538,7 @@ help:
> > @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK (sparse by default)'
> > @echo ' make C=2 [targets] Force check of all c source with $$CHECK'
> > @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections'
> > - @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where'
> > + @echo ' make W=n [targets] Enable extra checks, n=1,2,3 where'
> > @echo ' 1: warnings which may be relevant and do not occur too often'
> > @echo ' 2: warnings which occur quite often but may still be relevant'
> > @echo ' 3: more obscure warnings, can most likely be ignored'
> > diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> > index 2a21ca86b720..f72aba64d611 100644
> > --- a/scripts/Makefile.build
> > +++ b/scripts/Makefile.build
> > @@ -85,7 +85,7 @@ else ifeq ($(KBUILD_CHECKSRC),2)
> > cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $<
> > endif
> >
> > -ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),)
> > +ifneq ($(KBUILD_EXTRA_WARN),)
> > cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $<
> > endif
> >
> > diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> > index d226c5fb13e2..53eb7e0c6a5a 100644
> > --- a/scripts/Makefile.extrawarn
> > +++ b/scripts/Makefile.extrawarn
> > @@ -8,14 +8,19 @@
> >
> > KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
> >
> > +# backward compatibility
> > +KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)
> > +
> > ifeq ("$(origin W)", "command line")
> > - export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)
> > + KBUILD_EXTRA_WARN := $(W)
> > endif
> >
> > +export KBUILD_EXTRA_WARN
> > +
> > #
> > # W=1 - warnings which may be relevant and do not occur too often
> > #
> > -ifneq ($(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
> > +ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
> >
> > KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter
> > KBUILD_CFLAGS += -Wmissing-declarations
> > @@ -48,7 +53,7 @@ endif
> > #
> > # W=2 - warnings which occur quite often but may still be relevant
> > #
> > -ifneq ($(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
> > +ifneq ($(findstring 2, $(KBUILD_EXTRA_WARN)),)
> >
> > KBUILD_CFLAGS += -Wcast-align
> > KBUILD_CFLAGS += -Wdisabled-optimization
> > @@ -65,7 +70,7 @@ endif
> > #
> > # W=3 - more obscure warnings, can most likely be ignored
> > #
> > -ifneq ($(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
> > +ifneq ($(findstring 3, $(KBUILD_EXTRA_WARN)),)
> >
> > KBUILD_CFLAGS += -Wbad-function-cast
> > KBUILD_CFLAGS += -Wcast-qual
> > diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> > index 7ab17712ab24..df83967268ba 100644
> > --- a/scripts/Makefile.lib
> > +++ b/scripts/Makefile.lib
> > @@ -248,7 +248,7 @@ quiet_cmd_gzip = GZIP $@
> > DTC ?= $(objtree)/scripts/dtc/dtc
> >
> > # Disable noisy checks by default
> > -ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
> > +ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
> > DTC_FLAGS += -Wno-unit_address_vs_reg \
> > -Wno-unit_address_format \
> > -Wno-avoid_unnecessary_addr_size \
> > @@ -259,7 +259,7 @@ DTC_FLAGS += -Wno-unit_address_vs_reg \
> > -Wno-pci_device_reg
> > endif
> >
> > -ifneq ($(findstring 2,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
> > +ifneq ($(findstring 2,$(KBUILD_EXTRA_WARN)),)
> > DTC_FLAGS += -Wnode_name_chars_strict \
> > -Wproperty_name_chars_strict
> > endif
> > diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile
> > index baf44ed0a93a..78629f515e78 100644
> > --- a/scripts/genksyms/Makefile
> > +++ b/scripts/genksyms/Makefile
> > @@ -12,7 +12,7 @@ genksyms-objs := genksyms.o parse.tab.o lex.lex.o
> > #
> > # Just in case, run "$(YACC) --version" without suppressing stderr
> > # so that 'bison: not found' will be displayed if it is missing.
> > -ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
> > +ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
> >
> > quiet_cmd_bison_no_warn = $(quiet_cmd_bison)
> > cmd_bison_no_warn = $(YACC) --version >/dev/null; \
> > --
> > 2.17.1
> >
>
>
> --
> Thanks,
> ~Nick Desaulniers
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 2/2] kbuild: rename KBUILD_ENABLE_EXTRA_GCC_CHECKS to KBUILD_EXTRA_WARN
2019-09-04 6:58 ` Sedat Dilek
@ 2019-09-04 8:07 ` Sedat Dilek
2019-09-04 9:58 ` Sedat Dilek
0 siblings, 1 reply; 12+ messages in thread
From: Sedat Dilek @ 2019-09-04 8:07 UTC (permalink / raw)
To: Nick Desaulniers
Cc: Masahiro Yamada, Linux Kbuild mailing list, Nathan Chancellor,
Jonathan Corbet, Michal Marek, clang-built-linux, linux-doc,
LKML
On Wed, Sep 4, 2019 at 8:58 AM Sedat Dilek <sedat.dilek@gmail.com> wrote:
>
> On Tue, Sep 3, 2019 at 11:50 PM Nick Desaulniers
> <ndesaulniers@google.com> wrote:
> >
> > On Sat, Aug 31, 2019 at 9:26 AM Masahiro Yamada
> > <yamada.masahiro@socionext.com> wrote:
> > >
> > > KBUILD_ENABLE_EXTRA_GCC_CHECKS started as a switch to add extra warning
> > > options for GCC, but now it is a historical misnomer since we use it
> > > also for Clang, DTC, and even kernel-doc.
> >
> > Thanks for the patch!
> > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> >
>
> Thanks for the patch.
> I like the backward compatibility and am OK with pointing to 'make
> --help' for the documentation part (KISS - Keep It Simple and
> Short/Stupid).
>
> Reviewed-by: Sedat Dilek <sedat.dilek@gmail.com>
If you will do a next version...
- @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where'
+ @echo ' make W=n [targets] Enable extra checks, n=1,2,3 where'
...clarify on extra checks for compiler...
+ @echo ' make W=n [targets] Enable extra *compiler* checks, n=1,2,3 where'
Thanks in advance.
- Sedat -
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 2/2] kbuild: rename KBUILD_ENABLE_EXTRA_GCC_CHECKS to KBUILD_EXTRA_WARN
2019-09-04 8:07 ` Sedat Dilek
@ 2019-09-04 9:58 ` Sedat Dilek
2019-09-04 14:05 ` Masahiro Yamada
0 siblings, 1 reply; 12+ messages in thread
From: Sedat Dilek @ 2019-09-04 9:58 UTC (permalink / raw)
To: Nick Desaulniers
Cc: Masahiro Yamada, Linux Kbuild mailing list, Nathan Chancellor,
Jonathan Corbet, Michal Marek, clang-built-linux, linux-doc,
LKML
On Wed, Sep 4, 2019 at 10:07 AM Sedat Dilek <sedat.dilek@gmail.com> wrote:
>
> On Wed, Sep 4, 2019 at 8:58 AM Sedat Dilek <sedat.dilek@gmail.com> wrote:
> >
> > On Tue, Sep 3, 2019 at 11:50 PM Nick Desaulniers
> > <ndesaulniers@google.com> wrote:
> > >
> > > On Sat, Aug 31, 2019 at 9:26 AM Masahiro Yamada
> > > <yamada.masahiro@socionext.com> wrote:
> > > >
> > > > KBUILD_ENABLE_EXTRA_GCC_CHECKS started as a switch to add extra warning
> > > > options for GCC, but now it is a historical misnomer since we use it
> > > > also for Clang, DTC, and even kernel-doc.
> > >
> > > Thanks for the patch!
> > > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> > >
> >
> > Thanks for the patch.
> > I like the backward compatibility and am OK with pointing to 'make
> > --help' for the documentation part (KISS - Keep It Simple and
> > Short/Stupid).
> >
> > Reviewed-by: Sedat Dilek <sedat.dilek@gmail.com>
>
> If you will do a next version...
>
> - @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where'
> + @echo ' make W=n [targets] Enable extra checks, n=1,2,3 where'
>
> ...clarify on extra checks for compiler...
>
> + @echo ' make W=n [targets] Enable extra *compiler* checks, n=1,2,3 where'
>
+KBUILD_EXTRA_WARN
+-----------------
+Specify the extra build checks. The same value can be assigned by passing
+W=... from the command line.
For consistency reasons might be better:
- @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where'
+ @echo ' make W=n [targets] Enable extra build checks, n=1,2,3 where'
- Sedat -
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 2/2] kbuild: rename KBUILD_ENABLE_EXTRA_GCC_CHECKS to KBUILD_EXTRA_WARN
2019-09-04 9:58 ` Sedat Dilek
@ 2019-09-04 14:05 ` Masahiro Yamada
0 siblings, 0 replies; 12+ messages in thread
From: Masahiro Yamada @ 2019-09-04 14:05 UTC (permalink / raw)
To: Sedat Dilek
Cc: Nick Desaulniers, Linux Kbuild mailing list, Nathan Chancellor,
Jonathan Corbet, Michal Marek, clang-built-linux,
open list:DOCUMENTATION, LKML
On Wed, Sep 4, 2019 at 6:58 PM Sedat Dilek <sedat.dilek@gmail.com> wrote:
>
> On Wed, Sep 4, 2019 at 10:07 AM Sedat Dilek <sedat.dilek@gmail.com> wrote:
> >
> > On Wed, Sep 4, 2019 at 8:58 AM Sedat Dilek <sedat.dilek@gmail.com> wrote:
> > >
> > > On Tue, Sep 3, 2019 at 11:50 PM Nick Desaulniers
> > > <ndesaulniers@google.com> wrote:
> > > >
> > > > On Sat, Aug 31, 2019 at 9:26 AM Masahiro Yamada
> > > > <yamada.masahiro@socionext.com> wrote:
> > > > >
> > > > > KBUILD_ENABLE_EXTRA_GCC_CHECKS started as a switch to add extra warning
> > > > > options for GCC, but now it is a historical misnomer since we use it
> > > > > also for Clang, DTC, and even kernel-doc.
> > > >
> > > > Thanks for the patch!
> > > > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> > > >
> > >
> > > Thanks for the patch.
> > > I like the backward compatibility and am OK with pointing to 'make
> > > --help' for the documentation part (KISS - Keep It Simple and
> > > Short/Stupid).
> > >
> > > Reviewed-by: Sedat Dilek <sedat.dilek@gmail.com>
> >
> > If you will do a next version...
> >
> > - @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where'
> > + @echo ' make W=n [targets] Enable extra checks, n=1,2,3 where'
> >
> > ...clarify on extra checks for compiler...
> >
> > + @echo ' make W=n [targets] Enable extra *compiler* checks, n=1,2,3 where'
> >
>
> +KBUILD_EXTRA_WARN
> +-----------------
> +Specify the extra build checks. The same value can be assigned by passing
> +W=... from the command line.
>
> For consistency reasons might be better:
>
> - @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where'
> + @echo ' make W=n [targets] Enable extra build checks, n=1,2,3 where'
>
OK, I will squash this. Thanks.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 1/2] kbuild: refactor scripts/Makefile.extrawarn
2019-08-31 16:25 [PATCH v3 1/2] kbuild: refactor scripts/Makefile.extrawarn Masahiro Yamada
2019-08-31 16:25 ` [PATCH v3 2/2] kbuild: rename KBUILD_ENABLE_EXTRA_GCC_CHECKS to KBUILD_EXTRA_WARN Masahiro Yamada
@ 2019-09-04 21:46 ` Arnd Bergmann
2019-09-04 22:40 ` Nathan Chancellor
2019-09-07 2:29 ` Masahiro Yamada
2 siblings, 1 reply; 12+ messages in thread
From: Arnd Bergmann @ 2019-09-04 21:46 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Linux Kbuild mailing list, Nick Desaulniers, Nathan Chancellor,
Sedat Dilek, Michal Marek, clang-built-linux, linux-kernel
On Sat, Aug 31, 2019 at 6:26 PM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> +# Some diagnostics enabled by default are noisy.
> +# Suppress them by using -Wno... except for W=1.
> +
> ifdef CONFIG_CC_IS_CLANG
> KBUILD_CFLAGS += -Wno-initializer-overrides
> KBUILD_CFLAGS += -Wno-format
> KBUILD_CFLAGS += -Wno-sign-compare
> KBUILD_CFLAGS += -Wno-format-zero-length
> endif
FWIW, I just found out I missed a bug that clang failed to warn about
because of the -Wno-format. Apparently gcc warns only about type
mismatches that result in incompatible calling conventions (e.g.
int vs int64_t) but not smaller types (int, short) that get converted to an
int anyway. Passing -Wno-format turns both off.
Arnd
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 1/2] kbuild: refactor scripts/Makefile.extrawarn
2019-09-04 21:46 ` [PATCH v3 1/2] kbuild: refactor scripts/Makefile.extrawarn Arnd Bergmann
@ 2019-09-04 22:40 ` Nathan Chancellor
2019-09-05 8:06 ` Arnd Bergmann
0 siblings, 1 reply; 12+ messages in thread
From: Nathan Chancellor @ 2019-09-04 22:40 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Masahiro Yamada, Linux Kbuild mailing list, Nick Desaulniers,
Sedat Dilek, Michal Marek, clang-built-linux, linux-kernel
On Wed, Sep 04, 2019 at 11:46:45PM +0200, Arnd Bergmann wrote:
> On Sat, Aug 31, 2019 at 6:26 PM Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
>
> > +# Some diagnostics enabled by default are noisy.
> > +# Suppress them by using -Wno... except for W=1.
> > +
> > ifdef CONFIG_CC_IS_CLANG
> > KBUILD_CFLAGS += -Wno-initializer-overrides
> > KBUILD_CFLAGS += -Wno-format
> > KBUILD_CFLAGS += -Wno-sign-compare
> > KBUILD_CFLAGS += -Wno-format-zero-length
> > endif
>
> FWIW, I just found out I missed a bug that clang failed to warn about
> because of the -Wno-format. Apparently gcc warns only about type
> mismatches that result in incompatible calling conventions (e.g.
> int vs int64_t) but not smaller types (int, short) that get converted to an
> int anyway. Passing -Wno-format turns both off.
>
> Arnd
Hi Arnd,
This has been fixed in clang 10.0.0 but this areas has not been updated
as nobody has sent a patch yet:
https://github.com/ClangBuiltLinux/linux/issues/378#issuecomment-524411147
Cheers,
Nathan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 1/2] kbuild: refactor scripts/Makefile.extrawarn
2019-09-04 22:40 ` Nathan Chancellor
@ 2019-09-05 8:06 ` Arnd Bergmann
0 siblings, 0 replies; 12+ messages in thread
From: Arnd Bergmann @ 2019-09-05 8:06 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Masahiro Yamada, Linux Kbuild mailing list, Nick Desaulniers,
Sedat Dilek, Michal Marek, clang-built-linux, linux-kernel
On Thu, Sep 5, 2019 at 12:40 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
> On Wed, Sep 04, 2019 at 11:46:45PM +0200, Arnd Bergmann wrote:
> > On Sat, Aug 31, 2019 at 6:26 PM Masahiro Yamada
> > <yamada.masahiro@socionext.com> wrote:
> >
> > FWIW, I just found out I missed a bug that clang failed to warn about
> > because of the -Wno-format. Apparently gcc warns only about type
> > mismatches that result in incompatible calling conventions (e.g.
> > int vs int64_t) but not smaller types (int, short) that get converted to an
> > int anyway. Passing -Wno-format turns both off.
> >
> > Arnd
>
> Hi Arnd,
>
> This has been fixed in clang 10.0.0 but this areas has not been updated
> as nobody has sent a patch yet:
>
> https://github.com/ClangBuiltLinux/linux/issues/378#issuecomment-524411147
Ok, that's good. I see that on clang-9, the documentation also
mentions that -Wformat control -Wformat-extra-args -Wformat-invalid-specifier
-Wformat-y2k -Wformat-zero-length -Wnonnull and -Wformat-security.
We can probably turn these all on, regardless. The only warning
that produces output here is -Wformat-security, and only in a couple of
files (number of warnings per file from a few hundred randconfig builds):
384 kernel/trace/ring_buffer_benchmark.c
176 samples/trace_printk/trace-printk.c
174 kernel/debug/kdb/kdb_io.c
102 arch/x86/kernel/e820.c
80 fs/btrfs/check-integrity.c
67 fs/reiserfs/prints.c
63 fs/xfs/xfs_log_recover.c
54 fs/quota/dquot.c
53 lib/test_printf.c
39 sound/core/sound.c
28 arch/x86/kernel/cpu/mce/core.c
21 kernel/trace/preemptirq_delay_test.c
19 sound/core/seq/seq_clientmgr.c
17 sound/pci/hda/hda_bind.c
16 sound/usb/mixer_quirks.c
16 arch/x86/kernel/cpu/mce/amd.c
15 net/smc/smc_ism.c
12 kernel/debug/kdb/kdb_main.c
8 net/netfilter/nf_conntrack_helper.c
4 kernel/power/suspend_test.c
3 sound/pci/rme32.c
3 net/dsa/dsa.c
2 sound/pci/rme96.c
1 sound/soc/sof/intel/hda-codec.c
1 sound/pci/korg1212/korg1212.c
Arnd
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 1/2] kbuild: refactor scripts/Makefile.extrawarn
2019-08-31 16:25 [PATCH v3 1/2] kbuild: refactor scripts/Makefile.extrawarn Masahiro Yamada
2019-08-31 16:25 ` [PATCH v3 2/2] kbuild: rename KBUILD_ENABLE_EXTRA_GCC_CHECKS to KBUILD_EXTRA_WARN Masahiro Yamada
2019-09-04 21:46 ` [PATCH v3 1/2] kbuild: refactor scripts/Makefile.extrawarn Arnd Bergmann
@ 2019-09-07 2:29 ` Masahiro Yamada
2 siblings, 0 replies; 12+ messages in thread
From: Masahiro Yamada @ 2019-09-07 2:29 UTC (permalink / raw)
To: Linux Kbuild mailing list
Cc: Nick Desaulniers, Nathan Chancellor, Sedat Dilek, Michal Marek,
clang-built-linux, Linux Kernel Mailing List
On Sun, Sep 1, 2019 at 1:26 AM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> Instead of the warning-[123] magic, let's accumulate compiler options
> to KBUILD_CFLAGS directly as the top Makefile does. I think this makes
> easier to understand what is going on in this file.
>
> This commit slightly changes the behavior, I think all of which are OK.
>
> [1] Currently, cc-option calls are needlessly evaluated. For example,
> warning-3 += $(call cc-option, -Wpacked-bitfield-compat)
> needs evaluating only when W=3, but it is actually evaluated for
> W=1, W=2 as well. With this commit, only relevant cc-option calls
> will be evaluated. This is a slight optimization.
>
> [2] Currently, unsupported level like W=4 is checked by:
> $(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown)
> This will no longer be checked, but I do not think it is a big
> deal.
>
> [3] Currently, 4 Clang warnings (Winitializer-overrides, Wformat,
> Wsign-compare, Wformat-zero-length) are shown by any of W=1, W=2,
> and W=3. With this commit, they will be warned only by W=1. I
> think this is a more correct behavior since each warning belongs
> to only one group.
>
> For understanding this commit correctly:
>
> We have 3 warning groups, W=1, W=2, and W=3. You may think W=3 has a
> higher level than W=1, but they are actually independent. If you like,
> you can combine them like W=13. To enable all the warnings, you can
> pass W=123. It is shown by 'make help', but not noticed much. Since we
> support W= combination, there should not exist intersection among the
> three groups. If we enable Winitializer-overrides for W=1, we do not
> need to for W=2 or W=3. This is the reason why I think the change [3]
> makes sense.
>
> The documentation says -Winitializer-overrides is enabled by default.
> (https://clang.llvm.org/docs/DiagnosticsReference.html#winitializer-overrides)
> We negate it by passing -Wno-initializer-overrides for the normal
> build, but we do not do that for W=1. This means, W=1 effectively
> enables -Winitializer-overrides by the clang's default. The same for
> the other three.
>
> Add comments in case people are confused with the code.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
> Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
> Acked-by: Nick Desaulniers <ndesaulniers@google.com>
> Acked-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
> ---
Both applied to linux-kbuild.
> Changes in v3:
> - Added yet more comments.
> Fix grammatical mistake 'does' -> 'do'.
>
> Changes in v2:
> - Added comments and more commit log
>
> scripts/Makefile.extrawarn | 106 ++++++++++++++++++++-----------------
> 1 file changed, 56 insertions(+), 50 deletions(-)
>
> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> index a74ce2e3c33e..d226c5fb13e2 100644
> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -1,14 +1,9 @@
> # SPDX-License-Identifier: GPL-2.0
> # ==========================================================================
> -#
> # make W=... settings
> #
> -# 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
> -#
> -# $(call cc-option, -W...) handles gcc -W.. options which
> -# are not supported by all versions of the compiler
> +# There are three warning groups enabled by W=1, W=2, W=3.
> +# They are independent, and can be combined like W=12 or W=123.
> # ==========================================================================
>
> KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned)
> @@ -17,58 +12,69 @@ ifeq ("$(origin W)", "command line")
> export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)
> endif
>
> -ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS
> -warning- := $(empty)
> +#
> +# W=1 - warnings which may be relevant and do not occur too often
> +#
> +ifneq ($(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
>
> -warning-1 := -Wextra -Wunused -Wno-unused-parameter
> -warning-1 += -Wmissing-declarations
> -warning-1 += -Wmissing-format-attribute
> -warning-1 += -Wmissing-prototypes
> -warning-1 += -Wold-style-definition
> -warning-1 += -Wmissing-include-dirs
> -warning-1 += $(call cc-option, -Wunused-but-set-variable)
> -warning-1 += $(call cc-option, -Wunused-const-variable)
> -warning-1 += $(call cc-option, -Wpacked-not-aligned)
> -warning-1 += $(call cc-option, -Wstringop-truncation)
> +KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter
> +KBUILD_CFLAGS += -Wmissing-declarations
> +KBUILD_CFLAGS += -Wmissing-format-attribute
> +KBUILD_CFLAGS += -Wmissing-prototypes
> +KBUILD_CFLAGS += -Wold-style-definition
> +KBUILD_CFLAGS += -Wmissing-include-dirs
> +KBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable)
> +KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable)
> +KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned)
> +KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation)
> # The following turn off the warnings enabled by -Wextra
> -warning-1 += -Wno-missing-field-initializers
> -warning-1 += -Wno-sign-compare
> -
> -warning-2 += -Wcast-align
> -warning-2 += -Wdisabled-optimization
> -warning-2 += -Wnested-externs
> -warning-2 += -Wshadow
> -warning-2 += $(call cc-option, -Wlogical-op)
> -warning-2 += -Wmissing-field-initializers
> -warning-2 += -Wsign-compare
> -warning-2 += $(call cc-option, -Wmaybe-uninitialized)
> -warning-2 += $(call cc-option, -Wunused-macros)
> -
> -warning-3 := -Wbad-function-cast
> -warning-3 += -Wcast-qual
> -warning-3 += -Wconversion
> -warning-3 += -Wpacked
> -warning-3 += -Wpadded
> -warning-3 += -Wpointer-arith
> -warning-3 += -Wredundant-decls
> -warning-3 += -Wswitch-default
> -warning-3 += $(call cc-option, -Wpacked-bitfield-compat)
> -
> -warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
> -warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
> -warning += $(warning-$(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
> -
> -ifeq ("$(strip $(warning))","")
> - $(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown)
> -endif
> +KBUILD_CFLAGS += -Wno-missing-field-initializers
> +KBUILD_CFLAGS += -Wno-sign-compare
>
> -KBUILD_CFLAGS += $(warning)
> else
>
> +# Some diagnostics enabled by default are noisy.
> +# Suppress them by using -Wno... except for W=1.
> +
> ifdef CONFIG_CC_IS_CLANG
> KBUILD_CFLAGS += -Wno-initializer-overrides
> KBUILD_CFLAGS += -Wno-format
> KBUILD_CFLAGS += -Wno-sign-compare
> KBUILD_CFLAGS += -Wno-format-zero-length
> endif
> +
> +endif
> +
> +#
> +# W=2 - warnings which occur quite often but may still be relevant
> +#
> +ifneq ($(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
> +
> +KBUILD_CFLAGS += -Wcast-align
> +KBUILD_CFLAGS += -Wdisabled-optimization
> +KBUILD_CFLAGS += -Wnested-externs
> +KBUILD_CFLAGS += -Wshadow
> +KBUILD_CFLAGS += $(call cc-option, -Wlogical-op)
> +KBUILD_CFLAGS += -Wmissing-field-initializers
> +KBUILD_CFLAGS += -Wsign-compare
> +KBUILD_CFLAGS += $(call cc-option, -Wmaybe-uninitialized)
> +KBUILD_CFLAGS += $(call cc-option, -Wunused-macros)
> +
> +endif
> +
> +#
> +# W=3 - more obscure warnings, can most likely be ignored
> +#
> +ifneq ($(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),)
> +
> +KBUILD_CFLAGS += -Wbad-function-cast
> +KBUILD_CFLAGS += -Wcast-qual
> +KBUILD_CFLAGS += -Wconversion
> +KBUILD_CFLAGS += -Wpacked
> +KBUILD_CFLAGS += -Wpadded
> +KBUILD_CFLAGS += -Wpointer-arith
> +KBUILD_CFLAGS += -Wredundant-decls
> +KBUILD_CFLAGS += -Wswitch-default
> +KBUILD_CFLAGS += $(call cc-option, -Wpacked-bitfield-compat)
> +
> endif
> --
> 2.17.1
>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2019-09-07 2:30 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-31 16:25 [PATCH v3 1/2] kbuild: refactor scripts/Makefile.extrawarn Masahiro Yamada
2019-08-31 16:25 ` [PATCH v3 2/2] kbuild: rename KBUILD_ENABLE_EXTRA_GCC_CHECKS to KBUILD_EXTRA_WARN Masahiro Yamada
2019-09-03 5:37 ` Nathan Chancellor
2019-09-03 21:50 ` Nick Desaulniers
2019-09-04 6:58 ` Sedat Dilek
2019-09-04 8:07 ` Sedat Dilek
2019-09-04 9:58 ` Sedat Dilek
2019-09-04 14:05 ` Masahiro Yamada
2019-09-04 21:46 ` [PATCH v3 1/2] kbuild: refactor scripts/Makefile.extrawarn Arnd Bergmann
2019-09-04 22:40 ` Nathan Chancellor
2019-09-05 8:06 ` Arnd Bergmann
2019-09-07 2:29 ` Masahiro Yamada
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).