kbuild: move cc-option and cc-disable-warning after incl. arch Makefile

Geert reported commit ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before
incl. arch Makefile") broke cross-compilation using a cross-compiler
that supports less compiler options than the host compiler.

For example,

cc1: error: unrecognized command line option "-Wno-unused-but-set-variable"

This problem happens on architectures that setup CROSS_COMPILE in their
arch/*/Makefile.

Move the cc-option and cc-disable-warning back to the original position,
but keep the Clang target options untouched.

Fixes: ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before incl. arch Makefile")
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>

+23 -20
+23 -20
Makefile
··· 484 484 endif 485 485 KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) 486 486 KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) 487 - KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,) 488 - KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable) 489 - KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier) 490 - KBUILD_CFLAGS += $(call cc-disable-warning, gnu) 491 - KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) 492 - # Quiet clang warning: comparison of unsigned expression < 0 is always false 493 - KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare) 494 - # CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the 495 - # source of a reference will be _MergedGlobals and not on of the whitelisted names. 496 - # See modpost pattern 2 497 - KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,) 498 - KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior) 499 - KBUILD_CFLAGS += $(call cc-option, -no-integrated-as) 500 - KBUILD_AFLAGS += $(call cc-option, -no-integrated-as) 501 - else 502 - 503 - # These warnings generated too much noise in a regular build. 504 - # Use make W=1 to enable them (see scripts/Makefile.extrawarn) 505 - KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) 506 - KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) 507 487 endif 508 488 509 489 ifeq ($(config-targets),1) ··· 695 715 stackp-check := $(wildcard $(stackp-path)) 696 716 endif 697 717 KBUILD_CFLAGS += $(stackp-flag) 718 + 719 + ifeq ($(cc-name),clang) 720 + KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,) 721 + KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable) 722 + KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier) 723 + KBUILD_CFLAGS += $(call cc-disable-warning, gnu) 724 + KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) 725 + # Quiet clang warning: comparison of unsigned expression < 0 is always false 726 + KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare) 727 + # CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the 728 + # source of a reference will be _MergedGlobals and not on of the whitelisted names. 729 + # See modpost pattern 2 730 + KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,) 731 + KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior) 732 + KBUILD_CFLAGS += $(call cc-option, -no-integrated-as) 733 + KBUILD_AFLAGS += $(call cc-option, -no-integrated-as) 734 + else 735 + 736 + # These warnings generated too much noise in a regular build. 737 + # Use make W=1 to enable them (see scripts/Makefile.extrawarn) 738 + KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) 739 + KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) 740 + endif 698 741 699 742 ifdef CONFIG_FRAME_POINTER 700 743 KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls