All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v2 0/5] samples: bpf: fix build after move to full libbpf
@ 2018-05-15  5:35 Jakub Kicinski
  2018-05-15  5:35 ` [PATCH bpf-next v2 1/5] samples: bpf: include bpf/bpf.h instead of local libbpf.h Jakub Kicinski
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Jakub Kicinski @ 2018-05-15  5:35 UTC (permalink / raw)
  To: alexei.starovoitov, daniel
  Cc: oss-drivers, netdev, Björn Töpel, Y Song,
	Jesper Dangaard Brouer, Jakub Kicinski

Hi!

Following patches address build issues after recent move to libbpf.
For out-of-tree builds we would see the following error:

gcc: error: samples/bpf/../../tools/lib/bpf/libbpf.a: No such file or directory

libbpf build system is now always invoked explicitly rather than
relying on building single objects most of the time.  We need to
resolve the friction between Kbuild and tools/ build system.

Mini-library called libbpf.h in samples is renamed to bpf_insn.h,
using linux/filter.h seems not completely trivial since some samples
get upset when order on include search path in changed.  We do have
to rename libbpf.h, however, because otherwise it's hard to reliably
get to libbpf's header in out-of-tree builds.

v2:
 - fix the build error harder (patch 3);
 - add patch 5 (make clang less noisy).

Jakub Kicinski (5):
  samples: bpf: include bpf/bpf.h instead of local libbpf.h
  samples: bpf: rename libbpf.h to bpf_insn.h
  samples: bpf: fix build after move to compiling full libbpf.a
  samples: bpf: move libbpf from object dependencies to libs
  samples: bpf: make the build less noisy

 samples/bpf/Makefile                          | 165 +++++++-----------
 samples/bpf/{libbpf.h => bpf_insn.h}          |   8 +-
 samples/bpf/bpf_load.c                        |   2 +-
 samples/bpf/bpf_load.h                        |   2 +-
 samples/bpf/cookie_uid_helper_example.c       |   2 +-
 samples/bpf/cpustat_user.c                    |   2 +-
 samples/bpf/fds_example.c                     |   4 +-
 samples/bpf/lathist_user.c                    |   2 +-
 samples/bpf/load_sock_ops.c                   |   2 +-
 samples/bpf/lwt_len_hist_user.c               |   2 +-
 samples/bpf/map_perf_test_user.c              |   2 +-
 samples/bpf/sock_example.c                    |   3 +-
 samples/bpf/sock_example.h                    |   1 -
 samples/bpf/sockex1_user.c                    |   2 +-
 samples/bpf/sockex2_user.c                    |   2 +-
 samples/bpf/sockex3_user.c                    |   2 +-
 samples/bpf/syscall_tp_user.c                 |   2 +-
 samples/bpf/tc_l2_redirect_user.c             |   2 +-
 samples/bpf/test_cgrp2_array_pin.c            |   2 +-
 samples/bpf/test_cgrp2_attach.c               |   3 +-
 samples/bpf/test_cgrp2_attach2.c              |   3 +-
 samples/bpf/test_cgrp2_sock.c                 |   3 +-
 samples/bpf/test_cgrp2_sock2.c                |   3 +-
 .../bpf/test_current_task_under_cgroup_user.c |   2 +-
 samples/bpf/test_lru_dist.c                   |   2 +-
 samples/bpf/test_map_in_map_user.c            |   2 +-
 samples/bpf/test_overhead_user.c              |   2 +-
 samples/bpf/test_probe_write_user_user.c      |   2 +-
 samples/bpf/trace_output_user.c               |   2 +-
 samples/bpf/tracex1_user.c                    |   2 +-
 samples/bpf/tracex2_user.c                    |   2 +-
 samples/bpf/tracex3_user.c                    |   2 +-
 samples/bpf/tracex4_user.c                    |   2 +-
 samples/bpf/tracex5_user.c                    |   2 +-
 samples/bpf/tracex6_user.c                    |   2 +-
 samples/bpf/tracex7_user.c                    |   2 +-
 samples/bpf/xdp_fwd_user.c                    |   2 +-
 samples/bpf/xdp_monitor_user.c                |   2 +-
 samples/bpf/xdp_redirect_cpu_user.c           |   2 +-
 samples/bpf/xdp_redirect_map_user.c           |   2 +-
 samples/bpf/xdp_redirect_user.c               |   2 +-
 samples/bpf/xdp_router_ipv4_user.c            |   2 +-
 samples/bpf/xdp_tx_iptunnel_user.c            |   2 +-
 samples/bpf/xdpsock_user.c                    |   2 +-
 44 files changed, 116 insertions(+), 147 deletions(-)
 rename samples/bpf/{libbpf.h => bpf_insn.h} (98%)

-- 
2.17.0

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

* [PATCH bpf-next v2 1/5] samples: bpf: include bpf/bpf.h instead of local libbpf.h
  2018-05-15  5:35 [PATCH bpf-next v2 0/5] samples: bpf: fix build after move to full libbpf Jakub Kicinski
@ 2018-05-15  5:35 ` Jakub Kicinski
  2018-05-15  5:35 ` [PATCH bpf-next v2 2/5] samples: bpf: rename libbpf.h to bpf_insn.h Jakub Kicinski
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Jakub Kicinski @ 2018-05-15  5:35 UTC (permalink / raw)
  To: alexei.starovoitov, daniel
  Cc: oss-drivers, netdev, Björn Töpel, Y Song,
	Jesper Dangaard Brouer, Jakub Kicinski

There are two files in the tree called libbpf.h which is becoming
problematic.  Most samples don't actually need the local libbpf.h
they simply include it to get to bpf/bpf.h.  Include bpf/bpf.h
directly instead.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
 samples/bpf/bpf_load.c                            | 2 +-
 samples/bpf/bpf_load.h                            | 2 +-
 samples/bpf/cpustat_user.c                        | 2 +-
 samples/bpf/lathist_user.c                        | 2 +-
 samples/bpf/load_sock_ops.c                       | 2 +-
 samples/bpf/lwt_len_hist_user.c                   | 2 +-
 samples/bpf/map_perf_test_user.c                  | 2 +-
 samples/bpf/sock_example.h                        | 1 -
 samples/bpf/sockex1_user.c                        | 2 +-
 samples/bpf/sockex2_user.c                        | 2 +-
 samples/bpf/sockex3_user.c                        | 2 +-
 samples/bpf/syscall_tp_user.c                     | 2 +-
 samples/bpf/tc_l2_redirect_user.c                 | 2 +-
 samples/bpf/test_cgrp2_array_pin.c                | 2 +-
 samples/bpf/test_current_task_under_cgroup_user.c | 2 +-
 samples/bpf/test_lru_dist.c                       | 2 +-
 samples/bpf/test_map_in_map_user.c                | 2 +-
 samples/bpf/test_overhead_user.c                  | 2 +-
 samples/bpf/test_probe_write_user_user.c          | 2 +-
 samples/bpf/trace_output_user.c                   | 2 +-
 samples/bpf/tracex1_user.c                        | 2 +-
 samples/bpf/tracex2_user.c                        | 2 +-
 samples/bpf/tracex3_user.c                        | 2 +-
 samples/bpf/tracex4_user.c                        | 2 +-
 samples/bpf/tracex5_user.c                        | 2 +-
 samples/bpf/tracex6_user.c                        | 2 +-
 samples/bpf/tracex7_user.c                        | 2 +-
 samples/bpf/xdp_fwd_user.c                        | 2 +-
 samples/bpf/xdp_monitor_user.c                    | 2 +-
 samples/bpf/xdp_redirect_cpu_user.c               | 2 +-
 samples/bpf/xdp_redirect_map_user.c               | 2 +-
 samples/bpf/xdp_redirect_user.c                   | 2 +-
 samples/bpf/xdp_router_ipv4_user.c                | 2 +-
 samples/bpf/xdp_tx_iptunnel_user.c                | 2 +-
 samples/bpf/xdpsock_user.c                        | 2 +-
 35 files changed, 34 insertions(+), 35 deletions(-)

diff --git a/samples/bpf/bpf_load.c b/samples/bpf/bpf_load.c
index a6b290de5632..89161c9ed466 100644
--- a/samples/bpf/bpf_load.c
+++ b/samples/bpf/bpf_load.c
@@ -24,7 +24,7 @@
 #include <poll.h>
 #include <ctype.h>
 #include <assert.h>
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 #include "perf-sys.h"
 
diff --git a/samples/bpf/bpf_load.h b/samples/bpf/bpf_load.h
index f9da59bca0cc..814894a12974 100644
--- a/samples/bpf/bpf_load.h
+++ b/samples/bpf/bpf_load.h
@@ -2,7 +2,7 @@
 #ifndef __BPF_LOAD_H
 #define __BPF_LOAD_H
 
-#include "libbpf.h"
+#include <bpf/bpf.h>
 
 #define MAX_MAPS 32
 #define MAX_PROGS 32
diff --git a/samples/bpf/cpustat_user.c b/samples/bpf/cpustat_user.c
index 2b4cd1ae57c5..869a99406dbf 100644
--- a/samples/bpf/cpustat_user.c
+++ b/samples/bpf/cpustat_user.c
@@ -17,7 +17,7 @@
 #include <sys/resource.h>
 #include <sys/wait.h>
 
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 
 #define MAX_CPU			8
diff --git a/samples/bpf/lathist_user.c b/samples/bpf/lathist_user.c
index 6477bad5b4e2..c8e88cc84e61 100644
--- a/samples/bpf/lathist_user.c
+++ b/samples/bpf/lathist_user.c
@@ -10,7 +10,7 @@
 #include <stdlib.h>
 #include <signal.h>
 #include <linux/bpf.h>
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 
 #define MAX_ENTRIES	20
diff --git a/samples/bpf/load_sock_ops.c b/samples/bpf/load_sock_ops.c
index e5da6cf71a3e..8ecb41ea0c03 100644
--- a/samples/bpf/load_sock_ops.c
+++ b/samples/bpf/load_sock_ops.c
@@ -8,7 +8,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <linux/bpf.h>
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 #include <unistd.h>
 #include <errno.h>
diff --git a/samples/bpf/lwt_len_hist_user.c b/samples/bpf/lwt_len_hist_user.c
index 7fcb94c09112..587b68b1f8dd 100644
--- a/samples/bpf/lwt_len_hist_user.c
+++ b/samples/bpf/lwt_len_hist_user.c
@@ -9,7 +9,7 @@
 #include <errno.h>
 #include <arpa/inet.h>
 
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_util.h"
 
 #define MAX_INDEX 64
diff --git a/samples/bpf/map_perf_test_user.c b/samples/bpf/map_perf_test_user.c
index 519d9af4b04a..38b7b1a96cc2 100644
--- a/samples/bpf/map_perf_test_user.c
+++ b/samples/bpf/map_perf_test_user.c
@@ -21,7 +21,7 @@
 #include <arpa/inet.h>
 #include <errno.h>
 
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 
 #define TEST_BIT(t) (1U << (t))
diff --git a/samples/bpf/sock_example.h b/samples/bpf/sock_example.h
index 772d5dad8465..a27d7579bc73 100644
--- a/samples/bpf/sock_example.h
+++ b/samples/bpf/sock_example.h
@@ -9,7 +9,6 @@
 #include <net/if.h>
 #include <linux/if_packet.h>
 #include <arpa/inet.h>
-#include "libbpf.h"
 
 static inline int open_raw_sock(const char *name)
 {
diff --git a/samples/bpf/sockex1_user.c b/samples/bpf/sockex1_user.c
index 2be935c2627d..93ec01c56104 100644
--- a/samples/bpf/sockex1_user.c
+++ b/samples/bpf/sockex1_user.c
@@ -2,7 +2,7 @@
 #include <stdio.h>
 #include <assert.h>
 #include <linux/bpf.h>
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 #include "sock_example.h"
 #include <unistd.h>
diff --git a/samples/bpf/sockex2_user.c b/samples/bpf/sockex2_user.c
index 44fe0805b087..1d5c6e9a6d27 100644
--- a/samples/bpf/sockex2_user.c
+++ b/samples/bpf/sockex2_user.c
@@ -2,7 +2,7 @@
 #include <stdio.h>
 #include <assert.h>
 #include <linux/bpf.h>
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 #include "sock_example.h"
 #include <unistd.h>
diff --git a/samples/bpf/sockex3_user.c b/samples/bpf/sockex3_user.c
index 495ee02e2fb7..5ba3ae9d180b 100644
--- a/samples/bpf/sockex3_user.c
+++ b/samples/bpf/sockex3_user.c
@@ -2,7 +2,7 @@
 #include <stdio.h>
 #include <assert.h>
 #include <linux/bpf.h>
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 #include "sock_example.h"
 #include <unistd.h>
diff --git a/samples/bpf/syscall_tp_user.c b/samples/bpf/syscall_tp_user.c
index 9169d3207f18..1a1d0059a277 100644
--- a/samples/bpf/syscall_tp_user.c
+++ b/samples/bpf/syscall_tp_user.c
@@ -16,7 +16,7 @@
 #include <assert.h>
 #include <stdbool.h>
 #include <sys/resource.h>
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 
 /* This program verifies bpf attachment to tracepoint sys_enter_* and sys_exit_*.
diff --git a/samples/bpf/tc_l2_redirect_user.c b/samples/bpf/tc_l2_redirect_user.c
index 28995a776560..7ec45c3e8f56 100644
--- a/samples/bpf/tc_l2_redirect_user.c
+++ b/samples/bpf/tc_l2_redirect_user.c
@@ -13,7 +13,7 @@
 #include <string.h>
 #include <errno.h>
 
-#include "libbpf.h"
+#include <bpf/bpf.h>
 
 static void usage(void)
 {
diff --git a/samples/bpf/test_cgrp2_array_pin.c b/samples/bpf/test_cgrp2_array_pin.c
index 8a1b8b5d8def..242184292f59 100644
--- a/samples/bpf/test_cgrp2_array_pin.c
+++ b/samples/bpf/test_cgrp2_array_pin.c
@@ -14,7 +14,7 @@
 #include <errno.h>
 #include <fcntl.h>
 
-#include "libbpf.h"
+#include <bpf/bpf.h>
 
 static void usage(void)
 {
diff --git a/samples/bpf/test_current_task_under_cgroup_user.c b/samples/bpf/test_current_task_under_cgroup_user.c
index 65b5fb51c1db..4be4874ca2bc 100644
--- a/samples/bpf/test_current_task_under_cgroup_user.c
+++ b/samples/bpf/test_current_task_under_cgroup_user.c
@@ -9,7 +9,7 @@
 #include <stdio.h>
 #include <linux/bpf.h>
 #include <unistd.h>
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 #include <linux/bpf.h>
 #include "cgroup_helpers.h"
diff --git a/samples/bpf/test_lru_dist.c b/samples/bpf/test_lru_dist.c
index 73c357142268..eec3e2509ce8 100644
--- a/samples/bpf/test_lru_dist.c
+++ b/samples/bpf/test_lru_dist.c
@@ -21,7 +21,7 @@
 #include <stdlib.h>
 #include <time.h>
 
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_util.h"
 
 #define min(a, b) ((a) < (b) ? (a) : (b))
diff --git a/samples/bpf/test_map_in_map_user.c b/samples/bpf/test_map_in_map_user.c
index 1aca18539d8d..e308858f7bcf 100644
--- a/samples/bpf/test_map_in_map_user.c
+++ b/samples/bpf/test_map_in_map_user.c
@@ -13,7 +13,7 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 
 #define PORT_A		(map_fd[0])
diff --git a/samples/bpf/test_overhead_user.c b/samples/bpf/test_overhead_user.c
index e1d35e07a10e..6caf47afa635 100644
--- a/samples/bpf/test_overhead_user.c
+++ b/samples/bpf/test_overhead_user.c
@@ -19,7 +19,7 @@
 #include <string.h>
 #include <time.h>
 #include <sys/resource.h>
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 
 #define MAX_CNT 1000000
diff --git a/samples/bpf/test_probe_write_user_user.c b/samples/bpf/test_probe_write_user_user.c
index bf8e3a9f3067..045eb5e30f54 100644
--- a/samples/bpf/test_probe_write_user_user.c
+++ b/samples/bpf/test_probe_write_user_user.c
@@ -3,7 +3,7 @@
 #include <assert.h>
 #include <linux/bpf.h>
 #include <unistd.h>
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 #include <sys/socket.h>
 #include <string.h>
diff --git a/samples/bpf/trace_output_user.c b/samples/bpf/trace_output_user.c
index da98be721001..4837d73edefe 100644
--- a/samples/bpf/trace_output_user.c
+++ b/samples/bpf/trace_output_user.c
@@ -18,7 +18,7 @@
 #include <sys/mman.h>
 #include <time.h>
 #include <signal.h>
-#include "libbpf.h"
+#include <libbpf.h>
 #include "bpf_load.h"
 #include "perf-sys.h"
 #include "trace_helpers.h"
diff --git a/samples/bpf/tracex1_user.c b/samples/bpf/tracex1_user.c
index 3dcb475fb135..af8c20608ab5 100644
--- a/samples/bpf/tracex1_user.c
+++ b/samples/bpf/tracex1_user.c
@@ -2,7 +2,7 @@
 #include <stdio.h>
 #include <linux/bpf.h>
 #include <unistd.h>
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 
 int main(int ac, char **argv)
diff --git a/samples/bpf/tracex2_user.c b/samples/bpf/tracex2_user.c
index efb5e61918df..1a81e6a5c2ea 100644
--- a/samples/bpf/tracex2_user.c
+++ b/samples/bpf/tracex2_user.c
@@ -7,7 +7,7 @@
 #include <string.h>
 #include <sys/resource.h>
 
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 #include "bpf_util.h"
 
diff --git a/samples/bpf/tracex3_user.c b/samples/bpf/tracex3_user.c
index fe372239d505..6c6b10f4c3ee 100644
--- a/samples/bpf/tracex3_user.c
+++ b/samples/bpf/tracex3_user.c
@@ -13,7 +13,7 @@
 #include <linux/bpf.h>
 #include <sys/resource.h>
 
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 #include "bpf_util.h"
 
diff --git a/samples/bpf/tracex4_user.c b/samples/bpf/tracex4_user.c
index 22c644f1f4c3..14625c898e43 100644
--- a/samples/bpf/tracex4_user.c
+++ b/samples/bpf/tracex4_user.c
@@ -14,7 +14,7 @@
 #include <linux/bpf.h>
 #include <sys/resource.h>
 
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 
 struct pair {
diff --git a/samples/bpf/tracex5_user.c b/samples/bpf/tracex5_user.c
index 4e2774b731f0..c4ab91c89494 100644
--- a/samples/bpf/tracex5_user.c
+++ b/samples/bpf/tracex5_user.c
@@ -5,7 +5,7 @@
 #include <linux/filter.h>
 #include <linux/seccomp.h>
 #include <sys/prctl.h>
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 #include <sys/resource.h>
 
diff --git a/samples/bpf/tracex6_user.c b/samples/bpf/tracex6_user.c
index 89ab8d408474..4bb3c830adb2 100644
--- a/samples/bpf/tracex6_user.c
+++ b/samples/bpf/tracex6_user.c
@@ -16,7 +16,7 @@
 #include <unistd.h>
 
 #include "bpf_load.h"
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "perf-sys.h"
 
 #define SAMPLE_PERIOD  0x7fffffffffffffffULL
diff --git a/samples/bpf/tracex7_user.c b/samples/bpf/tracex7_user.c
index 8a52ac492e8b..ea6dae78f0df 100644
--- a/samples/bpf/tracex7_user.c
+++ b/samples/bpf/tracex7_user.c
@@ -3,7 +3,7 @@
 #include <stdio.h>
 #include <linux/bpf.h>
 #include <unistd.h>
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 
 int main(int argc, char **argv)
diff --git a/samples/bpf/xdp_fwd_user.c b/samples/bpf/xdp_fwd_user.c
index 9c6606f57126..a87a2048ed32 100644
--- a/samples/bpf/xdp_fwd_user.c
+++ b/samples/bpf/xdp_fwd_user.c
@@ -26,7 +26,7 @@
 
 #include "bpf_load.h"
 #include "bpf_util.h"
-#include "libbpf.h"
+#include <bpf/bpf.h>
 
 
 static int do_attach(int idx, int fd, const char *name)
diff --git a/samples/bpf/xdp_monitor_user.c b/samples/bpf/xdp_monitor_user.c
index 05ad3f590c91..bf09b5188acd 100644
--- a/samples/bpf/xdp_monitor_user.c
+++ b/samples/bpf/xdp_monitor_user.c
@@ -26,7 +26,7 @@ static const char *__doc_err_only__=
 #include <net/if.h>
 #include <time.h>
 
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 #include "bpf_util.h"
 
diff --git a/samples/bpf/xdp_redirect_cpu_user.c b/samples/bpf/xdp_redirect_cpu_user.c
index 23744a8aaf21..f6efaefd485b 100644
--- a/samples/bpf/xdp_redirect_cpu_user.c
+++ b/samples/bpf/xdp_redirect_cpu_user.c
@@ -28,7 +28,7 @@ static const char *__doc__ =
  * use bpf/libbpf.h), but cannot as (currently) needed for XDP
  * attaching to a device via bpf_set_link_xdp_fd()
  */
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_load.h"
 
 #include "bpf_util.h"
diff --git a/samples/bpf/xdp_redirect_map_user.c b/samples/bpf/xdp_redirect_map_user.c
index 7eae07d7293e..4445e76854b5 100644
--- a/samples/bpf/xdp_redirect_map_user.c
+++ b/samples/bpf/xdp_redirect_map_user.c
@@ -24,7 +24,7 @@
 
 #include "bpf_load.h"
 #include "bpf_util.h"
-#include "libbpf.h"
+#include <bpf/bpf.h>
 
 static int ifindex_in;
 static int ifindex_out;
diff --git a/samples/bpf/xdp_redirect_user.c b/samples/bpf/xdp_redirect_user.c
index b701b5c21342..81a69e36cb78 100644
--- a/samples/bpf/xdp_redirect_user.c
+++ b/samples/bpf/xdp_redirect_user.c
@@ -24,7 +24,7 @@
 
 #include "bpf_load.h"
 #include "bpf_util.h"
-#include "libbpf.h"
+#include <bpf/bpf.h>
 
 static int ifindex_in;
 static int ifindex_out;
diff --git a/samples/bpf/xdp_router_ipv4_user.c b/samples/bpf/xdp_router_ipv4_user.c
index 6296741c1fbd..b2b4dfa776c8 100644
--- a/samples/bpf/xdp_router_ipv4_user.c
+++ b/samples/bpf/xdp_router_ipv4_user.c
@@ -16,7 +16,7 @@
 #include <sys/socket.h>
 #include <unistd.h>
 #include "bpf_load.h"
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include <arpa/inet.h>
 #include <fcntl.h>
 #include <poll.h>
diff --git a/samples/bpf/xdp_tx_iptunnel_user.c b/samples/bpf/xdp_tx_iptunnel_user.c
index f0a787268a87..a4ccc33adac0 100644
--- a/samples/bpf/xdp_tx_iptunnel_user.c
+++ b/samples/bpf/xdp_tx_iptunnel_user.c
@@ -18,7 +18,7 @@
 #include <unistd.h>
 #include <time.h>
 #include "bpf_load.h"
-#include "libbpf.h"
+#include <bpf/bpf.h>
 #include "bpf_util.h"
 #include "xdp_tx_iptunnel_common.h"
 
diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c
index 4b8a7cf3e63b..7fe60f6f7d53 100644
--- a/samples/bpf/xdpsock_user.c
+++ b/samples/bpf/xdpsock_user.c
@@ -38,7 +38,7 @@
 
 #include "bpf_load.h"
 #include "bpf_util.h"
-#include "libbpf.h"
+#include <bpf/bpf.h>
 
 #include "xdpsock.h"
 
-- 
2.17.0

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

* [PATCH bpf-next v2 2/5] samples: bpf: rename libbpf.h to bpf_insn.h
  2018-05-15  5:35 [PATCH bpf-next v2 0/5] samples: bpf: fix build after move to full libbpf Jakub Kicinski
  2018-05-15  5:35 ` [PATCH bpf-next v2 1/5] samples: bpf: include bpf/bpf.h instead of local libbpf.h Jakub Kicinski
