]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.165/kbuild-add-__cc-option-macro.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.4.165 / kbuild-add-__cc-option-macro.patch
CommitLineData
22b74881
GKH
1From foo@baz Wed Nov 21 18:50:39 CET 2018
2From: Matthias Kaehlcke <mka@chromium.org>
3Date: Wed, 21 Jun 2017 16:28:03 -0700
4Subject: kbuild: Add __cc-option macro
5
6From: Matthias Kaehlcke <mka@chromium.org>
7
8commit 9f3f1fd299768782465cb32cdf0dd4528d11f26b upstream.
9
10cc-option uses KBUILD_CFLAGS and KBUILD_CPPFLAGS when it determines
11whether an option is supported or not. This is fine for options used to
12build the kernel itself, however some components like the x86 boot code
13use a different set of flags.
14
15Add the new macro __cc-option which is a more generic version of
16cc-option with additional parameters. One parameter is the compiler
17with which the check should be performed, the other the compiler options
18to be used instead KBUILD_C*FLAGS.
19
20Refactor cc-option and hostcc-option to use __cc-option and move
21hostcc-option to scripts/Kbuild.include.
22
23Suggested-by: Arnd Bergmann <arnd@arndb.de>
24Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
25Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
26Acked-by: Arnd Bergmann <arnd@arndb.de>
27Acked-by: Michal Marek <mmarek@suse.com>
28Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
29[nc: Fix conflicts due to lack of CC_OPTION_CFLAGS and hostcc-option
30 wasn't added until v4.8 so no point including it in this tree]
31Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
32Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
33---
34 Makefile | 2 +-
35 scripts/Kbuild.include | 9 +++++++--
36 2 files changed, 8 insertions(+), 3 deletions(-)
37
38--- a/Makefile
39+++ b/Makefile
40@@ -303,7 +303,7 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH"
41
42 HOSTCC = gcc
43 HOSTCXX = g++
44-HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
45+HOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
46 HOSTCXXFLAGS = -O2
47
48 # Decide whether to build built-in, modular, or both.
49--- a/scripts/Kbuild.include
50+++ b/scripts/Kbuild.include
51@@ -108,11 +108,16 @@ as-option = $(call try-run,\
52 as-instr = $(call try-run,\
53 printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
54
55+# __cc-option
56+# Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
57+__cc-option = $(call try-run,\
58+ $(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4))
59+
60 # cc-option
61 # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
62
63-cc-option = $(call try-run,\
64- $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
65+cc-option = $(call __cc-option, $(CC),\
66+ $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS),$(1),$(2))
67
68 # cc-option-yn
69 # Usage: flag := $(call cc-option-yn,-march=winchip-c6)