diff mbox

[v2,2/4] kbuild: Add hostcc-option macro

Message ID 20170613230854.112282-3-mka@chromium.org (mailing list archive)
State New, archived
Headers show

Commit Message

Matthias Kaehlcke June 13, 2017, 11:08 p.m. UTC
hostcc-option is equivalent to cc-option, but uses the host compiler
and HOSTCFLAGS. Change HOSTCFLAGS to a simple expanded variable to
allow for HOSTCFLAGS += $(call hostcc-option, ...).

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
Changes in v2:
- Patch added in v2

 Makefile               | 2 +-
 scripts/Kbuild.include | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

Comments

Masahiro Yamada June 14, 2017, 1:28 a.m. UTC | #1
2017-06-14 8:08 GMT+09:00 Matthias Kaehlcke <mka@chromium.org>:
> hostcc-option is equivalent to cc-option, but uses the host compiler
> and HOSTCFLAGS. Change HOSTCFLAGS to a simple expanded variable to
> allow for HOSTCFLAGS += $(call hostcc-option, ...).
>
> 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: Masahiro Yamada <yamada.masahiro@socionext.com>
Arnd Bergmann June 14, 2017, 7:26 a.m. UTC | #2
On Wed, Jun 14, 2017 at 1:08 AM, Matthias Kaehlcke <mka@chromium.org> wrote:
> hostcc-option is equivalent to cc-option, but uses the host compiler
> and HOSTCFLAGS. Change HOSTCFLAGS to a simple expanded variable to
> allow for HOSTCFLAGS += $(call hostcc-option, ...).
>
> Suggested-by: Arnd Bergmann <arnd@arndb.de>
> Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>

Actually, we already have a hostcc-option macro. What I meant with my suggestion
was that we could redefine the existing one using cc-option-raw.

I checked again now and found that while this was added in 2016 by
Emese Revfy, we apparently don't have any users of the helper in the
kernel.

      Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Masahiro Yamada June 14, 2017, 7:40 a.m. UTC | #3
Hi Arnd,


2017-06-14 16:26 GMT+09:00 Arnd Bergmann <arnd@arndb.de>:
> On Wed, Jun 14, 2017 at 1:08 AM, Matthias Kaehlcke <mka@chromium.org> wrote:
>> hostcc-option is equivalent to cc-option, but uses the host compiler
>> and HOSTCFLAGS. Change HOSTCFLAGS to a simple expanded variable to
>> allow for HOSTCFLAGS += $(call hostcc-option, ...).
>>
>> Suggested-by: Arnd Bergmann <arnd@arndb.de>
>> Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
>
> Actually, we already have a hostcc-option macro. What I meant with my suggestion
> was that we could redefine the existing one using cc-option-raw.
>
> I checked again now and found that while this was added in 2016 by
> Emese Revfy, we apparently don't have any users of the helper in the
> kernel.


Oops, I missed it because
it is defined in scripts/Makefile.host instead of scripts/Kbuild.include


$(call cc-option, ...) is generally used in the top Makefile (or
arch/*/Makefile).


However, scripts/Makefile.host is not included from the top Makefile,
so $(call hostcc-option, ...) is available only under sub-directories.
I guess that is why we had no user of it.

I think the right thing to do
is to remove the former implementation from Makefile.host

Thanks!
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 83f6d9972cab..b234bba6d652 100644
--- a/Makefile
+++ b/Makefile
@@ -303,7 +303,7 @@  CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
 
 HOSTCC       = gcc
 HOSTCXX      = g++
-HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
+HOSTCFLAGS   := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
 HOSTCXXFLAGS = -O2
 
 ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 6dd0d1a921d6..4965ed92fc1e 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -123,6 +123,10 @@  CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
 cc-option = $(call cc-option-raw, $(CC), $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS),\
 	$(1), $(2))
 
+# hostcc-option
+# Usage: HOSTCFLAGS += $(call hostcc-option, -fno-delete-null-pointer-checks,)
+hostcc-option = $(call cc-option-raw, $(HOSTCC), $(HOSTCFLAGS), $(1), $(2))
+
 # cc-option-yn
 # Usage: flag := $(call cc-option-yn,-march=winchip-c6)
 cc-option-yn = $(call try-run,\