@ 2018-05-15  5:35 ` Jakub Kicinski
  2018-05-15  5:35 ` [PATCH bpf-next v2 3/5] samples: bpf: fix build after move to compiling full libbpf.a Jakub Kicinski
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Jakub Kicinski @ 2018-05-15  5:35 UTC (permalink / raw)
  To: alexei.starovoitov, daniel
  Cc: oss-drivers, netdev, Björn Töpel, Y Song,
	Jesper Dangaard Brouer, Jakub Kicinski

The libbpf.h file in samples is clashing with libbpf's header.
Since it only includes a subset of filter.h instruction helpers
rename it to bpf_insn.h.  Drop the unnecessary include of bpf/bpf.h.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
 samples/bpf/{libbpf.h => bpf_insn.h}    | 8 +++-----
 samples/bpf/cookie_uid_helper_example.c | 2 +-
 samples/bpf/fds_example.c               | 4 +++-
 samples/bpf/sock_example.c              | 3 ++-
 samples/bpf/test_cgrp2_attach.c         | 3 ++-
 samples/bpf/test_cgrp2_attach2.c        | 3 ++-
 samples/bpf/test_cgrp2_sock.c           | 3 ++-
 samples/bpf/test_cgrp2_sock2.c          | 3 ++-
 8 files changed, 17 insertions(+), 12 deletions(-)
 rename samples/bpf/{libbpf.h => bpf_insn.h} (98%)

