From: Alexei Starovoitov Date: Tue, 5 Jun 2018 02:53:41 +0000 (-0700) Subject: bpfilter: switch to CC from HOSTCC X-Git-Tag: v4.19~872^2~20 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=819dd92b9c0bc7bce9097d8c1f14240f471bb386;p=platform%2Fkernel%2Flinux-rpi3.git bpfilter: switch to CC from HOSTCC check that CC can build executables and use that compiler instead of HOSTCC Suggested-by: Arnd Bergmann Signed-off-by: Alexei Starovoitov Signed-off-by: David S. Miller --- diff --git a/Makefile b/Makefile index 56ba070..62c1100 100644 --- a/Makefile +++ b/Makefile @@ -510,6 +510,11 @@ ifeq ($(call shell-cached,$(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $ KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO endif +ifeq ($(call shell-cached,$(CONFIG_SHELL) $(srctree)/scripts/cc-can-link.sh $(CC)), y) + CC_CAN_LINK := y + export CC_CAN_LINK +endif + ifeq ($(config-targets),1) # =========================================================================== # *config targets only - make sure prerequisites are updated, and descend diff --git a/net/Makefile b/net/Makefile index bdaf539..13ec0d5 100644 --- a/net/Makefile +++ b/net/Makefile @@ -20,7 +20,11 @@ obj-$(CONFIG_TLS) += tls/ obj-$(CONFIG_XFRM) += xfrm/ obj-$(CONFIG_UNIX) += unix/ obj-$(CONFIG_NET) += ipv6/ +ifneq ($(CC_CAN_LINK),y) +$(warning CC cannot link executables. Skipping bpfilter.) +else obj-$(CONFIG_BPFILTER) += bpfilter/ +endif obj-$(CONFIG_PACKET) += packet/ obj-$(CONFIG_NET_KEY) += key/ obj-$(CONFIG_BRIDGE) += bridge/ diff --git a/net/bpfilter/Makefile b/net/bpfilter/Makefile index 3f3cb87..aafa720 100644 --- a/net/bpfilter/Makefile +++ b/net/bpfilter/Makefile @@ -6,6 +6,8 @@ hostprogs-y := bpfilter_umh bpfilter_umh-objs := main.o HOSTCFLAGS += -I. -Itools/include/ -Itools/include/uapi +HOSTCC := $(CC) + ifeq ($(CONFIG_BPFILTER_UMH), y) # builtin bpfilter_umh should be compiled with -static # since rootfs isn't mounted at the time of __init diff --git a/scripts/cc-can-link.sh b/scripts/cc-can-link.sh new file mode 100755 index 0000000..208eb28 --- /dev/null +++ b/scripts/cc-can-link.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +cat << "END" | $@ -x c - -o /dev/null >/dev/null 2>&1 && echo "y" +#include +int main(void) +{ + printf(""); + return 0; +} +END