diff mbox series

[RESEND] bpfilter: check compiler capability in Kconfig

Message ID 1529985336-27522-1-git-send-email-yamada.masahiro@socionext.com
State Accepted
Commit 88e85a7daf8e21f2d6cb054374d480c540725cde
Headers show
Series [RESEND] bpfilter: check compiler capability in Kconfig | expand

Commit Message

Masahiro Yamada June 26, 2018, 3:55 a.m. UTC
With the brand-new syntax extension of Kconfig, we can directly
check the compiler capability in the configuration phase.

If the cc-can-link.sh fails, the BPFILTER_UMH is automatically
hidden by the dependency.

I also deleted 'default n', which is no-op.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

---

 Makefile               | 5 -----
 net/Makefile           | 4 ----
 net/bpfilter/Kconfig   | 2 +-
 scripts/cc-can-link.sh | 2 +-
 4 files changed, 2 insertions(+), 11 deletions(-)

-- 
2.7.4

Comments

Daniel Borkmann June 26, 2018, 10:29 a.m. UTC | #1
On 06/26/2018 05:55 AM, Masahiro Yamada wrote:
> With the brand-new syntax extension of Kconfig, we can directly

> check the compiler capability in the configuration phase.

> 

> If the cc-can-link.sh fails, the BPFILTER_UMH is automatically

> hidden by the dependency.

> 

> I also deleted 'default n', which is no-op.

> 

> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Alexei Starovoitov June 28, 2018, 2:05 a.m. UTC | #2
On Tue, Jun 26, 2018 at 12:55:35PM +0900, Masahiro Yamada wrote:
> With the brand-new syntax extension of Kconfig, we can directly

> check the compiler capability in the configuration phase.

> 

> If the cc-can-link.sh fails, the BPFILTER_UMH is automatically

> hidden by the dependency.

> 

> I also deleted 'default n', which is no-op.

> 

> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


I haven't tested it yet, but looks good to me as well.
Thank you for the follow up.
Acked-by: Alexei Starovoitov <ast@kernel.org>
David Miller June 28, 2018, 4:37 a.m. UTC | #3
From: Masahiro Yamada <yamada.masahiro@socionext.com>

Date: Tue, 26 Jun 2018 12:55:35 +0900

> With the brand-new syntax extension of Kconfig, we can directly

> check the compiler capability in the configuration phase.

> 

> If the cc-can-link.sh fails, the BPFILTER_UMH is automatically

> hidden by the dependency.

> 

> I also deleted 'default n', which is no-op.

> 

> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


Applied, thank you.
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index a6d4872..f71ea52 100644
--- a/Makefile
+++ b/Makefile
@@ -520,11 +520,6 @@  ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLA
   KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
 endif
 
-ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/cc-can-link.sh $(CC)), y)
-  CC_CAN_LINK := y
-  export CC_CAN_LINK
-endif
-
 # The expansion should be delayed until arch/$(SRCARCH)/Makefile is included.
 # Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile.
 # CC_VERSION_TEXT is referenced from Kconfig (so it needs export),
diff --git a/net/Makefile b/net/Makefile
index 13ec0d5..bdaf539 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -20,11 +20,7 @@  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/Kconfig b/net/bpfilter/Kconfig
index a948b07..76deb66 100644
--- a/net/bpfilter/Kconfig
+++ b/net/bpfilter/Kconfig
@@ -1,6 +1,5 @@ 
 menuconfig BPFILTER
 	bool "BPF based packet filtering framework (BPFILTER)"
-	default n
 	depends on NET && BPF && INET
 	help
 	  This builds experimental bpfilter framework that is aiming to
@@ -9,6 +8,7 @@  menuconfig BPFILTER
 if BPFILTER
 config BPFILTER_UMH
 	tristate "bpfilter kernel module with user mode helper"
+	depends on $(success,$(srctree)/scripts/cc-can-link.sh $(CC))
 	default m
 	help
 	  This builds bpfilter kernel module with embedded user mode helper
diff --git a/scripts/cc-can-link.sh b/scripts/cc-can-link.sh
index 208eb28..6efcead 100755
--- a/scripts/cc-can-link.sh
+++ b/scripts/cc-can-link.sh
@@ -1,7 +1,7 @@ 
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0
 
-cat << "END" | $@ -x c - -o /dev/null >/dev/null 2>&1 && echo "y"
+cat << "END" | $@ -x c - -o /dev/null >/dev/null 2>&1
 #include <stdio.h>
 int main(void)
 {