diff --git a/samples/bpf/libbpf.h b/samples/bpf/bpf_insn.h
similarity index 98%
rename from samples/bpf/libbpf.h
rename to samples/bpf/bpf_insn.h
index 18bfee5aab6b..20dc5cefec84 100644
--- a/samples/bpf/libbpf.h
+++ b/samples/bpf/bpf_insn.h
@@ -1,9 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-/* eBPF mini library */
-#ifndef __LIBBPF_H
-#define __LIBBPF_H
-
-#include <bpf/bpf.h>
+/* eBPF instruction mini library */
+#ifndef __BPF_INSN_H
+#define __BPF_INSN_H
 
 struct bpf_insn;
 
diff --git a/samples/bpf/cookie_uid_helper_example.c b/samples/bpf/cookie_uid_helper_example.c
index 8eca27e595ae..deb0e3e0324d 100644
--- a/samples/bpf/cookie_uid_helper_example.c
+++ b/samples/bpf/cookie_uid_helper_example.c
@@ -51,7 +51,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <bpf/bpf.h>
-#include "libbpf.h"
+#include "bpf_insn.h"
 
 #define PORT 8888
 
diff --git a/samples/bpf/fds_example.c b/samples/bpf/fds_example.c
index e29bd52ff9e8..9854854f05d1 100644
--- a/samples/bpf/fds_example.c
+++ b/samples/bpf/fds_example.c
@@ -12,8 +12,10 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 
+#include <bpf/bpf.h>
+
+#include "bpf_insn.h"
 #include "bpf_load.h"
