summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2017-11-27 07:15:13 -0500
committerMasahiro Yamada <yamada.masahiro@socionext.com>2017-12-06 07:53:57 -0500
commitcfe17c9bbe6a673fdafdab179c32b355ed447f66 (patch)
treea8829e79271018fedab3f8c4a8e1d5cc02a5903b /Makefile
parentae64f9bd1d3621b5e60d7363bc20afb46aede215 (diff)
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>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile43
1 files changed, 23 insertions, 20 deletions
diff --git a/Makefile b/Makefile
index c988e46a53cd..477c4cf01cae 100644
--- a/Makefile
+++ b/Makefile
@@ -484,26 +484,6 @@ CLANG_GCC_TC := --gcc-toolchain=$(GCC_TOOLCHAIN)
484endif 484endif
485KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) 485KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
486KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) 486KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
487KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
488KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
489KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
490KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
491KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
492# Quiet clang warning: comparison of unsigned expression < 0 is always false
493KBUILD_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
497KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
498KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
499KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
500KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
501else
502
503# These warnings generated too much noise in a regular build.
504# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
505KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
506KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
507endif 487endif
508 488
509ifeq ($(config-targets),1) 489ifeq ($(config-targets),1)
@@ -716,6 +696,29 @@ ifdef CONFIG_CC_STACKPROTECTOR
716endif 696endif
717KBUILD_CFLAGS += $(stackp-flag) 697KBUILD_CFLAGS += $(stackp-flag)
718 698
699ifeq ($(cc-name),clang)
700KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
701KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
702KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
703KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
704KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
705# Quiet clang warning: comparison of unsigned expression < 0 is always false
706KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
707# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
708# source of a reference will be _MergedGlobals and not on of the whitelisted names.
709# See modpost pattern 2
710KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
711KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
712KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
713KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
714else
715
716# These warnings generated too much noise in a regular build.
717# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
718KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
719KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
720endif
721
719ifdef CONFIG_FRAME_POINTER 722ifdef CONFIG_FRAME_POINTER
720KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls 723KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
721else 724else