]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.165/kbuild-move-cc-option-and-cc-disable-warning-after-incl.-arch-makefile.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.4.165 / kbuild-move-cc-option-and-cc-disable-warning-after-incl.-arch-makefile.patch
1 From foo@baz Wed Nov 21 18:50:39 CET 2018
2 From: Masahiro Yamada <yamada.masahiro@socionext.com>
3 Date: Mon, 27 Nov 2017 21:15:13 +0900
4 Subject: kbuild: move cc-option and cc-disable-warning after incl. arch Makefile
5
6 From: Masahiro Yamada <yamada.masahiro@socionext.com>
7
8 commit cfe17c9bbe6a673fdafdab179c32b355ed447f66 upstream.
9
10 Geert reported commit ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before
11 incl. arch Makefile") broke cross-compilation using a cross-compiler
12 that supports less compiler options than the host compiler.
13
14 For example,
15
16 cc1: error: unrecognized command line option "-Wno-unused-but-set-variable"
17
18 This problem happens on architectures that setup CROSS_COMPILE in their
19 arch/*/Makefile.
20
21 Move the cc-option and cc-disable-warning back to the original position,
22 but keep the Clang target options untouched.
23
24 Fixes: ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before incl. arch Makefile")
25 Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
26 Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
27 Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
28 [nc: Adjust context]
29 Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
30 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
31 ---
32 Makefile | 43 +++++++++++++++++++++++--------------------
33 1 file changed, 23 insertions(+), 20 deletions(-)
34
35 --- a/Makefile
36 +++ b/Makefile
37 @@ -622,26 +622,6 @@ CLANG_GCC_TC := -gcc-toolchain $(GCC_TOO
38 endif
39 KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
40 KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
41 -KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
42 -KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
43 -KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
44 -KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
45 -KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
46 -# Quiet clang warning: comparison of unsigned expression < 0 is always false
47 -KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
48 -# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
49 -# source of a reference will be _MergedGlobals and not on of the whitelisted names.
50 -# See modpost pattern 2
51 -KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
52 -KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
53 -KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
54 -KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
55 -else
56 -
57 -# These warnings generated too much noise in a regular build.
58 -# Use make W=1 to enable them (see scripts/Makefile.build)
59 -KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
60 -KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
61 endif
62
63 # The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
64 @@ -729,6 +709,29 @@ endif
65 endif
66 KBUILD_CFLAGS += $(stackp-flag)
67
68 +ifeq ($(cc-name),clang)
69 +KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
70 +KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
71 +KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
72 +KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
73 +KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
74 +# Quiet clang warning: comparison of unsigned expression < 0 is always false
75 +KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
76 +# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
77 +# source of a reference will be _MergedGlobals and not on of the whitelisted names.
78 +# See modpost pattern 2
79 +KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
80 +KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
81 +KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
82 +KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
83 +else
84 +
85 +# These warnings generated too much noise in a regular build.
86 +# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
87 +KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
88 +KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
89 +endif
90 +
91 ifdef CONFIG_FRAME_POINTER
92 KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
93 else