-#include "libbpf.h"
 #include "sock_example.h"
 
 #define BPF_F_PIN	(1 << 0)
diff --git a/samples/bpf/sock_example.c b/samples/bpf/sock_example.c
index 33a637507c00..60ec467c78ab 100644
--- a/samples/bpf/sock_example.c
+++ b/samples/bpf/sock_example.c
@@ -26,7 +26,8 @@
 #include <linux/if_ether.h>
 #include <linux/ip.h>
 #include <stddef.h>
-#include "libbpf.h"
+#include <bpf/bpf.h>
+#include "bpf_insn.h"
 #include "sock_example.h"
 
 char bpf_log_buf[BPF_LOG_BUF_SIZE];
diff --git a/samples/bpf/test_cgrp2_attach.c b/samples/bpf/test_cgrp2_attach.c
index 4bfcaf93fcf3..20fbd1241db3 100644
--- a/samples/bpf/test_cgrp2_attach.c
+++ b/samples/bpf/test_cgrp2_attach.c
@@ -28,8 +28,9 @@
 #include <fcntl.h>
 
 #include <linux/bpf.h>
+#include <bpf/bpf.h>
 
-#include "libbpf.h"
+#include "bpf_insn.h"
 
 enum {
 	MAP_KEY_PACKETS,
diff --git a/samples/bpf/test_cgrp2_attach2.c b/samples/bpf/test_cgrp2_attach2.c
index 1af412ec6007..b453e6a161be 100644
--- a/samples/bpf/test_cgrp2_attach2.c
+++ b/samples/bpf/test_cgrp2_attach2.c
@@ -24,8 +24,9 @@
 #include <unistd.h>
 
 #include <linux/bpf.h>
+#include <bpf/bpf.h>
 
-#include "libbpf.h"
+#include "bpf_insn.h"
 #include "cgroup_helpers.h"
 
 #define FOO		"/foo"
diff --git a/samples/bpf/test_cgrp2_sock.c b/samples/bpf/test_cgrp2_sock.c
index e79594dd629b..b0811da5a00f 100644
--- a/samples/bpf/test_cgrp2_sock.c
+++ b/samples/bpf/test_cgrp2_sock.c
@@ -21,8 +21,9 @@
 #include <net/if.h>
 #include <inttypes.h>
 #include <linux/bpf.h>
+#include <bpf/bpf.h>
 
-#include "libbpf.h"
+#include "bpf_insn.h"
 
 char bpf_log_buf[BPF_LOG_BUF_SIZE];
 
diff --git a/samples/bpf/test_cgrp2_sock2.c b/samples/bpf/test_cgrp2_sock2.c
index e53f1f6f0867..3b5be2364975 100644
--- a/samples/bpf/test_cgrp2_sock2.c
+++ b/samples/bpf/test_cgrp2_sock2.c
@@ -19,8 +19,9 @@
 #include <fcntl.h>
 #include <net/if.h>
 #include <linux/bpf.h>
+#include <bpf/bpf.h>
 
-#include "libbpf.h"
+#include "bpf_insn.h"
 #include "bpf_load.h"
 
 static int usage(const char *argv0)
-- 
2.17.0

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

* [PATCH bpf-next v2 3/5] samples: bpf: fix build after move to compiling full libbpf.a
  2018-05-15  5:35 [PATCH bpf-next v2 0/5] samples: bpf: fix build after move to full libbpf Jakub Kicinski
  2018-05-15  5:35 ` [PATCH bpf-next v2 1/5] samples: bpf: include bpf/bpf.h instead of local libbpf.h Jakub Kicinski
  2018-05-15  5:35 ` [PATCH bpf-next v2 2/5] samples: bpf: rename libbpf.h to bpf_insn.h Jakub Kicinski
@ 2018-05-15  5:35 ` Jakub Kicinski
  2018-05-15  6:05   ` Björn Töpel
  2018-05-15  5:35 ` [PATCH bpf-next v2 4/5] samples: bpf: move libbpf from object dependencies to libs Jakub Kicinski
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Jakub Kicinski @ 2018-05-15  5:35 UTC (permalink / raw)
  To: alexei.starovoitov, daniel
  Cc: oss-drivers, netdev, Björn Töpel, Y Song,
	Jesper Dangaard Brouer, Jakub Kicinski

There are many ways users may compile samples, some of them got
broken by commit 5f9380572b4b ("samples: bpf: compile and link
against full libbpf").  Improve path resolution and make libbpf
building a dependency of source files to force its build.

Samples should now again build with any of:
 cd samples/bpf; make
 make samples/bpf/
 make -C samples/bpf
 cd samples/bpf; make O=builddir
 make samples/bpf/ O=builddir
 make -C samples/bpf O=builddir
 export KBUILD_OUTPUT=builddir
 make samples/bpf/
 make -C samples/bpf

Fixes: 5f9380572b4b ("samples: bpf: compile and link against full libbpf")
Reported-by: Björn Töpel <bjorn.topel@gmail.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 samples/bpf/Makefile | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 9e255ca4059a..0dae77c88d2e 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -1,4 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
+
+BPF_SAMPLES_PATH ?= $(abspath $(srctree)/$(src))
+TOOLS_PATH := $(BPF_SAMPLES_PATH)/../../tools
+
 # List of programs to build
 hostprogs-y := test_lru_dist
 hostprogs-y += sock_example
@@ -49,7 +53,8 @@ hostprogs-y += xdpsock
 hostprogs-y += xdp_fwd
 
 # Libbpf dependencies
-LIBBPF := ../../tools/lib/bpf/libbpf.a
+LIBBPF = $(TOOLS_PATH)/lib/bpf/libbpf.a
+
 CGROUP_HELPERS := ../../tools/testing/selftests/bpf/cgroup_helpers.o
 TRACE_HELPERS := ../../tools/testing/selftests/bpf/trace_helpers.o
 
@@ -233,15 +238,16 @@ CLANG_ARCH_ARGS = -target $(ARCH)
 endif
 
 # Trick to allow make to be run from this directory
-all: $(LIBBPF)
-	$(MAKE) -C ../../ $(CURDIR)/
+all:
+	$(MAKE) -C ../../ $(CURDIR)/ BPF_SAMPLES_PATH=$(CURDIR)
 
 clean:
 	$(MAKE) -C ../../ M=$(CURDIR) clean
 	@rm -f *~
 
 $(LIBBPF): FORCE
-	$(MAKE) -C $(dir $@)
+# Fix up variables inherited from Kbuild that tools/ build system won't like
+	$(MAKE) -C $(dir $@) RM='rm -rf' LDFLAGS= srctree=$(BPF_SAMPLES_PATH)/../../ O=
 
 $(obj)/syscall_nrs.s:	$(src)/syscall_nrs.c
 	$(call if_changed_dep,cc_s_c)
@@ -272,7 +278,8 @@ verify_target_bpf: verify_cmds
 		exit 2; \
 	else true; fi
 
-$(src)/*.c: verify_target_bpf
+$(BPF_SAMPLES_PATH)/*.c: verify_target_bpf $(LIBBPF)
+$(src)/*.c: verify_target_bpf $(LIBBPF)
 
 $(obj)/tracex5_kern.o: $(obj)/syscall_nrs.h
 
-- 
2.17.0

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

* [PATCH bpf-next v2 4/5] samples: bpf: move libbpf from object dependencies to libs
  2018-05-15  5:35 [PATCH bpf-next v2 0/5] samples: bpf: fix build after move to full libbpf Jakub Kicinski
                   ` (2 preceding siblings ...)
  2018-05-15  5:35 ` [PATCH bpf-next v2 3/5] samples: bpf: fix build after move to compiling full libbpf.a Jakub Kicinski
@ 2018-05-15  5:35 ` Jakub Kicinski
  2018-05-15  5:35 ` [PATCH bpf-next v2 5/5] samples: bpf: make the build less noisy Jakub Kicinski
  2018-05-15  5:57 ` [PATCH bpf-next v2 0/5] samples: bpf: fix build after move to full libbpf Alexei Starovoitov
  5 siblings, 0 replies; 11+ messages in thread
From: Jakub Kicinski @ 2018-05-15  5:35 UTC (permalink / raw)
  To: alexei.starovoitov, daniel
  Cc: oss-drivers, netdev, Björn Töpel, Y Song,
	Jesper Dangaard Brouer, Jakub Kicinski

Make complains that it doesn't know how to make libbpf.a:

scripts/Makefile.host:106: target 'samples/bpf/../../tools/lib/bpf/libbpf.a' doesn't match the target pattern

Now that we have it as a dependency of the sources simply add libbpf.a
to libraries not objects.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
 samples/bpf/Makefile | 145 +++++++++++++++----------------------------
 1 file changed, 51 insertions(+), 94 deletions(-)

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 0dae77c88d2e..0036a77c2d97 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -58,55 +58,53 @@ LIBBPF = $(TOOLS_PATH)/lib/bpf/libbpf.a
 CGROUP_HELPERS := ../../tools/testing/selftests/bpf/cgroup_helpers.o
 TRACE_HELPERS := ../../tools/testing/selftests/bpf/trace_helpers.o
 
-test_lru_dist-objs := test_lru_dist.o $(LIBBPF)
-sock_example-objs := sock_example.o $(LIBBPF)
-fds_example-objs := bpf_load.o $(LIBBPF) fds_example.o
-sockex1-objs := bpf_load.o $(LIBBPF) sockex1_user.o
-sockex2-objs := bpf_load.o $(LIBBPF) sockex2_user.o
-sockex3-objs := bpf_load.o $(LIBBPF) sockex3_user.o
-tracex1-objs := bpf_load.o $(LIBBPF) tracex1_user.o
-tracex2-objs := bpf_load.o $(LIBBPF) tracex2_user.o
-tracex3-objs := bpf_load.o $(LIBBPF) tracex3_user.o
-tracex4-objs := bpf_load.o $(LIBBPF) tracex4_user.o
-tracex5-objs := bpf_load.o $(LIBBPF) tracex5_user.o
-tracex6-objs := bpf_load.o $(LIBBPF) tracex6_user.o
-tracex7-objs := bpf_load.o $(LIBBPF) tracex7_user.o
-load_sock_ops-objs := bpf_load.o $(LIBBPF) load_sock_ops.o
-test_probe_write_user-objs := bpf_load.o $(LIBBPF) test_probe_write_user_user.o
-trace_output-objs := bpf_load.o $(LIBBPF) trace_output_user.o $(TRACE_HELPERS)
-lathist-objs := bpf_load.o $(LIBBPF) lathist_user.o
-offwaketime-objs := bpf_load.o $(LIBBPF) offwaketime_user.o $(TRACE_HELPERS)
-spintest-objs := bpf_load.o $(LIBBPF) spintest_user.o $(TRACE_HELPERS)
-map_perf_test-objs := bpf_load.o $(LIBBPF) map_perf_test_user.o
-test_overhead-objs := bpf_load.o $(LIBBPF) test_overhead_user.o
-test_cgrp2_array_pin-objs := test_cgrp2_array_pin.o $(LIBBPF)
-test_cgrp2_attach-objs := test_cgrp2_attach.o $(LIBBPF)
-test_cgrp2_attach2-objs := test_cgrp2_attach2.o $(LIBBPF) $(CGROUP_HELPERS)
-test_cgrp2_sock-objs := test_cgrp2_sock.o $(LIBBPF)
-test_cgrp2_sock2-objs := bpf_load.o $(LIBBPF) test_cgrp2_sock2.o
-xdp1-objs := xdp1_user.o $(LIBBPF)
+fds_example-objs := bpf_load.o fds_example.o
+sockex1-objs := bpf_load.o sockex1_user.o
+sockex2-objs := bpf_load.o sockex2_user.o
+sockex3-objs := bpf_load.o sockex3_user.o
+tracex1-objs := bpf_load.o tracex1_user.o
+tracex2-objs := bpf_load.o tracex2_user.o
+tracex3-objs := bpf_load.o tracex3_user.o
+tracex4-objs := bpf_load.o tracex4_user.o
+tracex5-objs := bpf_load.o tracex5_user.o
+tracex6-objs := bpf_load.o tracex6_user.o
+tracex7-objs := bpf_load.o tracex7_user.o
+load_sock_ops-objs := bpf_load.o load_sock_ops.o
+test_probe_write_user-objs := bpf_load.o test_probe_write_user_user.o
+trace_output-objs := bpf_load.o trace_output_user.o $(TRACE_HELPERS)
+lathist-objs := bpf_load.o lathist_user.o
+offwaketime-objs := bpf_load.o offwaketime_user.o $(TRACE_HELPERS)
+spintest-objs := bpf_load.o spintest_user.o $(TRACE_HELPERS)
+map_perf_test-objs := bpf_load.o map_perf_test_user.o
+test_overhead-objs := bpf_load.o test_overhead_user.o
+test_cgrp2_array_pin-objs := test_cgrp2_array_pin.o
+test_cgrp2_attach-objs := test_cgrp2_attach.o
+test_cgrp2_attach2-objs := test_cgrp2_attach2.o $(CGROUP_HELPERS)
+test_cgrp2_sock-objs := test_cgrp2_sock.o
+test_cgrp2_sock2-objs := bpf_load.o test_cgrp2_sock2.o
+xdp1-objs := xdp1_user.o
 # reuse xdp1 source intentionally
-xdp2-objs := xdp1_user.o $(LIBBPF)
-xdp_router_ipv4-objs := bpf_load.o $(LIBBPF) xdp_router_ipv4_user.o
-test_current_task_under_cgroup-objs := bpf_load.o $(LIBBPF) $(CGROUP_HELPERS) \
+xdp2-objs := xdp1_user.o
+xdp_router_ipv4-objs := bpf_load.o xdp_router_ipv4_user.o
+test_current_task_under_cgroup-objs := bpf_load.o $(CGROUP_HELPERS) \
 				       test_current_task_under_cgroup_user.o
-trace_event-objs := bpf_load.o $(LIBBPF) trace_event_user.o $(TRACE_HELPERS)
-sampleip-objs := bpf_load.o $(LIBBPF) sampleip_user.o $(TRACE_HELPERS)
-tc_l2_redirect-objs := bpf_load.o $(LIBBPF) tc_l2_redirect_user.o
-lwt_len_hist-objs := bpf_load.o $(LIBBPF) lwt_len_hist_user.o
-xdp_tx_iptunnel-objs := bpf_load.o $(LIBBPF) xdp_tx_iptunnel_user.o
-test_map_in_map-objs := bpf_load.o $(LIBBPF) test_map_in_map_user.o
-per_socket_stats_example-objs := cookie_uid_helper_example.o $(LIBBPF)
-xdp_redirect-objs := bpf_load.o $(LIBBPF) xdp_redirect_user.o
-xdp_redirect_map-objs := bpf_load.o $(LIBBPF) xdp_redirect_map_user.o
-xdp_redirect_cpu-objs := bpf_load.o $(LIBBPF) xdp_redirect_cpu_user.o
-xdp_monitor-objs := bpf_load.o $(LIBBPF) xdp_monitor_user.o
-xdp_rxq_info-objs := xdp_rxq_info_user.o $(LIBBPF)
-syscall_tp-objs := bpf_load.o $(LIBBPF) syscall_tp_user.o
-cpustat-objs := bpf_load.o $(LIBBPF) cpustat_user.o
-xdp_adjust_tail-objs := xdp_adjust_tail_user.o $(LIBBPF)
-xdpsock-objs := bpf_load.o $(LIBBPF) xdpsock_user.o
-xdp_fwd-objs := bpf_load.o $(LIBBPF) xdp_fwd_user.o
+trace_event-objs := bpf_load.o trace_event_user.o $(TRACE_HELPERS)
+sampleip-objs := bpf_load.o sampleip_user.o $(TRACE_HELPERS)
+tc_l2_redirect-objs := bpf_load.o tc_l2_redirect_user.o
+lwt_len_hist-objs := bpf_load.o lwt_len_hist_user.o
+xdp_tx_iptunnel-objs := bpf_load.o xdp_tx_iptunnel_user.o
+test_map_in_map-objs := bpf_load.o test_map_in_map_user.o
+per_socket_stats_example-objs := cookie_uid_helper_example.o
+xdp_redirect-objs := bpf_load.o xdp_redirect_user.o
+xdp_redirect_map-objs := bpf_load.o xdp_redirect_map_user.o
+xdp_redirect_cpu-objs := bpf_load.o xdp_redirect_cpu_user.o
+xdp_monitor-objs := bpf_load.o xdp_monitor_user.o
+xdp_rxq_info-objs := xdp_rxq_info_user.o
+syscall_tp-objs := bpf_load.o syscall_tp_user.o
+cpustat-objs := bpf_load.o cpustat_user.o
+xdp_adjust_tail-objs := xdp_adjust_tail_user.o
+xdpsock-objs := bpf_load.o xdpsock_user.o
+xdp_fwd-objs := bpf_load.o xdp_fwd_user.o
 
 # Tell kbuild to always build the programs
 always := $(hostprogs-y)
@@ -178,53 +176,12 @@ HOSTCFLAGS_spintest_user.o += -I$(srctree)/tools/lib/bpf/
 HOSTCFLAGS_trace_event_user.o += -I$(srctree)/tools/lib/bpf/
 HOSTCFLAGS_sampleip_user.o += -I$(srctree)/tools/lib/bpf/
 
-HOSTLOADLIBES_test_lru_dist += -lelf
-HOSTLOADLIBES_sock_example += -lelf
-HOSTLOADLIBES_fds_example += -lelf
-HOSTLOADLIBES_sockex1 += -lelf
-HOSTLOADLIBES_sockex2 += -lelf
-HOSTLOADLIBES_sockex3 += -lelf
-HOSTLOADLIBES_tracex1 += -lelf
-HOSTLOADLIBES_tracex2 += -lelf
-HOSTLOADLIBES_tracex3 += -lelf
-HOSTLOADLIBES_tracex4 += -lelf -lrt
-HOSTLOADLIBES_tracex5 += -lelf
-HOSTLOADLIBES_tracex6 += -lelf
-HOSTLOADLIBES_tracex7 += -lelf
-HOSTLOADLIBES_test_cgrp2_array_pin += -lelf
-HOSTLOADLIBES_test_cgrp2_attach += -lelf
-HOSTLOADLIBES_test_cgrp2_attach2 += -lelf
-HOSTLOADLIBES_test_cgrp2_sock += -lelf
-HOSTLOADLIBES_test_cgrp2_sock2 += -lelf
-HOSTLOADLIBES_load_sock_ops += -lelf
-HOSTLOADLIBES_test_probe_write_user += -lelf
-HOSTLOADLIBES_trace_output += -lelf -lrt
-HOSTLOADLIBES_lathist += -lelf
-HOSTLOADLIBES_offwaketime += -lelf
-HOSTLOADLIBES_spintest += -lelf
-HOSTLOADLIBES_map_perf_test += -lelf -lrt
-HOSTLOADLIBES_test_overhead += -lelf -lrt
-HOSTLOADLIBES_xdp1 += -lelf
-HOSTLOADLIBES_xdp2 += -lelf
-HOSTLOADLIBES_xdp_router_ipv4 += -lelf
-HOSTLOADLIBES_test_current_task_under_cgroup += -lelf
-HOSTLOADLIBES_trace_event += -lelf
-HOSTLOADLIBES_sampleip += -lelf
-HOSTLOADLIBES_tc_l2_redirect += -l elf
-HOSTLOADLIBES_lwt_len_hist += -l elf
-HOSTLOADLIBES_xdp_tx_iptunnel += -lelf
-HOSTLOADLIBES_test_map_in_map += -lelf
-HOSTLOADLIBES_per_socket_stats_example += -lelf
-HOSTLOADLIBES_xdp_redirect += -lelf
-HOSTLOADLIBES_xdp_redirect_map += -lelf
-HOSTLOADLIBES_xdp_redirect_cpu += -lelf
-HOSTLOADLIBES_xdp_monitor += -lelf
-HOSTLOADLIBES_xdp_rxq_info += -lelf
-HOSTLOADLIBES_syscall_tp += -lelf
-HOSTLOADLIBES_cpustat += -lelf
-HOSTLOADLIBES_xdp_adjust_tail += -lelf
-HOSTLOADLIBES_xdpsock += -lelf -pthread
-HOSTLOADLIBES_xdp_fwd += -lelf
+HOST_LOADLIBES		+= $(LIBBPF) -lelf
+HOSTLOADLIBES_tracex4		+= -lrt
+HOSTLOADLIBES_trace_output	+= -lrt
+HOSTLOADLIBES_map_perf_test	+= -lrt
+HOSTLOADLIBES_test_overhead	+= -lrt
+HOSTLOADLIBES_xdpsock		+= -pthread
 
 # Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline:
 #  make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
-- 
2.17.0

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

* [PATCH bpf-next v2 5/5] samples: bpf: make the build less noisy
  2018-05-15  5:35 [PATCH bpf-next v2 0/5] samples: bpf: fix build after move to full libbpf Jakub Kicinski
                   ` (3 preceding siblings ...)
  2018-05-15  5:35 ` [PATCH bpf-next v2 4/5] samples: bpf: move libbpf from object dependencies to libs Jakub Kicinski
@ 2018-05-15  5:35 ` Jakub Kicinski
  2018-05-15  5:57 ` [PATCH bpf-next v2 0/5] samples: bpf: fix build after move to full libbpf Alexei Starovoitov
  5 siblings, 0 replies; 11+ messages in thread
From: Jakub Kicinski @ 2018-05-15  5:35 UTC (permalink / raw)
  To: alexei.starovoitov, daniel
  Cc: oss-drivers, netdev, Björn Töpel, Y Song,
	Jesper Dangaard Brouer, Jakub Kicinski

Building samples with clang ignores the $(Q) setting, always
printing full command to the output.  Make it less verbose.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 samples/bpf/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 0036a77c2d97..62d1aa1a4cf3 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -244,7 +244,8 @@ $(obj)/tracex5_kern.o: $(obj)/syscall_nrs.h
 # But, there is no easy way to fix it, so just exclude it since it is
 # useless for BPF samples.
 $(obj)/%.o: $(src)/%.c
-	$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) -I$(obj) \
+	@echo "  CLANG-bpf " $@
+	$(Q)$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) -I$(obj) \
 		-I$(srctree)/tools/testing/selftests/bpf/ \
 		-D__KERNEL__ -Wno-unused-value -Wno-pointer-sign \
 		-D__TARGET_ARCH_$(ARCH) -Wno-compare-distinct-pointer-types \
