netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] bpf: fix compilation of samples/bpf/
@ 2018-07-07 14:52 Constantine Shulyupin
  2018-07-07 22:49 ` Alexei Starovoitov
  0 siblings, 1 reply; 2+ messages in thread
From: Constantine Shulyupin @ 2018-07-07 14:52 UTC (permalink / raw)
  To: jakub.kicinski, Masahiro Yamada, Michal Marek, Alexei Starovoitov,
	Daniel Borkmann, open list,
	open list:BPF (Safe dynamic programs and tools)
  Cc: Constantine Shulyupin

Example of errors:

samples/bpf/test_lru_dist.c:39:8: error: redefinition of ‘struct list_head’
 struct list_head {
        ^~~~~~~~~
In file included from samples/bpf/test_lru_dist.c:9:0:
./tools/include/linux/types.h:69:8: note: originally defined here

In file included from samples/bpf/sock_example.c:27:0:
/usr/include/linux/ip.h:102:2: error: unknown type name ‘__sum16’

samples/bpf/bpf_load.c: In function ‘load_and_attach’:
samples/bpf/bpf_load.c:90:15: error: ‘BPF_PROG_TYPE_RAW_TRACEPOINT’ undeclared (first use in this function); did you mean ‘BPF_PROG_TYPE_TRACEPOINT’?

samples/bpf/xdpsock_user.c:10:10: fatal error: linux/if_xdp.h: No such file or directory

samples/bpf/task_fd_query_user.c: In function ‘test_debug_fs_uprobe’:
samples/bpf/task_fd_query_user.c:270:31: error: ‘BPF_FD_TYPE_URETPROBE’ undeclared (first use in this function); did you mean ‘BPF_PROG_TYPE_KPROBE’?

samples/bpf/parse_varlen.c:111:8: error: redefinition of 'vlan_hdr'
struct vlan_hdr {
       ^
./include/linux/if_vlan.h:38:8: note: previous definition is here

Signed-off-by: Constantine Shulyupin <const@MakeLinux.com>
---
 Makefile                           | 1 +
 samples/bpf/Makefile               | 5 +++--
 samples/bpf/xdp_sample_pkts_user.c | 3 +++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index d15ac32afbaf..824006258319 100644
--- a/Makefile
+++ b/Makefile
@@ -441,6 +441,7 @@ export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
 export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
 export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
 export KBUILD_ARFLAGS
+export USERINCLUDE
 
 # When compiling out-of-tree modules, put MODVERDIR in the module
 # tree rather than in the kernel tree. The kernel tree might
diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 9ea2f7b64869..991273c81459 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -167,11 +167,12 @@ always += xdp_fwd_kern.o
 always += task_fd_query_kern.o
 always += xdp_sample_pkts_kern.o
 
-HOSTCFLAGS += -I$(objtree)/usr/include
+HOSTCFLAGS += -D__EXPORTED_HEADERS__ $(USERINCLUDE)
 HOSTCFLAGS += -I$(srctree)/tools/lib/
 HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
-HOSTCFLAGS += -I$(srctree)/tools/lib/ -I$(srctree)/tools/include
+HOSTCFLAGS += -I$(srctree)/tools/include
 HOSTCFLAGS += -I$(srctree)/tools/perf
+HOSTCFLAGS += -I./include # for generated/autoconf.h from USERINCLUDE
 
 HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
 HOSTCFLAGS_trace_helpers.o += -I$(srctree)/tools/lib/bpf/
diff --git a/samples/bpf/xdp_sample_pkts_user.c b/samples/bpf/xdp_sample_pkts_user.c
index 8dd87c1eb560..be7329697500 100644
--- a/samples/bpf/xdp_sample_pkts_user.c
+++ b/samples/bpf/xdp_sample_pkts_user.c
@@ -15,6 +15,9 @@
 
 #include "perf-sys.h"
 #include "trace_helpers.h"
+#ifndef __packed
+#define __packed __attribute__((packed))
+#endif
 
 #define MAX_CPUS 128
 static int pmu_fds[MAX_CPUS], if_idx;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] bpf: fix compilation of samples/bpf/
  2018-07-07 14:52 [PATCH v1] bpf: fix compilation of samples/bpf/ Constantine Shulyupin
@ 2018-07-07 22:49 ` Alexei Starovoitov
  0 siblings, 0 replies; 2+ messages in thread
