summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMatthias Kaehlcke <mka@chromium.org>2017-06-21 19:28:03 -0400
committerMasahiro Yamada <yamada.masahiro@socionext.com>2017-06-24 23:47:55 -0400
commit9f3f1fd299768782465cb32cdf0dd4528d11f26b (patch)
tree844070b5fac455e1bad324587a3d02c55f9fdbcc /scripts
parent39a33ff80a259b2bddebb236549baee55f9b4f41 (diff)
kbuild: Add __cc-option macro
cc-option uses KBUILD_CFLAGS and KBUILD_CPPFLAGS when it determines whether an option is supported or not. This is fine for options used to build the kernel itself, however some components like the x86 boot code use a different set of flags. Add the new macro __cc-option which is a more generic version of cc-option with additional parameters. One parameter is the compiler with which the check should be performed, the other the compiler options to be used instead KBUILD_C*FLAGS. Refactor cc-option and hostcc-option to use __cc-option and move hostcc-option to scripts/Kbuild.include. Suggested-by: Arnd Bergmann <arnd@arndb.de> Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Matthias Kaehlcke <mka@chromium.org> Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Michal Marek <mmarek@suse.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Kbuild.include14
-rw-r--r--scripts/Makefile.host6
2 files changed, 12 insertions, 8 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 53b7d47ce43a..dd8e2dde0b34 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -108,6 +108,11 @@ as-option = $(call try-run,\
108as-instr = $(call try-run,\ 108as-instr = $(call try-run,\
109 printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3)) 109 printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
110 110
111# __cc-option
112# Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)
113__cc-option = $(call try-run,\
114 $(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4))
115
111# Do not attempt to build with gcc plugins during cc-option tests. 116# Do not attempt to build with gcc plugins during cc-option tests.
112# (And this uses delayed resolution so the flags will be up to date.) 117# (And this uses delayed resolution so the flags will be up to date.)
113CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS)) 118CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
@@ -115,8 +120,13 @@ CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
115# cc-option 120# cc-option
116# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) 121# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
117 122
118cc-option = $(call try-run,\ 123cc-option = $(call __cc-option, $(CC),\
119 $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2)) 124 $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS),$(1),$(2))
125
126# hostcc-option
127# Usage: cflags-y += $(call hostcc-option,-march=winchip-c6,-march=i586)
128hostcc-option = $(call __cc-option, $(HOSTCC),\
129 $(HOSTCFLAGS) $(HOST_EXTRACFLAGS),$(1),$(2))
120 130
121# cc-option-yn 131# cc-option-yn
122# Usage: flag := $(call cc-option-yn,-march=winchip-c6) 132# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 45b5b1aaedbd..9cfd5c84d76f 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -20,12 +20,6 @@
20# Will compile qconf as a C++ program, and menu as a C program. 20# Will compile qconf as a C++ program, and menu as a C program.
21# They are linked as C++ code to the executable qconf 21# They are linked as C++ code to the executable qconf
22 22
23# hostcc-option
24# Usage: cflags-y += $(call hostcc-option,-march=winchip-c6,-march=i586)
25
26hostcc-option = $(call try-run,\
27 $(HOSTCC) $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
28
29__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m)) 23__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
30host-cshlib := $(sort $(hostlibs-y) $(hostlibs-m)) 24host-cshlib := $(sort $(hostlibs-y) $(hostlibs-m))
31host-cxxshlib := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m)) 25host-cxxshlib := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))