Skip to content

Commit c3f0d0b

Browse files
mcharlebmasahir0y
authored andcommitted
kbuild, LLVMLinux: Add -Werror to cc-option to support clang
Clang will warn about unknown warnings but will not return false unless -Werror is set. GCC will return false if an unknown warning is passed. Adding -Werror make both compiler behave the same. [arnd: it turns out we need the same patch for testing whether -ffunction-sections works right with gcc. I've build tested extensively with this patch applied, so let's just merge this one now.] Signed-off-by: Mark Charlebois <charlebm@gmail.com> Signed-off-by: Behan Webster <behanw@converseincode.com> Reviewed-by: Jan-Simon Möller <dl9pf@gmx.de> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Kees Cook <keescook@chromium.org> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
1 parent c834f0e commit c3f0d0b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

scripts/Kbuild.include

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
116116
# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
117117

118118
cc-option = $(call try-run,\
119-
$(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
119+
$(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
120120

121121
# cc-option-yn
122122
# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
123123
cc-option-yn = $(call try-run,\
124-
$(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
124+
$(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
125125

126126
# cc-option-align
127127
# Prefix align with either -falign or -malign
@@ -131,7 +131,7 @@ cc-option-align = $(subst -functions=0,,\
131131
# cc-disable-warning
132132
# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
133133
cc-disable-warning = $(call try-run,\
134-
$(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
134+
$(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
135135

136136
# cc-name
137137
# Expands to either gcc or clang

0 commit comments

Comments
 (0)