From: Alexei Starovoitov @ 2018-07-07 22:49 UTC (permalink / raw)
  To: Constantine Shulyupin
  Cc: jakub.kicinski, Masahiro Yamada, Michal Marek, Alexei Starovoitov,
	Daniel Borkmann, open list,
	open list:BPF (Safe dynamic programs and tools)

On Sat, Jul 07, 2018 at 05:52:03PM +0300, Constantine Shulyupin wrote:
> Example of errors:
> 
> samples/bpf/test_lru_dist.c:39:8: error: redefinition of ‘struct list_head’
>  struct list_head {
>         ^~~~~~~~~
> In file included from samples/bpf/test_lru_dist.c:9:0:
> ./tools/include/linux/types.h:69:8: note: originally defined here
> 
> In file included from samples/bpf/sock_example.c:27:0:
> /usr/include/linux/ip.h:102:2: error: unknown type name ‘__sum16’
> 
> samples/bpf/bpf_load.c: In function ‘load_and_attach’:
> samples/bpf/bpf_load.c:90:15: error: ‘BPF_PROG_TYPE_RAW_TRACEPOINT’ undeclared (first use in this function); did you mean ‘BPF_PROG_TYPE_TRACEPOINT’?
> 
> samples/bpf/xdpsock_user.c:10:10: fatal error: linux/if_xdp.h: No such file or directory
> 
> samples/bpf/task_fd_query_user.c: In function ‘test_debug_fs_uprobe’:
> samples/bpf/task_fd_query_user.c:270:31: error: ‘BPF_FD_TYPE_URETPROBE’ undeclared (first use in this function); did you mean ‘BPF_PROG_TYPE_KPROBE’?
> 
> samples/bpf/parse_varlen.c:111:8: error: redefinition of 'vlan_hdr'
> struct vlan_hdr {
>        ^
> ./include/linux/if_vlan.h:38:8: note: previous definition is here
> 
> Signed-off-by: Constantine Shulyupin <const@MakeLinux.com>
> ---
>  Makefile                           | 1 +
>  samples/bpf/Makefile               | 5 +++--
>  samples/bpf/xdp_sample_pkts_user.c | 3 +++
>  3 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index d15ac32afbaf..824006258319 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -441,6 +441,7 @@ export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
>  export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
>  export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
>  export KBUILD_ARFLAGS
> +export USERINCLUDE
>  
>  # When compiling out-of-tree modules, put MODVERDIR in the module
>  # tree rather than in the kernel tree. The kernel tree might
> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
> index 9ea2f7b64869..991273c81459 100644
> --- a/samples/bpf/Makefile
> +++ b/samples/bpf/Makefile
> @@ -167,11 +167,12 @@ always += xdp_fwd_kern.o
>  always += task_fd_query_kern.o
>  always += xdp_sample_pkts_kern.o
>  
> -HOSTCFLAGS += -I$(objtree)/usr/include
> +HOSTCFLAGS += -D__EXPORTED_HEADERS__ $(USERINCLUDE)

the goal of the patch is to avoid doing 'make headers_install' to build samples/bpf/ ?
The idea of the patch is interesting, but it breaks the build for me:
/w/net-next make samples/bpf/
make[1]: Entering directory `/data/users/ast/net-next/bld_x64'
  Using .. as source for kernel
  GEN     ./Makefile
  CALL    ../scripts/checksyscalls.sh
  DESCEND  objtool
  HOSTCC  samples/bpf/test_lru_dist
In file included from ../include/uapi/linux/posix_types.h:5:0,
                 from ../include/uapi/linux/types.h:14,
                 from ../samples/bpf/test_lru_dist.c:9:
../include/uapi/linux/stddef.h:2:34: fatal error: linux/compiler_types.h: No such file or directory
 #include <linux/compiler_types.h>
                                  ^
compilation terminated.

while I don't see any build issues without this patch in bpf tree.
Strangely current bpf-next tree fails with:
parse_varlen.c:111:8: error: redefinition of 'vlan_hdr'
but none of the other errors you mentioned.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-07 22:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-07 14:52 [PATCH v1] bpf: fix compilation of samples/bpf/ Constantine Shulyupin
2018-07-07 22:49 ` Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).