-- 
2.17.0

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

* Re: [PATCH bpf-next v2 0/5] samples: bpf: fix build after move to full libbpf
  2018-05-15  5:35 [PATCH bpf-next v2 0/5] samples: bpf: fix build after move to full libbpf Jakub Kicinski
                   ` (4 preceding siblings ...)
  2018-05-15  5:35 ` [PATCH bpf-next v2 5/5] samples: bpf: make the build less noisy Jakub Kicinski
@ 2018-05-15  5:57 ` Alexei Starovoitov
  2018-05-15  6:10   ` Jesper Dangaard Brouer
  5 siblings, 1 reply; 11+ messages in thread
From: Alexei Starovoitov @ 2018-05-15  5:57 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: daniel, oss-drivers, netdev, Björn Töpel, Y Song,
	Jesper Dangaard Brouer

On Mon, May 14, 2018 at 10:35:01PM -0700, Jakub Kicinski wrote:
> Hi!
> 
> Following patches address build issues after recent move to libbpf.
> For out-of-tree builds we would see the following error:
> 
> gcc: error: samples/bpf/../../tools/lib/bpf/libbpf.a: No such file or directory
> 
> libbpf build system is now always invoked explicitly rather than
> relying on building single objects most of the time.  We need to
> resolve the friction between Kbuild and tools/ build system.
> 
> Mini-library called libbpf.h in samples is renamed to bpf_insn.h,
> using linux/filter.h seems not completely trivial since some samples
> get upset when order on include search path in changed.  We do have
> to rename libbpf.h, however, because otherwise it's hard to reliably
> get to libbpf's header in out-of-tree builds.
> 
> v2:
>  - fix the build error harder (patch 3);
>  - add patch 5 (make clang less noisy).

