Skip to content

Commit e2079e9

Browse files
nathanchancemasahir0y
authored andcommitted
kbuild: Do not enable -Wimplicit-fallthrough for clang for now
This functionally reverts commit bfd7714 ("Makefile: Convert -Wimplicit-fallthrough=3 to just -Wimplicit-fallthrough for clang"). clang enabled support for -Wimplicit-fallthrough in C in r369414 [1], which causes a lot of warnings when building the kernel for two reasons: 1. Clang does not support the /* fall through */ comments. There seems to be a general consensus in the LLVM community that this is not something they want to support. Joe Perches wrote a script to convert all of the comments to a "fallthrough" keyword that will be added to compiler_attributes.h [2] [3], which catches the vast majority of the comments. There doesn't appear to be any consensus in the kernel community when to do this conversion. 2. Clang and GCC disagree about falling through to final case statements with no content or cases that simply break: https://godbolt.org/z/c8csDu This difference contributes at least 50 warnings in an allyesconfig build for x86, not considering other architectures. This difference will need to be discussed to see which compiler is right [4] [5]. [1]: llvm/llvm-project@1e0affb [2]: https://lore.kernel.org/lkml/[email protected]/ [3]: https://lore.kernel.org/lkml/1d2830aadbe9d8151728a7df5b88528fc72a0095.1564549413.git.joe@perches.com/ [4]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91432 [5]: ClangBuiltLinux#636 Given these two problems need discussion and coordination, do not enable -Wimplicit-fallthrough with clang right now. Add a comment to explain what is going on as well. This commit should be reverted once these two issues are fully flushed out and resolved. Suggested-by: Masahiro Yamada <[email protected]> Signed-off-by: Nathan Chancellor <[email protected]> Acked-by: Miguel Ojeda <[email protected]> Acked-by: Nick Desaulniers <[email protected]> Acked-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 4ca7694 commit e2079e9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,11 @@ else
774774
# These warnings generated too much noise in a regular build.
775775
# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
776776
KBUILD_CFLAGS += -Wno-unused-but-set-variable
777+
778+
# Warn about unmarked fall-throughs in switch statement.
779+
# Disabled for clang while comment to attribute conversion happens and
780+
# https://github.com/ClangBuiltLinux/linux/issues/636 is discussed.
781+
KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,)
777782
endif
778783

779784
KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
@@ -868,9 +873,6 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
868873
# warn about C99 declaration after statement
869874
KBUILD_CFLAGS += -Wdeclaration-after-statement
870875

871-
# Warn about unmarked fall-throughs in switch statement.
872-
KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,)
873-
874876
# Variable Length Arrays (VLAs) should not be used anywhere in the kernel
875877
KBUILD_CFLAGS += -Wvla
876878

0 commit comments

Comments
 (0)