Skip to content

Commit cfe17c9

Browse files
committed
kbuild: move cc-option and cc-disable-warning after incl. arch Makefile
Geert reported commit ae6b289 ("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: ae6b289 ("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>
1 parent ae64f9b commit cfe17c9

1 file changed

Lines changed: 23 additions & 20 deletions

File tree

‎Makefile‎

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -484,26 +484,6 @@ CLANG_GCC_TC := --gcc-toolchain=$(GCC_TOOLCHAIN)
484484
endif
485485
KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
486486
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)
507487
endif
508488

509489
ifeq ($(config-targets),1)
@@ -716,6 +696,29 @@ ifdef CONFIG_CC_STACKPROTECTOR
716696
endif
717697
KBUILD_CFLAGS += $(stackp-flag)
718698

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+
719722
ifdef CONFIG_FRAME_POINTER
720723
KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
721724
else

0 commit comments

Comments
 (0)