Applied, Thanks

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

* Re: [PATCH bpf-next v2 3/5] samples: bpf: fix build after move to compiling full libbpf.a
  2018-05-15  5:35 ` [PATCH bpf-next v2 3/5] samples: bpf: fix build after move to compiling full libbpf.a Jakub Kicinski
@ 2018-05-15  6:05   ` Björn Töpel
  0 siblings, 0 replies; 11+ messages in thread
From: Björn Töpel @ 2018-05-15  6:05 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Alexei Starovoitov, Daniel Borkmann, oss-drivers, Netdev, Y Song,
	Jesper Dangaard Brouer

2018-05-15 7:35 GMT+02:00 Jakub Kicinski <jakub.kicinski@netronome.com>:
> There are many ways users may compile samples, some of them got
> broken by commit 5f9380572b4b ("samples: bpf: compile and link
> against full libbpf").  Improve path resolution and make libbpf
> building a dependency of source files to force its build.
>
> Samples should now again build with any of:
>  cd samples/bpf; make
>  make samples/bpf/
>  make -C samples/bpf
>  cd samples/bpf; make O=builddir
>  make samples/bpf/ O=builddir
>  make -C samples/bpf O=builddir
>  export KBUILD_OUTPUT=builddir
>  make samples/bpf/
>  make -C samples/bpf
>
> Fixes: 5f9380572b4b ("samples: bpf: compile and link against full libbpf")
> Reported-by: Björn Töpel <bjorn.topel@gmail.com>
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> ---
>  samples/bpf/Makefile | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
> index 9e255ca4059a..0dae77c88d2e 100644
> --- a/samples/bpf/Makefile
> +++ b/samples/bpf/Makefile
> @@ -1,4 +1,8 @@
>  # SPDX-License-Identifier: GPL-2.0
> +
> +BPF_SAMPLES_PATH ?= $(abspath $(srctree)/$(src))
> +TOOLS_PATH := $(BPF_SAMPLES_PATH)/../../tools
> +
>  # List of programs to build
>  hostprogs-y := test_lru_dist
>  hostprogs-y += sock_example
> @@ -49,7 +53,8 @@ hostprogs-y += xdpsock
>  hostprogs-y += xdp_fwd
>
>  # Libbpf dependencies
> -LIBBPF := ../../tools/lib/bpf/libbpf.a
> +LIBBPF = $(TOOLS_PATH)/lib/bpf/libbpf.a
> +
>  CGROUP_HELPERS := ../../tools/testing/selftests/bpf/cgroup_helpers.o
>  TRACE_HELPERS := ../../tools/testing/selftests/bpf/trace_helpers.o
>
> @@ -233,15 +238,16 @@ CLANG_ARCH_ARGS = -target $(ARCH)
>  endif
>
>  # Trick to allow make to be run from this directory
> -all: $(LIBBPF)
> -       $(MAKE) -C ../../ $(CURDIR)/
> +all:
> +       $(MAKE) -C ../../ $(CURDIR)/ BPF_SAMPLES_PATH=$(CURDIR)
>
>  clean:
>         $(MAKE) -C ../../ M=$(CURDIR) clean
>         @rm -f *~
>
>  $(LIBBPF): FORCE
> -       $(MAKE) -C $(dir $@)
> +# Fix up variables inherited from Kbuild that tools/ build system won't like
> +       $(MAKE) -C $(dir $@) RM='rm -rf' LDFLAGS= srctree=$(BPF_SAMPLES_PATH)/../../ O=
>
>  $(obj)/syscall_nrs.s:  $(src)/syscall_nrs.c
>         $(call if_changed_dep,cc_s_c)
> @@ -272,7 +278,8 @@ verify_target_bpf: verify_cmds
>                 exit 2; \
>         else true; fi
>
> -$(src)/*.c: verify_target_bpf
> +$(BPF_SAMPLES_PATH)/*.c: verify_target_bpf $(LIBBPF)
> +$(src)/*.c: verify_target_bpf $(LIBBPF)
>
>  $(obj)/tracex5_kern.o: $(obj)/syscall_nrs.h
>
> --
> 2.17.0
>


Thanks a bunch for this!

Tested-by: Björn Töpel <bjorn.topel@gmail.com>

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

* Re: [PATCH bpf-next v2 0/5] samples: bpf: fix build after move to full libbpf
  2018-05-15  5:57 ` [PATCH bpf-next v2 0/5] samples: bpf: fix build after move to full libbpf Alexei Starovoitov
@ 2018-05-15  6:10   ` Jesper Dangaard Brouer
  2018-05-15  9:16     ` Jesper Dangaard Brouer
  0 siblings, 1 reply; 11+ messages in thread
From: Jesper Dangaard Brouer @ 2018-05-15  6:10 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Jakub Kicinski, daniel, oss-drivers, netdev,
	Björn Töpel, Y Song, brouer

On Mon, 14 May 2018 22:57:53 -0700
Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote:

> On Mon, May 14, 2018 at 10:35:01PM -0700, Jakub Kicinski wrote:
> > Hi!
> > 
> > Following patches address build issues after recent move to libbpf.
> > For out-of-tree builds we would see the following error:
> > 
> > gcc: error: samples/bpf/../../tools/lib/bpf/libbpf.a: No such file or directory
> > 
> > libbpf build system is now always invoked explicitly rather than
> > relying on building single objects most of the time.  We need to
> > resolve the friction between Kbuild and tools/ build system.
> > 
> > Mini-library called libbpf.h in samples is renamed to bpf_insn.h,
> > using linux/filter.h seems not completely trivial since some samples
> > get upset when order on include search path in changed.  We do have
> > to rename libbpf.h, however, because otherwise it's hard to reliably
> > get to libbpf's header in out-of-tree builds.
> > 
> > v2:
> >  - fix the build error harder (patch 3);
> >  - add patch 5 (make clang less noisy).  
> 
> Applied, Thanks

I just tried it out, but the build fails.

$ make samples/bpf/
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  DESCEND  objtool
  CHK     scripts/mod/devicetable-offsets.h
make -C /home/jbrouer/git/kernel/bpf-next/samples/bpf/../../tools/lib/bpf/ RM='rm -rf' LDFLAGS= srctree=/home/jbrouer/git/kernel/bpf-next/samples/bpf/../../ O=

Auto-detecting system features:
...                        libelf: [ OFF ]
...                           bpf: [ OFF ]

No libelf found
make[2]: *** [Makefile:212: elfdep] Error 1
make[1]: *** [samples/bpf/Makefile:207: /home/jbrouer/git/kernel/bpf-next/samples/bpf/../../tools/lib/bpf/libbpf.a] Error 2
make: *** [Makefile:1743: samples/bpf/] Error 2
 

But it might not be related to this change, as the problem seems to the
with the "Auto-detecting system features".  It is the build of libbpf
that is the problem.

$ cd tools/lib/bpf/
$ make

Auto-detecting system features:
...                        libelf: [ OFF ]
...                           bpf: [ OFF ]

No libelf found
make: *** [Makefile:212: elfdep] Error 1


And do have 'libelf' installed on this system... the same build/make
commands works on net-next.

On net-next I see:

$ cd tools/lib/bpf/
$ make

Auto-detecting system features:
...                        libelf: [ on  ]
...                           bpf: [ on  ]

Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf.h' differs from latest version at 'include/uapi/linux/bpf.h'
Warning: Kernel ABI header at 'tools/include/uapi/linux/if_link.h' differs from latest version at 'include/uapi/linux/if_link.h'
  CC       libbpf.o
  CC       bpf.o
  CC       nlattr.o
  CC       btf.o
  LD       libbpf-in.o
  LINK     libbpf.a
  LINK     libbpf.so


-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer

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

* Re: [PATCH bpf-next v2 0/5] samples: bpf: fix build after move to full libbpf
  2018-05-15  6:10   ` Jesper Dangaard Brouer
@ 2018-05-15  9:16     ` Jesper Dangaard Brouer
  2018-05-15 17:46       ` Jakub Kicinski
  0 siblings, 1 reply; 11+ messages in thread
From: Jesper Dangaard Brouer @ 2018-05-15  9:16 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Jakub Kicinski, daniel, oss-drivers, netdev,
	Björn Töpel, Y Song, brouer

SOLVED, how see below

On Tue, 15 May 2018 08:10:09 +0200
Jesper Dangaard Brouer <brouer@redhat.com> wrote:

> On Mon, 14 May 2018 22:57:53 -0700
> Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote:
> 
> > On Mon, May 14, 2018 at 10:35:01PM -0700, Jakub Kicinski wrote:  
> > > Hi!
> > > 
> > > Following patches address build issues after recent move to libbpf.
> > > For out-of-tree builds we would see the following error:
> > > 
> > > gcc: error: samples/bpf/../../tools/lib/bpf/libbpf.a: No such file or directory
> > > 
> > > libbpf build system is now always invoked explicitly rather than
> > > relying on building single objects most of the time.  We need to
> > > resolve the friction between Kbuild and tools/ build system.
> > > 
> > > Mini-library called libbpf.h in samples is renamed to bpf_insn.h,
> > > using linux/filter.h seems not completely trivial since some samples
> > > get upset when order on include search path in changed.  We do have
> > > to rename libbpf.h, however, because otherwise it's hard to reliably
> > > get to libbpf's header in out-of-tree builds.
> > > 
> > > v2:
> > >  - fix the build error harder (patch 3);
> > >  - add patch 5 (make clang less noisy).    
> > 
> > Applied, Thanks  
> 
> I just tried it out, but the build fails.
> 
> $ make samples/bpf/
>   CHK     include/config/kernel.release
>   CHK     include/generated/uapi/linux/version.h
>   CHK     include/generated/utsrelease.h
>   CHK     include/generated/bounds.h
>   CHK     include/generated/timeconst.h
>   CHK     include/generated/asm-offsets.h
>   CALL    scripts/checksyscalls.sh
>   DESCEND  objtool
>   CHK     scripts/mod/devicetable-offsets.h
> make -C /home/jbrouer/git/kernel/bpf-next/samples/bpf/../../tools/lib/bpf/ RM='rm -rf' LDFLAGS= srctree=/home/jbrouer/git/kernel/bpf-next/samples/bpf/../../ O=
> 
> Auto-detecting system features:
> ...                        libelf: [ OFF ]
> ...                           bpf: [ OFF ]
> 
> No libelf found
> make[2]: *** [Makefile:212: elfdep] Error 1
> make[1]: *** [samples/bpf/Makefile:207: /home/jbrouer/git/kernel/bpf-next/samples/bpf/../../tools/lib/bpf/libbpf.a] Error 2
> make: *** [Makefile:1743: samples/bpf/] Error 2
>  
> 
> But it might not be related to this change, as the problem seems to the
> with the "Auto-detecting system features".  It is the build of libbpf
> that is the problem.
> 
> $ cd tools/lib/bpf/
> $ make
> 
> Auto-detecting system features:
> ...                        libelf: [ OFF ]
> ...                           bpf: [ OFF ]
> 
> No libelf found
> make: *** [Makefile:212: elfdep] Error 1
> 
> 
> And do have 'libelf' installed on this system... the same build/make
> commands works on net-next.
> 
> On net-next I see:
> 
> $ cd tools/lib/bpf/
> $ make
> 
> Auto-detecting system features:
> ...                        libelf: [ on  ]
> ...                           bpf: [ on  ]
> 
> Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf.h' differs from latest version at 'include/uapi/linux/bpf.h'
> Warning: Kernel ABI header at 'tools/include/uapi/linux/if_link.h' differs from latest version at 'include/uapi/linux/if_link.h'
>   CC       libbpf.o
>   CC       bpf.o
>   CC       nlattr.o
>   CC       btf.o
>   LD       libbpf-in.o
>   LINK     libbpf.a
>   LINK     libbpf.so

SOLVED

It seems that the "Auto-detecting system" needed a 'make clean'.
My problem goes away when I did the following:

$ cd tools/
$ make clean

$ cd lib/bpf/
$ make

Auto-detecting system features:
...                        libelf: [ on  ]
...                           bpf: [ on  ]

  HOSTCC   fixdep.o
  HOSTLD   fixdep-in.o
  LINK     fixdep
Warning: Kernel ABI header at 'tools/include/uapi/linux/if_link.h' differs from latest version at 'include/uapi/linux/if_link.h'
  CC       libbpf.o
  CC       bpf.o
  CC       nlattr.o
  CC       btf.o
  LD       libbpf-in.o
  LINK     libbpf.a
  LINK     libbpf.so


-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer

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

* Re: [PATCH bpf-next v2 0/5] samples: bpf: fix build after move to full libbpf
  2018-05-15  9:16     ` Jesper Dangaard Brouer
@ 2018-05-15 17:46       ` Jakub Kicinski
  0 siblings, 0 replies; 11+ messages in thread
From: Jakub Kicinski @ 2018-05-15 17:46 UTC (permalink / raw)
  To: Jesper Dangaard Brouer
  Cc: Alexei Starovoitov, daniel, oss-drivers, netdev,
	Björn Töpel, Y Song

On Tue, 15 May 2018 11:16:43 +0200, Jesper Dangaard Brouer wrote:
> > $ cd tools/lib/bpf/
> > $ make
> > 
> > Auto-detecting system features:
> > ...                        libelf: [ on  ]
> > ...                           bpf: [ on  ]
> > 
> > Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf.h' differs from latest version at 'include/uapi/linux/bpf.h'
> > Warning: Kernel ABI header at 'tools/include/uapi/linux/if_link.h' differs from latest version at 'include/uapi/linux/if_link.h'
> >   CC       libbpf.o
> >   CC       bpf.o
> >   CC       nlattr.o
> >   CC       btf.o
> >   LD       libbpf-in.o
> >   LINK     libbpf.a
> >   LINK     libbpf.so  
> 
> SOLVED
> 
> It seems that the "Auto-detecting system" needed a 'make clean'.
> My problem goes away when I did the following:
> 
> $ cd tools/
> $ make clean
> 
> $ cd lib/bpf/
> $ make
> 
> Auto-detecting system features:
> ...                        libelf: [ on  ]
> ...                           bpf: [ on  ]

Interesting!  I've seen the same thing (on Fedora, not sure distro is
relevant).  I tracked it down to dependency files (*.d) in
tools/build/features/ containing a reference to a sigset.h header which
didn't exist :S  I did git clean -xdf to fix my tree.

Thanks for testing and sorry about the breakage!

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

end of thread, other threads:[~2018-05-15 17:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-15  5:35 [PATCH bpf-next v2 0/5] samples: bpf: fix build after move to full libbpf Jakub Kicinski
2018-05-15  5:35 ` [PATCH bpf-next v2 1/5] samples: bpf: include bpf/bpf.h instead of local libbpf.h Jakub Kicinski
2018-05-15  5:35 ` [PATCH bpf-next v2 2/5] samples: bpf: rename libbpf.h to bpf_insn.h Jakub Kicinski
2018-05-15  5:35 ` [PATCH bpf-next v2 3/5] samples: bpf: fix build after move to compiling full libbpf.a Jakub Kicinski
2018-05-15  6:05   ` Björn Töpel
2018-05-15  5:35 ` [PATCH bpf-next v2 4/5] samples: bpf: move libbpf from object dependencies to libs Jakub Kicinski
2018-05-15  5:35 ` [PATCH bpf-next v2 5/5] samples: bpf: make the build less noisy Jakub Kicinski
2018-05-15  5:57 ` [PATCH bpf-next v2 0/5] samples: bpf: fix build after move to full libbpf Alexei Starovoitov
2018-05-15  6:10   ` Jesper Dangaard Brouer
2018-05-15  9:16     ` Jesper Dangaard Brouer
2018-05-15 17:46       ` Jakub Kicinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.