1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
diff --git a/introspection/CMakeLists.txt b/introspection/CMakeLists.txt
index 91eac43c..f52cf654 100644
--- a/introspection/CMakeLists.txt
+++ b/introspection/CMakeLists.txt
@@ -4,10 +4,11 @@
include_directories(${CMAKE_SOURCE_DIR}/src/cc)
include_directories(${CMAKE_SOURCE_DIR}/src/cc/api)
include_directories(${CMAKE_SOURCE_DIR}/src/cc/libbpf/include/uapi)
+include_directories(/usr/include/uapi)
option(INSTALL_INTROSPECTION "Install BPF introspection tools" ON)
add_executable(bps bps.c)
-target_link_libraries(bps bpf-static elf)
+target_link_libraries(bps bccbpf-static elf)
install (TARGETS bps DESTINATION share/bcc/introspection)
diff --git a/introspection/bps.c b/introspection/bps.c
index 59160938..e3fc22c7 100644
--- a/introspection/bps.c
+++ b/introspection/bps.c
@@ -8,6 +8,7 @@
#include <unistd.h>
#include <ctype.h>
#include <sysexits.h>
+#include <linux/bpf.h>
#include "libbpf.h"
diff --git a/src/cc/CMakeLists.txt b/src/cc/CMakeLists.txt
index c53c542f..c4675dee 100644
--- a/src/cc/CMakeLists.txt
+++ b/src/cc/CMakeLists.txt
@@ -10,8 +10,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/frontends/clang)
include_directories(${LLVM_INCLUDE_DIRS})
include_directories(${LIBELF_INCLUDE_DIRS})
# todo: if check for kernel version
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libbpf/include)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libbpf/include/uapi)
+include_directories(/usr/include)
+include_directories(/usr/include/uapi)
add_definitions(${LLVM_DEFINITIONS})
configure_file(libbcc.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libbcc.pc @ONLY)
@@ -44,11 +44,13 @@ endif()
set(libbpf_uapi libbpf/include/uapi/linux})
-add_library(bpf-static STATIC libbpf.c perf_reader.c ${libbpf_sources})
-set_target_properties(bpf-static PROPERTIES OUTPUT_NAME bcc_bpf)
-add_library(bpf-shared SHARED libbpf.c perf_reader.c ${libbpf_sources})
-set_target_properties(bpf-shared PROPERTIES VERSION ${REVISION_LAST} SOVERSION 0)
-set_target_properties(bpf-shared PROPERTIES OUTPUT_NAME bcc_bpf)
+add_library(bccbpf-static STATIC libbpf.c perf_reader.c)
+set_target_properties(bccbpf-static PROPERTIES OUTPUT_NAME bccbpf)
+target_link_libraries(bccbpf-static bpf)
+add_library(bccbpf-shared SHARED libbpf.c perf_reader.c)
+set_target_properties(bccbpf-shared PROPERTIES VERSION ${REVISION_LAST} SOVERSION 0)
+set_target_properties(bccbpf-shared PROPERTIES OUTPUT_NAME bccbpf)
+target_link_libraries(bccbpf-shared bpf)
set(bcc_common_sources bcc_common.cc bpf_module.cc bcc_btf.cc exported_files.cc)
if (${LLVM_PACKAGE_VERSION} VERSION_EQUAL 6 OR ${LLVM_PACKAGE_VERSION} VERSION_GREATER 6)
@@ -107,10 +109,10 @@ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${llvm_lib_exclude_f
set(bcc_common_libs b_frontend clang_frontend
-Wl,--whole-archive ${clang_libs} ${llvm_libs} -Wl,--no-whole-archive
${LIBELF_LIBRARIES})
-set(bcc_common_libs_for_a ${bcc_common_libs} bpf-static)
-set(bcc_common_libs_for_s ${bcc_common_libs} bpf-static)
+set(bcc_common_libs_for_a ${bcc_common_libs} bccbpf-static bpf)
+set(bcc_common_libs_for_s ${bcc_common_libs} bccbpf-static bpf)
set(bcc_common_libs_for_n ${bcc_common_libs})
-set(bcc_common_libs_for_lua b_frontend clang_frontend bpf-static
+set(bcc_common_libs_for_lua b_frontend clang_frontend bccbpf-static bpf
${clang_libs} ${llvm_libs} ${LIBELF_LIBRARIES})
if(ENABLE_CPP_API)
@@ -149,4 +151,4 @@ install(DIRECTORY ${libbpf_uapi} DESTINATION include/bcc/compat/linux FILES_MATC
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libbcc.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif(ENABLE_CLANG_JIT)
install(FILES ${bcc_common_headers} DESTINATION include/bcc)
-install(TARGETS bpf-shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+install(TARGETS bccbpf-shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
diff --git a/src/cc/bcc_btf.cc b/src/cc/bcc_btf.cc
index f7773fd4..d6e5f02a 100644
--- a/src/cc/bcc_btf.cc
+++ b/src/cc/bcc_btf.cc
@@ -17,10 +17,12 @@
#include "bcc_btf.h"
#include <stdarg.h>
#include <string.h>
+
+#include <linux/bpf.h>
#include "linux/btf.h"
#include "libbpf.h"
-#include "libbpf/src/libbpf.h"
-#include "libbpf/src/btf.h"
+#include "bpf/libbpf.h"
+#include "bpf/btf.h"
#include <vector>
#define BCC_MAX_ERRNO 4095
diff --git a/src/cc/bpf_module.cc b/src/cc/bpf_module.cc
index 3df7ef18..7f7a26f3 100644
--- a/src/cc/bpf_module.cc
+++ b/src/cc/bpf_module.cc
@@ -45,7 +45,7 @@
#include "exported_files.h"
#include "libbpf.h"
#include "bcc_btf.h"
-#include "libbpf/src/bpf.h"
+#include "bpf/bpf.h"
namespace ebpf {
diff --git a/src/cc/frontends/clang/b_frontend_action.cc b/src/cc/frontends/clang/b_frontend_action.cc
index 5697f2f9..4708e9b0 100644
--- a/src/cc/frontends/clang/b_frontend_action.cc
+++ b/src/cc/frontends/clang/b_frontend_action.cc
@@ -34,7 +34,7 @@
#include "loader.h"
#include "table_storage.h"
#include "arch_helper.h"
-#include "libbpf/src/bpf.h"
+#include "bpf/libbpf.h"
#include "libbpf.h"
diff --git a/src/cc/libbpf.c b/src/cc/libbpf.c
index 111f0195..cf154345 100644
--- a/src/cc/libbpf.c
+++ b/src/cc/libbpf.c
@@ -52,8 +52,8 @@
// TODO: Remove this when CentOS 6 support is not needed anymore
#include "setns.h"
-#include "libbpf/src/bpf.h"
-#include "libbpf/src/libbpf.h"
+#include "bpf/bpf.h"
+#include "bpf/libbpf.h"
// TODO: remove these defines when linux-libc-dev exports them properly
|