diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2019-02-20 23:13:38 -0500 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2019-02-27 07:43:20 -0500 |
commit | b303c6df80c9f8f13785aa83a0471fca7e38b24d (patch) | |
tree | e5115e2524486b8633a4d024e9a1d2761f3c181f /init | |
parent | bd55f96fa9fc29702ec30d75a4290bdadb00209d (diff) |
kbuild: compute false-positive -Wmaybe-uninitialized cases in Kconfig
Since -Wmaybe-uninitialized was introduced by GCC 4.7, we have patched
various false positives:
- commit e74fc973b6e5 ("Turn off -Wmaybe-uninitialized when building
with -Os") turned off this option for -Os.
- commit 815eb71e7149 ("Kbuild: disable 'maybe-uninitialized' warning
for CONFIG_PROFILE_ALL_BRANCHES") turned off this option for
CONFIG_PROFILE_ALL_BRANCHES
- commit a76bcf557ef4 ("Kbuild: enable -Wmaybe-uninitialized warning
for "make W=1"") turned off this option for GCC < 4.9
Arnd provided more explanation in https://lkml.org/lkml/2017/3/14/903
I think this looks better by shifting the logic from Makefile to Kconfig.
Link: https://github.com/ClangBuiltLinux/linux/issues/350
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Diffstat (limited to 'init')
-rw-r--r-- | init/Kconfig | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/init/Kconfig b/init/Kconfig index 513fa544a134..ce43083b681d 100644 --- a/init/Kconfig +++ b/init/Kconfig | |||
@@ -26,6 +26,22 @@ config CLANG_VERSION | |||
26 | config CC_HAS_ASM_GOTO | 26 | config CC_HAS_ASM_GOTO |
27 | def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC)) | 27 | def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC)) |
28 | 28 | ||
29 | config CC_HAS_WARN_MAYBE_UNINITIALIZED | ||
30 | def_bool $(cc-option,-Wmaybe-uninitialized) | ||
31 | help | ||
32 | GCC >= 4.7 supports this option. | ||
33 | |||
34 | config CC_DISABLE_WARN_MAYBE_UNINITIALIZED | ||
35 | bool | ||
36 | depends on CC_HAS_WARN_MAYBE_UNINITIALIZED | ||
37 | default CC_IS_GCC && GCC_VERSION < 40900 # unreliable for GCC < 4.9 | ||
38 | help | ||
39 | GCC's -Wmaybe-uninitialized is not reliable by definition. | ||
40 | Lots of false positive warnings are produced in some cases. | ||
41 | |||
42 | If this option is enabled, -Wno-maybe-uninitialzed is passed | ||
43 | to the compiler to suppress maybe-uninitialized warnings. | ||
44 | |||
29 | config CONSTRUCTORS | 45 | config CONSTRUCTORS |
30 | bool | 46 | bool |
31 | depends on !UML | 47 | depends on !UML |
@@ -1102,6 +1118,7 @@ config CC_OPTIMIZE_FOR_PERFORMANCE | |||
1102 | 1118 | ||
1103 | config CC_OPTIMIZE_FOR_SIZE | 1119 | config CC_OPTIMIZE_FOR_SIZE |
1104 | bool "Optimize for size" | 1120 | bool "Optimize for size" |
1121 | imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives | ||
1105 | help | 1122 | help |
1106 | Enabling this option will pass "-Os" instead of "-O2" to | 1123 | Enabling this option will pass "-Os" instead of "-O2" to |
1107 | your compiler resulting in a smaller kernel. | 1124 | your compiler resulting in a smaller kernel. |