]> git.baikalelectronics.ru Git - kernel.git/commit
kbuild: Check for unknown options with cc-option usage in Kconfig and clang
authorStephen Boyd <swboyd@chromium.org>
Tue, 30 Jul 2019 16:48:03 +0000 (09:48 -0700)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Wed, 31 Jul 2019 15:12:07 +0000 (00:12 +0900)
commit5461d267cc99bdca685c7dfe5ac957c88fd10b5d
treea78e8e42ec83c44c8d50215b5115c840775a59aa
parent1b2e98c2a407221fb2d98c1ac9075ff5694ee466
kbuild: Check for unknown options with cc-option usage in Kconfig and clang

If the particular version of clang a user has doesn't enable
-Werror=unknown-warning-option by default, even though it is the
default[1], then make sure to pass the option to the Kconfig cc-option
command so that testing options from Kconfig files works properly.
Otherwise, depending on the default values setup in the clang toolchain
we will silently assume options such as -Wmaybe-uninitialized are
supported by clang, when they really aren't.

A compilation issue only started happening for me once commit
8c585b8df2d2 ("kbuild: Add -Werror=unknown-warning-option to
CLANG_FLAGS") was applied on top of commit 1d87ce1ae1a7 ("kbuild:
compute false-positive -Wmaybe-uninitialized cases in Kconfig"). This
leads kbuild to try and test for the existence of the
-Wmaybe-uninitialized flag with the cc-option command in
scripts/Kconfig.include, and it doesn't see an error returned from the
option test so it sets the config value to Y. Then the Makefile tries to
pass the unknown option on the command line and
-Werror=unknown-warning-option catches the invalid option and breaks the
build. Before commit 8c585b8df2d2 ("kbuild: Add
-Werror=unknown-warning-option to CLANG_FLAGS") the build works fine,
but any cc-option test of a warning option in Kconfig files silently
evaluates to true, even if the warning option flag isn't supported on
clang.

Note: This doesn't change cc-option usages in Makefiles because those
use a different rule that includes KBUILD_CFLAGS by default (see the
__cc-option command in scripts/Kbuild.incluide). The KBUILD_CFLAGS
variable already has the -Werror=unknown-warning-option flag set. Thanks
to Doug for pointing out the different rule.

[1] https://clang.llvm.org/docs/DiagnosticsReference.html#wunknown-warning-option
Cc: Peter Smith <peter.smith@linaro.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
scripts/Kconfig.include