diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2017-11-27 07:15:13 -0500 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2017-12-06 07:53:57 -0500 |
commit | cfe17c9bbe6a673fdafdab179c32b355ed447f66 (patch) | |
tree | a8829e79271018fedab3f8c4a8e1d5cc02a5903b /Makefile | |
parent | ae64f9bd1d3621b5e60d7363bc20afb46aede215 (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-- | Makefile | 43 |
1 files changed, 23 insertions, 20 deletions
@@ -484,26 +484,6 @@ CLANG_GCC_TC := --gcc-toolchain=$(GCC_TOOLCHAIN) | |||
484 | endif | 484 | endif |
485 | KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) | 485 | KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) |
486 | KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) | 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 | endif | 487 | endif |
508 | 488 | ||
509 | ifeq ($(config-targets),1) | 489 | ifeq ($(config-targets),1) |
@@ -716,6 +696,29 @@ ifdef CONFIG_CC_STACKPROTECTOR | |||
716 | endif | 696 | endif |
717 | KBUILD_CFLAGS += $(stackp-flag) | 697 | KBUILD_CFLAGS += $(stackp-flag) |
718 | 698 | ||
699 | ifeq ($(cc-name),clang) | ||
700 | KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,) | ||
701 | KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable) | ||
702 | KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier) | ||
703 | KBUILD_CFLAGS += $(call cc-disable-warning, gnu) | ||
704 | KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) | ||
705 | # Quiet clang warning: comparison of unsigned expression < 0 is always false | ||
706 | KBUILD_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 | ||
710 | KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,) | ||
711 | KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior) | ||
712 | KBUILD_CFLAGS += $(call cc-option, -no-integrated-as) | ||
713 | KBUILD_AFLAGS += $(call cc-option, -no-integrated-as) | ||
714 | else | ||
715 | |||
716 | # These warnings generated too much noise in a regular build. | ||
717 | # Use make W=1 to enable them (see scripts/Makefile.extrawarn) | ||
718 | KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) | ||
719 | KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) | ||
720 | endif | ||
721 | |||
719 | ifdef CONFIG_FRAME_POINTER | 722 | ifdef CONFIG_FRAME_POINTER |
720 | KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls | 723 | KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls |
721 | else | 724 | else |