]>
Commit | Line | Data |
---|---|---|
22b74881 GKH |
1 | From foo@baz Wed Nov 21 18:50:39 CET 2018 |
2 | From: Matthias Kaehlcke <mka@chromium.org> | |
3 | Date: Wed, 21 Jun 2017 16:28:03 -0700 | |
4 | Subject: kbuild: Add __cc-option macro | |
5 | ||
6 | From: Matthias Kaehlcke <mka@chromium.org> | |
7 | ||
8 | commit 9f3f1fd299768782465cb32cdf0dd4528d11f26b upstream. | |
9 | ||
10 | cc-option uses KBUILD_CFLAGS and KBUILD_CPPFLAGS when it determines | |
11 | whether an option is supported or not. This is fine for options used to | |
12 | build the kernel itself, however some components like the x86 boot code | |
13 | use a different set of flags. | |
14 | ||
15 | Add the new macro __cc-option which is a more generic version of | |
16 | cc-option with additional parameters. One parameter is the compiler | |
17 | with which the check should be performed, the other the compiler options | |
18 | to be used instead KBUILD_C*FLAGS. | |
19 | ||
20 | Refactor cc-option and hostcc-option to use __cc-option and move | |
21 | hostcc-option to scripts/Kbuild.include. | |
22 | ||
23 | Suggested-by: Arnd Bergmann <arnd@arndb.de> | |
24 | Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com> | |
25 | Signed-off-by: Matthias Kaehlcke <mka@chromium.org> | |
26 | Acked-by: Arnd Bergmann <arnd@arndb.de> | |
27 | Acked-by: Michal Marek <mmarek@suse.com> | |
28 | Signed-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] | |
31 | Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> | |
32 | Signed-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) |