Skip to content

Commit 550ccb1

Browse files
committed
Make 'cc-option' work correctly for the -Wno-xyzzy pattern
This is the follow-up to commit a79be02 ("Fix mis-uses of 'cc-option' for warning disablement") where I mentioned that the best fix would be to just make 'cc-option' a bit smarter, and work for all compiler options, including the '-Wno-xyzzy' pattern that it used to accept unknown options for. It turns out that fixing cc-option is pretty straightforward: just rewrite any '-Wno-xyzzy' option pattern to use '-Wxyzzy' instead for testing. That makes the whole artificial distinction between 'cc-option' and 'cc-disable-warning' go away, and we can happily forget about the odd build rule that you have to treat compiler options that disable warnings specially. The 'cc-disable-warning' helper remains as a backwards compatibility syntax for now, but is implemented in terms of the new and improved cc-option. Acked-by: Masahiro Yamada <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Stephen Rothwell <[email protected]> Cc: Thomas Weißschuh <[email protected]> Cc: Nathan Chancellor <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 015a99f commit 550ccb1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

scripts/Makefile.compiler

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ as-instr = $(call try-run,\
4343
# __cc-option
4444
# Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
4545
__cc-option = $(call try-run,\
46-
$(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4))
46+
$(1) -Werror $(2) $(3:-Wno-%=-W%) -c -x c /dev/null -o "$$TMP",$(3),$(4))
4747

4848
# cc-option
4949
# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
@@ -57,7 +57,7 @@ cc-option-yn = $(if $(call cc-option,$1),y,n)
5757

5858
# cc-disable-warning
5959
# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
60-
cc-disable-warning = $(if $(call cc-option,-W$(strip $1)),-Wno-$(strip $1))
60+
cc-disable-warning = $(call cc-option,-Wno-$(strip $1))
6161

6262
# gcc-min-version
6363
# Usage: cflags-$(call gcc-min-version, 70100) += -foo

0 commit comments

Comments
 (0)