summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Replace-kprobe-function-blk_account_io_completion-to.patch169
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-cmake-link-dynamically-to-libclang-cpp-if-found-and-.patch68
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-fix-compilation-issues-with-latest-llvm12-trunk.patch89
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-tools-opensnoop-snoop-do_sys_openat2-for-kernel-v5.6.patch50
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0002-cmake-always-link-to-packaged-libbpf-if-CMAKE_USE_LI.patch239
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0002-fix-compilation-error-with-latest-llvm12-trunk.patch60
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0003-Remove-libbcc-no-libbpf-shared-library-change-libbcc.patch156
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0004-cmake-look-for-either-static-or-dynamic-libraries.patch69
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.20.0.bb (renamed from dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.17.0.bb)20
9 files changed, 7 insertions, 913 deletions
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Replace-kprobe-function-blk_account_io_completion-to.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Replace-kprobe-function-blk_account_io_completion-to.patch
deleted file mode 100644
index ef93296..0000000
--- a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Replace-kprobe-function-blk_account_io_completion-to.patch
+++ /dev/null
@@ -1,169 +0,0 @@
1From 95c9229ea9f029a1b9e8dcbe86fc67f037c0dfa2 Mon Sep 17 00:00:00 2001
2From: Chen HaoNing <owenchen1997@yeah.net>
3Date: Wed, 1 Jul 2020 15:49:17 -0500
4Subject: [PATCH] Replace kprobe function "blk_account_io_completion" to
5 "blk_account_io_done" for kernel version >= 5.8.0
6
7The kernel function "blk_account_io_completion" is not available anymore as attach point of Kprobe as of kernel version 5.8.0. Therefore, after discussions, we decided to use function "blk_account_io_done" instead in every kprobe attachment to "blk_account_io_completion".
8
9Upstream-Status: Backport
10
11---
12 docs/reference_guide.md | 4 ++--
13 docs/tutorial_bcc_python_developer.md | 6 +++---
14 examples/lua/kprobe-latency.lua | 2 +-
15 examples/tracing/bitehist.py | 2 +-
16 examples/tracing/disksnoop.py | 2 +-
17 tools/biosnoop.lua | 2 +-
18 tools/biosnoop.py | 2 +-
19 tools/biotop.py | 2 +-
20 tools/old/biosnoop.py | 2 +-
21 9 files changed, 12 insertions(+), 12 deletions(-)
22
23diff --git a/docs/reference_guide.md b/docs/reference_guide.md
24index 924fa203..9eaf27a5 100644
25--- a/docs/reference_guide.md
26+++ b/docs/reference_guide.md
27@@ -1784,7 +1784,7 @@ Example:
28 b = BPF(text="""
29 BPF_HISTOGRAM(dist);
30
31-int kprobe__blk_account_io_completion(struct pt_regs *ctx, struct request *req)
32+int kprobe__blk_account_io_done(struct pt_regs *ctx, struct request *req)
33 {
34 dist.increment(bpf_log2l(req->__data_len / 1024));
35 return 0;
36@@ -1835,7 +1835,7 @@ Example:
37 b = BPF(text="""
38 BPF_HISTOGRAM(dist);
39
40-int kprobe__blk_account_io_completion(struct pt_regs *ctx, struct request *req)
41+int kprobe__blk_account_io_done(struct pt_regs *ctx, struct request *req)
42 {
43 dist.increment(req->__data_len / 1024);
44 return 0;
45diff --git a/docs/tutorial_bcc_python_developer.md b/docs/tutorial_bcc_python_developer.md
46index 0cb0e780..b3b8ed6b 100644
47--- a/docs/tutorial_bcc_python_developer.md
48+++ b/docs/tutorial_bcc_python_developer.md
49@@ -220,7 +220,7 @@ void trace_completion(struct pt_regs *ctx, struct request *req) {
50
51 b.attach_kprobe(event="blk_start_request", fn_name="trace_start")
52 b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_start")
53-b.attach_kprobe(event="blk_account_io_completion", fn_name="trace_completion")
54+b.attach_kprobe(event="blk_account_io_done", fn_name="trace_completion")
55 [...]
56 ```
57
58@@ -351,7 +351,7 @@ b = BPF(text="""
59
60 BPF_HISTOGRAM(dist);
61
62-int kprobe__blk_account_io_completion(struct pt_regs *ctx, struct request *req)
63+int kprobe__blk_account_io_done(struct pt_regs *ctx, struct request *req)
64 {
65 dist.increment(bpf_log2l(req->__data_len / 1024));
66 return 0;
67@@ -374,7 +374,7 @@ b["dist"].print_log2_hist("kbytes")
68 A recap from earlier lessons:
69
70 - ```kprobe__```: This prefix means the rest will be treated as a kernel function name that will be instrumented using kprobe.
71-- ```struct pt_regs *ctx, struct request *req```: Arguments to kprobe. The ```ctx``` is registers and BPF context, the ```req``` is the first argument to the instrumented function: ```blk_account_io_completion()```.
72+- ```struct pt_regs *ctx, struct request *req```: Arguments to kprobe. The ```ctx``` is registers and BPF context, the ```req``` is the first argument to the instrumented function: ```blk_account_io_done()```.
73 - ```req->__data_len```: Dereferencing that member.
74
75 New things to learn:
76diff --git a/examples/lua/kprobe-latency.lua b/examples/lua/kprobe-latency.lua
77index 60ac2c1c..98464e5c 100644
78--- a/examples/lua/kprobe-latency.lua
79+++ b/examples/lua/kprobe-latency.lua
80@@ -30,7 +30,7 @@ local lat_map = bpf.map('array', bins)
81 local trace_start = bpf.kprobe('myprobe:blk_start_request', function (ptregs)
82 map[ptregs.parm1] = time()
83 end, false, -1, 0)
84-local trace_end = bpf.kprobe('myprobe2:blk_account_io_completion', function (ptregs)
85+local trace_end = bpf.kprobe('myprobe2:blk_account_io_done', function (ptregs)
86 -- The lines below are computing index
87 -- using log10(x)*10 = log2(x)*10/log2(10) = log2(x)*3
88 -- index = 29 ~ 1 usec
89diff --git a/examples/tracing/bitehist.py b/examples/tracing/bitehist.py
90index 4d7c7958..89ceb307 100755
91--- a/examples/tracing/bitehist.py
92+++ b/examples/tracing/bitehist.py
93@@ -25,7 +25,7 @@ b = BPF(text="""
94 BPF_HISTOGRAM(dist);
95 BPF_HISTOGRAM(dist_linear);
96
97-int kprobe__blk_account_io_completion(struct pt_regs *ctx, struct request *req)
98+int kprobe__blk_account_io_done(struct pt_regs *ctx, struct request *req)
99 {
100 dist.increment(bpf_log2l(req->__data_len / 1024));
101 dist_linear.increment(req->__data_len / 1024);
102diff --git a/examples/tracing/disksnoop.py b/examples/tracing/disksnoop.py
103index 1101e6f2..a35e1abd 100755
104--- a/examples/tracing/disksnoop.py
105+++ b/examples/tracing/disksnoop.py
106@@ -46,7 +46,7 @@ void trace_completion(struct pt_regs *ctx, struct request *req) {
107 if BPF.get_kprobe_functions(b'blk_start_request'):
108 b.attach_kprobe(event="blk_start_request", fn_name="trace_start")
109 b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_start")
110-b.attach_kprobe(event="blk_account_io_completion", fn_name="trace_completion")
111+b.attach_kprobe(event="blk_account_io_done", fn_name="trace_completion")
112
113 # header
114 print("%-18s %-2s %-7s %8s" % ("TIME(s)", "T", "BYTES", "LAT(ms)"))
115diff --git a/tools/biosnoop.lua b/tools/biosnoop.lua
116index 8d9b6a19..3e0441e2 100755
117--- a/tools/biosnoop.lua
118+++ b/tools/biosnoop.lua
119@@ -126,7 +126,7 @@ return function(BPF, utils)
120 bpf:attach_kprobe{event="blk_account_io_start", fn_name="trace_pid_start"}
121 bpf:attach_kprobe{event="blk_start_request", fn_name="trace_req_start"}
122 bpf:attach_kprobe{event="blk_mq_start_request", fn_name="trace_req_start"}
123- bpf:attach_kprobe{event="blk_account_io_completion",
124+ bpf:attach_kprobe{event="blk_account_io_done",
125 fn_name="trace_req_completion"}
126
127 print("%-14s %-14s %-6s %-7s %-2s %-9s %-7s %7s" % {"TIME(s)", "COMM", "PID",
128diff --git a/tools/biosnoop.py b/tools/biosnoop.py
129index ff9b842b..5bbc77cd 100755
130--- a/tools/biosnoop.py
131+++ b/tools/biosnoop.py
132@@ -160,7 +160,7 @@ b.attach_kprobe(event="blk_account_io_start", fn_name="trace_pid_start")
133 if BPF.get_kprobe_functions(b'blk_start_request'):
134 b.attach_kprobe(event="blk_start_request", fn_name="trace_req_start")
135 b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_req_start")
136-b.attach_kprobe(event="blk_account_io_completion",
137+b.attach_kprobe(event="blk_account_io_done",
138 fn_name="trace_req_completion")
139
140 # header
141diff --git a/tools/biotop.py b/tools/biotop.py
142index cad3759a..d3a42ef7 100755
143--- a/tools/biotop.py
144+++ b/tools/biotop.py
145@@ -178,7 +178,7 @@ b.attach_kprobe(event="blk_account_io_start", fn_name="trace_pid_start")
146 if BPF.get_kprobe_functions(b'blk_start_request'):
147 b.attach_kprobe(event="blk_start_request", fn_name="trace_req_start")
148 b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_req_start")
149-b.attach_kprobe(event="blk_account_io_completion",
150+b.attach_kprobe(event="blk_account_io_done",
151 fn_name="trace_req_completion")
152
153 print('Tracing... Output every %d secs. Hit Ctrl-C to end' % interval)
154diff --git a/tools/old/biosnoop.py b/tools/old/biosnoop.py
155index 37ee3f9c..847ab91b 100755
156--- a/tools/old/biosnoop.py
157+++ b/tools/old/biosnoop.py
158@@ -98,7 +98,7 @@ int trace_req_completion(struct pt_regs *ctx, struct request *req)
159 b.attach_kprobe(event="blk_account_io_start", fn_name="trace_pid_start")
160 b.attach_kprobe(event="blk_start_request", fn_name="trace_req_start")
161 b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_req_start")
162-b.attach_kprobe(event="blk_account_io_completion",
163+b.attach_kprobe(event="blk_account_io_done",
164 fn_name="trace_req_completion")
165
166 # header
167--
1682.17.1
169
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-cmake-link-dynamically-to-libclang-cpp-if-found-and-.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-cmake-link-dynamically-to-libclang-cpp-if-found-and-.patch
deleted file mode 100644
index 74b2e27..0000000
--- a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-cmake-link-dynamically-to-libclang-cpp-if-found-and-.patch
+++ /dev/null
@@ -1,68 +0,0 @@
1From f14f69d996ffc1c61dd523b839271d4a51328e4d Mon Sep 17 00:00:00 2001
2From: Luca Boccassi <bluca@debian.org>
3Date: Fri, 1 Jan 2021 19:04:37 +0000
4Subject: [PATCH 1/3] cmake: link dynamically to libclang-cpp if found and
5 ENABLE_LLVM_SHARED is set
6
7ENABLE_LLVM_SHARED allows to dynamically link against libLLVM, but
8libclang is still unconditionally linked statically.
9Search for libclang-cpp.so, and if it is found and ENABLE_LLVM_SHARED
10is set dynamically link against it.
11Also expand the libstdc++ static linking check to include this new
12condition.
13---
14 CMakeLists.txt | 1 +
15 cmake/clang_libs.cmake | 4 ++++
16 cmake/static_libstdc++.cmake | 2 +-
17 3 files changed, 6 insertions(+), 1 deletion(-)
18
19diff --git a/CMakeLists.txt b/CMakeLists.txt
20index 74fe4f19..b2e334e9 100644
21--- a/CMakeLists.txt
22+++ b/CMakeLists.txt
23@@ -76,6 +76,7 @@ find_library(libclangRewrite NAMES clangRewrite clang-cpp HINTS ${CLANG_SEARCH})
24 find_library(libclangSema NAMES clangSema clang-cpp HINTS ${CLANG_SEARCH})
25 find_library(libclangSerialization NAMES clangSerialization clang-cpp HINTS ${CLANG_SEARCH})
26 find_library(libclangASTMatchers NAMES clangASTMatchers clang-cpp HINTS ${CLANG_SEARCH})
27+find_library(libclang-shared libclang-cpp.so HINTS ${CLANG_SEARCH})
28 if(libclangBasic STREQUAL "libclangBasic-NOTFOUND")
29 message(FATAL_ERROR "Unable to find clang libraries")
30 endif()
31diff --git a/cmake/clang_libs.cmake b/cmake/clang_libs.cmake
32index c33b635c..3f1523b7 100644
33--- a/cmake/clang_libs.cmake
34+++ b/cmake/clang_libs.cmake
35@@ -26,6 +26,9 @@ llvm_map_components_to_libnames(_llvm_libs ${llvm_raw_libs})
36 llvm_expand_dependencies(llvm_libs ${_llvm_libs})
37 endif()
38
39+if(ENABLE_LLVM_SHARED AND NOT libclang-shared STREQUAL "libclang-shared-NOTFOUND")
40+set(clang_libs ${libclang-shared})
41+else()
42 # order is important
43 set(clang_libs
44 ${libclangFrontend}
45@@ -46,6 +49,7 @@ list(APPEND clang_libs
46 ${libclangAST}
47 ${libclangLex}
48 ${libclangBasic})
49+endif()
50
51 # prune unused llvm static library stuff when linking into the new .so
52 set(_exclude_flags)
53diff --git a/cmake/static_libstdc++.cmake b/cmake/static_libstdc++.cmake
54index 3c8ac179..787ed9ad 100644
55--- a/cmake/static_libstdc++.cmake
56+++ b/cmake/static_libstdc++.cmake
57@@ -1,7 +1,7 @@
58 # only turn on static-libstdc++ if also linking statically against clang
59 string(REGEX MATCH ".*[.]a$" LIBCLANG_ISSTATIC "${libclangBasic}")
60 # if gcc 4.9 or higher is used, static libstdc++ is a good option
61-if (CMAKE_COMPILER_IS_GNUCC AND LIBCLANG_ISSTATIC)
62+if (CMAKE_COMPILER_IS_GNUCC AND LIBCLANG_ISSTATIC AND (NOT ENABLE_LLVM_SHARED OR libclang-shared STREQUAL "libclang-shared-NOTFOUND"))
63 execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
64 if (GCC_VERSION VERSION_GREATER 4.9 OR GCC_VERSION VERSION_EQUAL 4.9)
65 execute_process(COMMAND ${CMAKE_C_COMPILER} -print-libgcc-file-name OUTPUT_VARIABLE GCC_LIB)
66--
672.29.2
68
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-fix-compilation-issues-with-latest-llvm12-trunk.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-fix-compilation-issues-with-latest-llvm12-trunk.patch
deleted file mode 100644
index b1f56e6..0000000
--- a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-fix-compilation-issues-with-latest-llvm12-trunk.patch
+++ /dev/null
@@ -1,89 +0,0 @@
1From 675fca6a646812361c16884ccd2ff789f40c4ce8 Mon Sep 17 00:00:00 2001
2From: Yonghong Song <yhs@fb.com>
3Date: Tue, 3 Nov 2020 22:11:57 -0800
4Subject: [PATCH 1/2] fix compilation issues with latest llvm12 trunk
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9With latest llvm12 trunk, we got two compilation bugs.
10
11Bug #1:
12 /home/yhs/work/bcc/src/cc/frontends/clang/b_frontend_action.cc:
13 In member function ‘void ebpf::BFrontendAction::DoMiscWorkAround()’:
14 /home/yhs/work/bcc/src/cc/frontends/clang/b_frontend_action.cc:1706:31:
15 error: ‘class clang::SourceManage’ has no member named ‘getBuffer’; did you mean ‘getBufferData’?
16 rewriter_->getSourceMgr().getBuffer(rewriter_->getSourceMgr().getMainFileID())->getBufferSize(),
17 ^~~~~~~~~
18 getBufferData
19
20 This is due to upstream change https://reviews.llvm.org/D89394.
21 To fix, follow upstream examples in https://reviews.llvm.org/D89394.
22
23Bug #2:
24 /home/yhs/work/bcc/src/cc/bpf_module.cc: In member function ‘int ebpf::BPFModule::finalize()’:
25 /home/yhs/work/bcc/src/cc/bpf_module.cc:470:11:
26 error: ‘class llvm::EngineBuilder’ has no member named ‘setUseOrcMCJITReplacement’
27 builder.setUseOrcMCJITReplacement(false);
28 ^~~~~~~~~~~~~~~~~~~~~~~~~
29
30 This is due to upstream
31 https://github.com/llvm/llvm-project/commit/6154c4115cd4b78d0171892aac21e340e72e32bd
32
33 It seems builder.setUseOrcMCJITReplacement() is not needed any more. So just remove it
34 from bcc.
35
36Signed-off-by: Yonghong Song <yhs@fb.com>
37---
38 src/cc/bpf_module.cc | 2 ++
39 src/cc/bpf_module_rw_engine.cc | 2 ++
40 src/cc/frontends/clang/b_frontend_action.cc | 4 ++++
41 3 files changed, 8 insertions(+)
42
43diff --git a/src/cc/bpf_module.cc b/src/cc/bpf_module.cc
44index 8fba8d27..c194b815 100644
45--- a/src/cc/bpf_module.cc
46+++ b/src/cc/bpf_module.cc
47@@ -466,7 +466,9 @@ int BPFModule::finalize() {
48 builder.setErrorStr(&err);
49 builder.setMCJITMemoryManager(ebpf::make_unique<MyMemoryManager>(sections_p));
50 builder.setMArch("bpf");
51+#if LLVM_MAJOR_VERSION <= 11
52 builder.setUseOrcMCJITReplacement(false);
53+#endif
54 engine_ = unique_ptr<ExecutionEngine>(builder.create());
55 if (!engine_) {
56 fprintf(stderr, "Could not create ExecutionEngine: %s\n", err.c_str());
57diff --git a/src/cc/bpf_module_rw_engine.cc b/src/cc/bpf_module_rw_engine.cc
58index d7e31a71..9890af69 100644
59--- a/src/cc/bpf_module_rw_engine.cc
60+++ b/src/cc/bpf_module_rw_engine.cc
61@@ -356,7 +356,9 @@ unique_ptr<ExecutionEngine> BPFModule::finalize_rw(unique_ptr<Module> m) {
62 string err;
63 EngineBuilder builder(move(m));
64 builder.setErrorStr(&err);
65+#if LLVM_MAJOR_VERSION <= 11
66 builder.setUseOrcMCJITReplacement(false);
67+#endif
68 auto engine = unique_ptr<ExecutionEngine>(builder.create());
69 if (!engine)
70 fprintf(stderr, "Could not create ExecutionEngine: %s\n", err.c_str());
71diff --git a/src/cc/frontends/clang/b_frontend_action.cc b/src/cc/frontends/clang/b_frontend_action.cc
72index 154a3794..80b03b9b 100644
73--- a/src/cc/frontends/clang/b_frontend_action.cc
74+++ b/src/cc/frontends/clang/b_frontend_action.cc
75@@ -1694,7 +1694,11 @@ void BFrontendAction::DoMiscWorkAround() {
76 false);
77
78 rewriter_->getEditBuffer(rewriter_->getSourceMgr().getMainFileID()).InsertTextAfter(
79+#if LLVM_MAJOR_VERSION >= 12
80+ rewriter_->getSourceMgr().getBufferOrFake(rewriter_->getSourceMgr().getMainFileID()).getBufferSize(),
81+#else
82 rewriter_->getSourceMgr().getBuffer(rewriter_->getSourceMgr().getMainFileID())->getBufferSize(),
83+#endif
84 "\n#include <bcc/footer.h>\n");
85 }
86
87--
882.30.0
89
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-tools-opensnoop-snoop-do_sys_openat2-for-kernel-v5.6.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-tools-opensnoop-snoop-do_sys_openat2-for-kernel-v5.6.patch
deleted file mode 100644
index fb659cc..0000000
--- a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-tools-opensnoop-snoop-do_sys_openat2-for-kernel-v5.6.patch
+++ /dev/null
@@ -1,50 +0,0 @@
1From 8e12b10e7576a6d47e0dc2cdc36caeb9ba26fa12 Mon Sep 17 00:00:00 2001
2From: He Zhe <zhe.he@windriver.com>
3Date: Mon, 15 Jun 2020 07:05:24 +0000
4Subject: [PATCH] tools: opensnoop: snoop do_sys_openat2 for kernel v5.6 and
5 later
6
7Since kernel v5.6, fddb5d430ad9 ("open: introduce openat2(2) syscall"),
8do_sys_openat2 instead of do_sys_open has been used as entry function for open.
9
10Upstream-Status: Inappropriate, upstream context has changed and needs more
11 tweak.
12
13Signed-off-by: He Zhe <zhe.he@windriver.com>
14---
15 tools/opensnoop.py | 12 ++++++++++--
16 1 file changed, 10 insertions(+), 2 deletions(-)
17
18diff --git a/tools/opensnoop.py b/tools/opensnoop.py
19index 51d3dc05..522812d4 100755
20--- a/tools/opensnoop.py
21+++ b/tools/opensnoop.py
22@@ -22,6 +22,8 @@ from bcc.utils import printb
23 import argparse
24 from datetime import datetime, timedelta
25 import os
26+import platform
27+from pkg_resources import parse_version
28
29 # arguments
30 examples = """examples:
31@@ -235,8 +237,14 @@ if debug or args.ebpf:
32 # initialize BPF
33 b = BPF(text=bpf_text)
34 if not is_support_kfunc:
35- b.attach_kprobe(event="do_sys_open", fn_name="trace_entry")
36- b.attach_kretprobe(event="do_sys_open", fn_name="trace_return")
37+ # Since kernel v5.6, do_sys_openat2 instead of do_sys_open has been used as entry function for open
38+ if parse_version(platform.uname().release.split('-')[0]) > parse_version('5.6.0'):
39+ entry = "do_sys_openat2"
40+ else:
41+ entry = "do_sys_open"
42+
43+ b.attach_kprobe(event=entry, fn_name="trace_entry")
44+ b.attach_kretprobe(event=entry, fn_name="trace_return")
45
46 initial_ts = 0
47
48--
492.17.1
50
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0002-cmake-always-link-to-packaged-libbpf-if-CMAKE_USE_LI.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0002-cmake-always-link-to-packaged-libbpf-if-CMAKE_USE_LI.patch
deleted file mode 100644
index 0269fa4..0000000
--- a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0002-cmake-always-link-to-packaged-libbpf-if-CMAKE_USE_LI.patch
+++ /dev/null
@@ -1,239 +0,0 @@
1From ab9a9dadf294f69e024a8b58c983a6c2085c223a Mon Sep 17 00:00:00 2001
2From: Luca Boccassi <bluca@debian.org>
3Date: Fri, 8 Jan 2021 16:58:56 +0000
4Subject: [PATCH 2/3] cmake: always link to packaged libbpf if
5 CMAKE_USE_LIBBPF_PACKAGE is set (#3210)
6
7Some of the executables still link to the local static versions
8even if the user requested CMAKE_USE_LIBBPF_PACKAGE. Fix this by
9using bcc-shared-no-libbpf more widely if the variable is set.
10
11Skip the git submodule and the extraction commands if the user
12set CMAKE_USE_LIBBPF_PACKAGE
13---
14 CMakeLists.txt | 2 +-
15 examples/cpp/CMakeLists.txt | 59 ++++++++----------------------
16 examples/cpp/pyperf/CMakeLists.txt | 5 +++
17 introspection/CMakeLists.txt | 8 +++-
18 src/cc/CMakeLists.txt | 29 ++++++++++-----
19 tests/cc/CMakeLists.txt | 22 +++++++----
20 6 files changed, 61 insertions(+), 64 deletions(-)
21
22diff --git a/CMakeLists.txt b/CMakeLists.txt
23index b2e334e9..b68571ea 100644
24--- a/CMakeLists.txt
25+++ b/CMakeLists.txt
26@@ -14,7 +14,7 @@ endif()
27 enable_testing()
28
29 # populate submodules (libbpf)
30-if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/cc/libbpf/src)
31+if(NOT CMAKE_USE_LIBBPF_PACKAGE AND NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/cc/libbpf/src)
32 execute_process(COMMAND git submodule update --init --recursive
33 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
34 endif()
35diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt
36index dae0e9ce..dd343245 100644
37--- a/examples/cpp/CMakeLists.txt
38+++ b/examples/cpp/CMakeLists.txt
39@@ -11,49 +11,20 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
40
41 option(INSTALL_CPP_EXAMPLES "Install C++ examples. Those binaries are statically linked and can take plenty of disk space" OFF)
42
43-add_executable(HelloWorld HelloWorld.cc)
44-target_link_libraries(HelloWorld bcc-static)
45-
46-add_executable(CPUDistribution CPUDistribution.cc)
47-target_link_libraries(CPUDistribution bcc-static)
48-
49-add_executable(RecordMySQLQuery RecordMySQLQuery.cc)
50-target_link_libraries(RecordMySQLQuery bcc-static)
51-
52-add_executable(TCPSendStack TCPSendStack.cc)
53-target_link_libraries(TCPSendStack bcc-static)
54-
55-add_executable(RandomRead RandomRead.cc)
56-target_link_libraries(RandomRead bcc-static)
57-
58-add_executable(LLCStat LLCStat.cc)
59-target_link_libraries(LLCStat bcc-static)
60-
61-add_executable(FollyRequestContextSwitch FollyRequestContextSwitch.cc)
62-target_link_libraries(FollyRequestContextSwitch bcc-static)
63-
64-add_executable(UseExternalMap UseExternalMap.cc)
65-target_link_libraries(UseExternalMap bcc-static)
66-
67-add_executable(CGroupTest CGroupTest.cc)
68-target_link_libraries(CGroupTest bcc-static)
69-
70-add_executable(TaskIterator TaskIterator.cc)
71-target_link_libraries(TaskIterator bcc-static)
72-
73-add_executable(SkLocalStorageIterator SkLocalStorageIterator.cc)
74-target_link_libraries(SkLocalStorageIterator bcc-static)
75-
76-if(INSTALL_CPP_EXAMPLES)
77- install (TARGETS HelloWorld DESTINATION share/bcc/examples/cpp)
78- install (TARGETS CPUDistribution DESTINATION share/bcc/examples/cpp)
79- install (TARGETS RecordMySQLQuery DESTINATION share/bcc/examples/cpp)
80- install (TARGETS TCPSendStack DESTINATION share/bcc/examples/cpp)
81- install (TARGETS RandomRead DESTINATION share/bcc/examples/cpp)
82- install (TARGETS LLCStat DESTINATION share/bcc/examples/cpp)
83- install (TARGETS FollyRequestContextSwitch DESTINATION share/bcc/examples/cpp)
84- install (TARGETS UseExternalMap DESTINATION share/bcc/examples/cpp)
85- install (TARGETS CGroupTest DESTINATION share/bcc/examples/cpp)
86-endif(INSTALL_CPP_EXAMPLES)
87+file(GLOB EXAMPLES *.cc)
88+foreach(EXAMPLE ${EXAMPLES})
89+ get_filename_component(NAME ${EXAMPLE} NAME_WE)
90+ add_executable(${NAME} ${EXAMPLE})
91+
92+ if(NOT CMAKE_USE_LIBBPF_PACKAGE)
93+ target_link_libraries(${NAME} bcc-static)
94+ else()
95+ target_link_libraries(${NAME} bcc-shared-no-libbpf)
96+ endif()
97+
98+ if(INSTALL_CPP_EXAMPLES)
99+ install (TARGETS ${NAME} DESTINATION share/bcc/examples/cpp)
100+ endif(INSTALL_CPP_EXAMPLES)
101+endforeach()
102
103 add_subdirectory(pyperf)
104diff --git a/examples/cpp/pyperf/CMakeLists.txt b/examples/cpp/pyperf/CMakeLists.txt
105index 6f963c66..97420806 100644
106--- a/examples/cpp/pyperf/CMakeLists.txt
107+++ b/examples/cpp/pyperf/CMakeLists.txt
108@@ -7,6 +7,11 @@ include_directories(${CMAKE_SOURCE_DIR}/src/cc/libbpf/include/uapi)
109
110 add_executable(PyPerf PyPerf.cc PyPerfUtil.cc PyPerfBPFProgram.cc PyPerfLoggingHelper.cc PyPerfDefaultPrinter.cc Py36Offsets.cc)
111 target_link_libraries(PyPerf bcc-static)
112+if(NOT CMAKE_USE_LIBBPF_PACKAGE)
113+ target_link_libraries(PyPerf bcc-static)
114+else()
115+ target_link_libraries(PyPerf bcc-shared-no-libbpf)
116+endif()
117
118 if(INSTALL_CPP_EXAMPLES)
119 install (TARGETS PyPerf DESTINATION share/bcc/examples/cpp)
120diff --git a/introspection/CMakeLists.txt b/introspection/CMakeLists.txt
121index 4328ee11..6c83f0c8 100644
122--- a/introspection/CMakeLists.txt
123+++ b/introspection/CMakeLists.txt
124@@ -8,7 +8,13 @@ include_directories(${CMAKE_SOURCE_DIR}/src/cc/libbpf/include/uapi)
125 option(INSTALL_INTROSPECTION "Install BPF introspection tools" ON)
126 option(BPS_LINK_RT "Pass -lrt to linker when linking bps tool" ON)
127
128-set(bps_libs_to_link bpf-static elf z)
129+# Note that the order matters! bpf-static first, the rest later
130+if(CMAKE_USE_LIBBPF_PACKAGE AND LIBBPF_FOUND)
131+set(bps_libs_to_link bpf-shared ${LIBBPF_LIBRARIES})
132+else()
133+set(bps_libs_to_link bpf-static)
134+endif()
135+list(APPEND bps_libs_to_link elf z)
136 if(BPS_LINK_RT)
137 list(APPEND bps_libs_to_link rt)
138 endif()
139diff --git a/src/cc/CMakeLists.txt b/src/cc/CMakeLists.txt
140index 4021c662..c8ea63aa 100644
141--- a/src/cc/CMakeLists.txt
142+++ b/src/cc/CMakeLists.txt
143@@ -10,8 +10,12 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/frontends/clang)
144 include_directories(${LLVM_INCLUDE_DIRS})
145 include_directories(${LIBELF_INCLUDE_DIRS})
146 # todo: if check for kernel version
147-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libbpf/include)
148-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libbpf/include/uapi)
149+if (CMAKE_USE_LIBBPF_PACKAGE AND LIBBPF_FOUND)
150+ include_directories(${LIBBPF_INCLUDE_DIRS})
151+else()
152+ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libbpf/include)
153+ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libbpf/include/uapi)
154+endif()
155
156 # add_definitions has a problem parsing "-D_GLIBCXX_USE_CXX11_ABI=0", this is safer
157 separate_arguments(LLVM_DEFINITIONS)
158@@ -41,21 +45,26 @@ if(LIBBPF_INCLUDE_DIR)
159 add_definitions(-DHAVE_EXTERNAL_LIBBPF)
160 endif()
161
162-if(LIBBPF_FOUND)
163- set(extract_dir ${CMAKE_CURRENT_BINARY_DIR}/libbpf_a_extract)
164- execute_process(COMMAND sh -c "mkdir -p ${extract_dir} && cd ${extract_dir} && ${CMAKE_AR} x ${LIBBPF_STATIC_LIBRARIES}")
165- file(GLOB libbpf_sources "${extract_dir}/*.o")
166-else()
167- file(GLOB libbpf_sources "libbpf/src/*.c")
168-endif()
169+if(NOT CMAKE_USE_LIBBPF_PACKAGE)
170+ if(LIBBPF_FOUND)
171+ set(extract_dir ${CMAKE_CURRENT_BINARY_DIR}/libbpf_a_extract)
172+ execute_process(COMMAND sh -c "mkdir -p ${extract_dir} && cd ${extract_dir} && ${CMAKE_AR} x ${LIBBPF_STATIC_LIBRARIES}")
173+ file(GLOB libbpf_sources "${extract_dir}/*.o")
174+ else()
175+ file(GLOB libbpf_sources "libbpf/src/*.c")
176+ endif()
177
178-set(libbpf_uapi libbpf/include/uapi/linux/)
179+ set(libbpf_uapi libbpf/include/uapi/linux/)
180+endif()
181
182 add_library(bpf-static STATIC libbpf.c perf_reader.c ${libbpf_sources})
183 set_target_properties(bpf-static PROPERTIES OUTPUT_NAME bcc_bpf)
184 add_library(bpf-shared SHARED libbpf.c perf_reader.c ${libbpf_sources})
185 set_target_properties(bpf-shared PROPERTIES VERSION ${REVISION_LAST} SOVERSION 0)
186 set_target_properties(bpf-shared PROPERTIES OUTPUT_NAME bcc_bpf)
187+if(CMAKE_USE_LIBBPF_PACKAGE AND LIBBPF_FOUND)
188+ target_link_libraries(bpf-shared ${LIBBPF_LIBRARIES})
189+endif()
190
191 set(bcc_common_sources bcc_common.cc bpf_module.cc bcc_btf.cc exported_files.cc)
192 if (${LLVM_PACKAGE_VERSION} VERSION_EQUAL 6 OR ${LLVM_PACKAGE_VERSION} VERSION_GREATER 6)
193diff --git a/tests/cc/CMakeLists.txt b/tests/cc/CMakeLists.txt
194index 528f1bda..b2fba5e3 100644
195--- a/tests/cc/CMakeLists.txt
196+++ b/tests/cc/CMakeLists.txt
197@@ -7,7 +7,11 @@ include_directories(${CMAKE_SOURCE_DIR}/src/cc/libbpf/include/uapi)
198 include_directories(${CMAKE_SOURCE_DIR}/tests/python/include)
199
200 add_executable(test_static test_static.c)
201-target_link_libraries(test_static bcc-static)
202+if(NOT CMAKE_USE_LIBBPF_PACKAGE)
203+ target_link_libraries(test_static bcc-static)
204+else()
205+ target_link_libraries(test_static bcc-shared-no-libbpf)
206+endif()
207
208 add_test(NAME c_test_static COMMAND ${TEST_WRAPPER} c_test_static sudo ${CMAKE_CURRENT_BINARY_DIR}/test_static)
209
210@@ -35,17 +39,19 @@ set(TEST_LIBBCC_SOURCES
211 utils.cc
212 test_parse_tracepoint.cc)
213
214-add_executable(test_libbcc ${TEST_LIBBCC_SOURCES})
215-
216 file(COPY dummy_proc_map.txt DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
217 add_library(usdt_test_lib SHARED usdt_test_lib.cc)
218
219-add_dependencies(test_libbcc bcc-shared)
220-target_link_libraries(test_libbcc ${PROJECT_BINARY_DIR}/src/cc/libbcc.so dl usdt_test_lib)
221-set_target_properties(test_libbcc PROPERTIES INSTALL_RPATH ${PROJECT_BINARY_DIR}/src/cc)
222-target_compile_definitions(test_libbcc PRIVATE -DLIBBCC_NAME=\"libbcc.so\")
223+if(NOT CMAKE_USE_LIBBPF_PACKAGE)
224+ add_executable(test_libbcc ${TEST_LIBBCC_SOURCES})
225+ add_dependencies(test_libbcc bcc-shared)
226
227-add_test(NAME test_libbcc COMMAND ${TEST_WRAPPER} c_test_all sudo ${CMAKE_CURRENT_BINARY_DIR}/test_libbcc)
228+ target_link_libraries(test_libbcc ${PROJECT_BINARY_DIR}/src/cc/libbcc.so dl usdt_test_lib)
229+ set_target_properties(test_libbcc PROPERTIES INSTALL_RPATH ${PROJECT_BINARY_DIR}/src/cc)
230+ target_compile_definitions(test_libbcc PRIVATE -DLIBBCC_NAME=\"libbcc.so\")
231+
232+ add_test(NAME test_libbcc COMMAND ${TEST_WRAPPER} c_test_all sudo ${CMAKE_CURRENT_BINARY_DIR}/test_libbcc)
233+endif()
234
235 if(LIBBPF_FOUND)
236 add_executable(test_libbcc_no_libbpf ${TEST_LIBBCC_SOURCES})
237--
2382.29.2
239
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0002-fix-compilation-error-with-latest-llvm12-trunk.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0002-fix-compilation-error-with-latest-llvm12-trunk.patch
deleted file mode 100644
index ded9f28..0000000
--- a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0002-fix-compilation-error-with-latest-llvm12-trunk.patch
+++ /dev/null
@@ -1,60 +0,0 @@
1From 35ff839b1b70b3cd7a9a025d0fd96173e7be566e Mon Sep 17 00:00:00 2001
2From: Yonghong Song <yhs@fb.com>
3Date: Mon, 4 Jan 2021 19:09:20 -0800
4Subject: [PATCH 2/2] fix compilation error with latest llvm12 trunk
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9With latest llvm trunk (llvm12), I hit the following compilation
10error:
11 ...
12 [ 17%] Building CXX object src/cc/frontends/b/CMakeFiles/b_frontend.dir/codegen_llvm.cc.o
13 /home/yhs/work/bcc/src/cc/frontends/b/codegen_llvm.cc: In member function
14 ‘virtual ebpf::StatusTuple ebpf::cc::CodegenLLVM::visit_table_decl_stmt_node(ebpf::cc::TableDeclStmtNode*)’:
15 /home/yhs/work/bcc/src/cc/frontends/b/codegen_llvm.cc:1122:37:
16 error: ‘class llvm::Module’ has no member named ‘getTypeB yName’; did you mean ‘getName’?
17 StructType *decl_struct = mod_->getTypeByName("_struct." + n->id_->name_);
18 ^~~~~~~~~~~~~
19 getName
20
21This is due to llvm patch https://reviews.llvm.org/D78793 which
22changed how to use getTypeByName(). This patch adjusted the usage
23in bcc based on this patch.
24
25Signed-off-by: Yonghong Song <yhs@fb.com>
26---
27 src/cc/frontends/b/codegen_llvm.cc | 8 ++++++++
28 1 file changed, 8 insertions(+)
29
30diff --git a/src/cc/frontends/b/codegen_llvm.cc b/src/cc/frontends/b/codegen_llvm.cc
31index d8c9470a..71c83b41 100644
32--- a/src/cc/frontends/b/codegen_llvm.cc
33+++ b/src/cc/frontends/b/codegen_llvm.cc
34@@ -1119,7 +1119,11 @@ StatusTuple CodegenLLVM::visit_table_decl_stmt_node(TableDeclStmtNode *n) {
35 StructType *key_stype, *leaf_stype;
36 TRY2(lookup_struct_type(n->key_type_, &key_stype));
37 TRY2(lookup_struct_type(n->leaf_type_, &leaf_stype));
38+#if LLVM_MAJOR_VERSION >= 12
39+ StructType *decl_struct = StructType::getTypeByName(mod_->getContext(), "_struct." + n->id_->name_);
40+#else
41 StructType *decl_struct = mod_->getTypeByName("_struct." + n->id_->name_);
42+#endif
43 if (!decl_struct)
44 decl_struct = StructType::create(ctx(), "_struct." + n->id_->name_);
45 if (decl_struct->isOpaque())
46@@ -1182,7 +1186,11 @@ StatusTuple CodegenLLVM::visit_func_decl_stmt_node(FuncDeclStmtNode *n) {
47 StructType *stype;
48 //TRY2(lookup_struct_type(formal, &stype));
49 auto var = (StructVariableDeclStmtNode *)formal;
50+#if LLVM_MAJOR_VERSION >= 12
51+ stype = StructType::getTypeByName(mod_->getContext(), "_struct." + var->struct_id_->name_);
52+#else
53 stype = mod_->getTypeByName("_struct." + var->struct_id_->name_);
54+#endif
55 if (!stype) return mkstatus_(n, "could not find type %s", var->struct_id_->c_str());
56 formals.push_back(PointerType::getUnqual(stype));
57 } else {
58--
592.30.0
60
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0003-Remove-libbcc-no-libbpf-shared-library-change-libbcc.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0003-Remove-libbcc-no-libbpf-shared-library-change-libbcc.patch
deleted file mode 100644
index 25e744f..0000000
--- a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0003-Remove-libbcc-no-libbpf-shared-library-change-libbcc.patch
+++ /dev/null
@@ -1,156 +0,0 @@
1From c7509c9e6377a374ca28d73960d505e129aace7b Mon Sep 17 00:00:00 2001
2From: Luca Boccassi <bluca@debian.org>
3Date: Fri, 8 Jan 2021 17:04:03 +0000
4Subject: [PATCH 3/3] Remove libbcc-no-libbpf shared library, change libbcc
5 linkage instead
6
7The current upstream split does not work very well, as the SONAME is mangled so
8nothing recognises it. Applications link against libbcc, not libbcc_no_bpf.
9Remove it entirely, and switch the libbcc.so to dynamically
10link with libbpf if CMAKE_USE_LIBBPF_PACKAGE is set.
11---
12 examples/cpp/CMakeLists.txt | 2 +-
13 examples/cpp/pyperf/CMakeLists.txt | 2 +-
14 src/cc/CMakeLists.txt | 36 +++++++++++++-----------------
15 tests/cc/CMakeLists.txt | 8 +++----
16 4 files changed, 21 insertions(+), 27 deletions(-)
17
18diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt
19index dd343245..45b30280 100644
20--- a/examples/cpp/CMakeLists.txt
21+++ b/examples/cpp/CMakeLists.txt
22@@ -19,7 +19,7 @@ foreach(EXAMPLE ${EXAMPLES})
23 if(NOT CMAKE_USE_LIBBPF_PACKAGE)
24 target_link_libraries(${NAME} bcc-static)
25 else()
26- target_link_libraries(${NAME} bcc-shared-no-libbpf)
27+ target_link_libraries(${NAME} bcc-shared)
28 endif()
29
30 if(INSTALL_CPP_EXAMPLES)
31diff --git a/examples/cpp/pyperf/CMakeLists.txt b/examples/cpp/pyperf/CMakeLists.txt
32index 97420806..618b4e75 100644
33--- a/examples/cpp/pyperf/CMakeLists.txt
34+++ b/examples/cpp/pyperf/CMakeLists.txt
35@@ -10,7 +10,7 @@ target_link_libraries(PyPerf bcc-static)
36 if(NOT CMAKE_USE_LIBBPF_PACKAGE)
37 target_link_libraries(PyPerf bcc-static)
38 else()
39- target_link_libraries(PyPerf bcc-shared-no-libbpf)
40+ target_link_libraries(PyPerf bcc-shared)
41 endif()
42
43 if(INSTALL_CPP_EXAMPLES)
44diff --git a/src/cc/CMakeLists.txt b/src/cc/CMakeLists.txt
45index c8ea63aa..931de2d9 100644
46--- a/src/cc/CMakeLists.txt
47+++ b/src/cc/CMakeLists.txt
48@@ -83,6 +83,9 @@ set(bcc_sym_sources bcc_syms.cc bcc_elf.c bcc_perf_map.c bcc_proc.c)
49 set(bcc_common_headers libbpf.h perf_reader.h "${CMAKE_CURRENT_BINARY_DIR}/bcc_version.h")
50 set(bcc_table_headers file_desc.h table_desc.h table_storage.h)
51 set(bcc_api_headers bcc_common.h bpf_module.h bcc_exception.h bcc_syms.h bcc_proc.h bcc_elf.h)
52+if(LIBBPF_FOUND)
53+ set(bcc_common_sources ${bcc_common_sources} libbpf.c perf_reader.c)
54+endif()
55
56 if(ENABLE_CLANG_JIT)
57 add_library(bcc-shared SHARED
58@@ -91,16 +94,6 @@ add_library(bcc-shared SHARED
59 set_target_properties(bcc-shared PROPERTIES VERSION ${REVISION_LAST} SOVERSION 0)
60 set_target_properties(bcc-shared PROPERTIES OUTPUT_NAME bcc)
61
62-# If there's libbpf detected we build the libbcc-no-libbpf.so library, that
63-# dynamicaly links libbpf.so, in comparison to static link in libbcc.so.
64-if(LIBBPF_FOUND)
65- add_library(bcc-shared-no-libbpf SHARED
66- link_all.cc ${bcc_common_sources} ${bcc_table_sources} ${bcc_sym_sources}
67- ${bcc_util_sources} libbpf.c perf_reader.c)
68- set_target_properties(bcc-shared-no-libbpf PROPERTIES VERSION ${REVISION_LAST} SOVERSION 0)
69- set_target_properties(bcc-shared-no-libbpf PROPERTIES OUTPUT_NAME bcc-no-libbpf)
70-endif()
71-
72 if(ENABLE_USDT)
73 set(bcc_usdt_sources usdt/usdt.cc usdt/usdt_args.cc)
74 # else undefined
75@@ -123,18 +116,25 @@ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${llvm_lib_exclude_f
76 set(bcc_common_libs b_frontend clang_frontend
77 -Wl,--whole-archive ${clang_libs} ${llvm_libs} -Wl,--no-whole-archive
78 ${LIBELF_LIBRARIES})
79-set(bcc_common_libs_for_a ${bcc_common_libs} bpf-static)
80-set(bcc_common_libs_for_s ${bcc_common_libs} bpf-static)
81-set(bcc_common_libs_for_n ${bcc_common_libs})
82-set(bcc_common_libs_for_lua b_frontend clang_frontend bpf-static
83+set(bcc_common_libs_for_a ${bcc_common_libs})
84+set(bcc_common_libs_for_s ${bcc_common_libs})
85+set(bcc_common_libs_for_lua b_frontend clang_frontend
86 ${clang_libs} ${llvm_libs} ${LIBELF_LIBRARIES})
87+if(LIBBPF_FOUND)
88+ list(APPEND bcc_common_libs_for_a ${LIBBPF_LIBRARIES})
89+ list(APPEND bcc_common_libs_for_s ${LIBBPF_LIBRARIES})
90+ list(APPEND bcc_common_libs_for_lua ${LIBBPF_LIBRARIES})
91+else()
92+ list(APPEND bcc_common_libs_for_a bpf-static)
93+ list(APPEND bcc_common_libs_for_s bpf-static)
94+ list(APPEND bcc_common_libs_for_lua bpf-static)
95+endif()
96
97 if(ENABLE_CPP_API)
98 add_subdirectory(api)
99 list(APPEND bcc_common_libs_for_a api-static)
100 # Keep all API functions
101 list(APPEND bcc_common_libs_for_s -Wl,--whole-archive api-static -Wl,--no-whole-archive)
102- list(APPEND bcc_common_libs_for_n -Wl,--whole-archive api-static -Wl,--no-whole-archive)
103 endif()
104
105 if(ENABLE_USDT)
106@@ -142,7 +142,6 @@ if(ENABLE_USDT)
107 add_subdirectory(usdt)
108 list(APPEND bcc_common_libs_for_a usdt-static)
109 list(APPEND bcc_common_libs_for_s usdt-static)
110- list(APPEND bcc_common_libs_for_n usdt-static)
111 list(APPEND bcc_common_libs_for_lua usdt-static)
112 endif()
113
114@@ -153,11 +152,6 @@ target_link_libraries(bcc-shared ${bcc_common_libs_for_s})
115 target_link_libraries(bcc-static ${bcc_common_libs_for_a} bcc-loader-static)
116 set(bcc-lua-static ${bcc-lua-static} ${bcc_common_libs_for_lua})
117
118-if(LIBBPF_FOUND)
119- target_link_libraries(bcc-shared-no-libbpf ${bcc_common_libs_for_n} ${LIBBPF_LIBRARIES})
120- install(TARGETS bcc-shared-no-libbpf LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
121-endif()
122-
123 install(TARGETS bcc-shared bcc-static bcc-loader-static bpf-static LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
124 install(FILES ${bcc_table_headers} DESTINATION include/bcc)
125 install(FILES ${bcc_api_headers} DESTINATION include/bcc)
126diff --git a/tests/cc/CMakeLists.txt b/tests/cc/CMakeLists.txt
127index b2fba5e3..58493248 100644
128--- a/tests/cc/CMakeLists.txt
129+++ b/tests/cc/CMakeLists.txt
130@@ -10,7 +10,7 @@ add_executable(test_static test_static.c)
131 if(NOT CMAKE_USE_LIBBPF_PACKAGE)
132 target_link_libraries(test_static bcc-static)
133 else()
134- target_link_libraries(test_static bcc-shared-no-libbpf)
135+ target_link_libraries(test_static bcc-shared)
136 endif()
137
138 add_test(NAME c_test_static COMMAND ${TEST_WRAPPER} c_test_static sudo ${CMAKE_CURRENT_BINARY_DIR}/test_static)
139@@ -55,11 +55,11 @@ endif()
140
141 if(LIBBPF_FOUND)
142 add_executable(test_libbcc_no_libbpf ${TEST_LIBBCC_SOURCES})
143- add_dependencies(test_libbcc_no_libbpf bcc-shared-no-libbpf)
144+ add_dependencies(test_libbcc_no_libbpf bcc-shared)
145
146- target_link_libraries(test_libbcc_no_libbpf ${PROJECT_BINARY_DIR}/src/cc/libbcc-no-libbpf.so dl usdt_test_lib ${LIBBPF_LIBRARIES})
147+ target_link_libraries(test_libbcc_no_libbpf ${PROJECT_BINARY_DIR}/src/cc/libbcc.so dl usdt_test_lib ${LIBBPF_LIBRARIES})
148 set_target_properties(test_libbcc_no_libbpf PROPERTIES INSTALL_RPATH ${PROJECT_BINARY_DIR}/src/cc)
149- target_compile_definitions(test_libbcc_no_libbpf PRIVATE -DLIBBCC_NAME=\"libbcc-no-libbpf.so\")
150+ target_compile_definitions(test_libbcc_no_libbpf PRIVATE -DLIBBCC_NAME=\"libbcc.so\")
151
152 add_test(NAME test_libbcc_no_libbpf COMMAND ${TEST_WRAPPER} c_test_all_no_libbpf sudo ${CMAKE_CURRENT_BINARY_DIR}/test_libbcc_no_libbpf)
153 endif()
154--
1552.29.2
156
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0004-cmake-look-for-either-static-or-dynamic-libraries.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0004-cmake-look-for-either-static-or-dynamic-libraries.patch
deleted file mode 100644
index 31bcbcd..0000000
--- a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0004-cmake-look-for-either-static-or-dynamic-libraries.patch
+++ /dev/null
@@ -1,69 +0,0 @@
1From 6b4222cd41b3f5e833307aeff2b10c6b084d3f4f Mon Sep 17 00:00:00 2001
2From: Matteo Croce <mcroce@microsoft.com>
3Date: Wed, 27 Jan 2021 00:26:39 +0100
4Subject: [PATCH] cmake: look for either static or dynamic libraries
5
6On some distro, static libraries are shipped in a separate package.
7Look for either a static or dynamic libbpf, and only fail if neither is found.
8---
9 cmake/FindLibBpf.cmake | 23 ++++++++++++++++-------
10 1 file changed, 16 insertions(+), 7 deletions(-)
11
12diff --git a/cmake/FindLibBpf.cmake b/cmake/FindLibBpf.cmake
13index 75683ae3d..dc10dcee4 100644
14--- a/cmake/FindLibBpf.cmake
15+++ b/cmake/FindLibBpf.cmake
16@@ -28,9 +28,9 @@ find_path (LIBBPF_INCLUDE_DIR
17 /sw/include
18 ENV CPATH)
19
20-find_library (LIBBPF_STATIC_LIBRARIES
21+find_library (LIBBPF_LIBRARIES
22 NAMES
23- libbpf.a
24+ bpf
25 PATHS
26 /usr/lib
27 /usr/local/lib
28@@ -38,10 +38,13 @@ find_library (LIBBPF_STATIC_LIBRARIES
29 /sw/lib
30 ENV LIBRARY_PATH
31 ENV LD_LIBRARY_PATH)
32+if(LIBBPF_LIBRARIES)
33+list(APPEND PATHS LIBBPF_LIBRARIES)
34+endif()
35
36-find_library (LIBBPF_LIBRARIES
37+find_library (LIBBPF_STATIC_LIBRARIES
38 NAMES
39- bpf
40+ libbpf.a
41 PATHS
42 /usr/lib
43 /usr/local/lib
44@@ -49,13 +52,19 @@ find_library (LIBBPF_LIBRARIES
45 /sw/lib
46 ENV LIBRARY_PATH
47 ENV LD_LIBRARY_PATH)
48+if(LIBBPF_STATIC_LIBRARIES)
49+list(APPEND PATHS LIBBPF_STATIC_LIBRARIES)
50+endif()
51
52+if(LIBBPF_STATIC_LIBRARIES OR LIBBPF_LIBRARIES)
53 include (FindPackageHandleStandardArgs)
54
55 # handle the QUIETLY and REQUIRED arguments and set LIBBPF_FOUND to TRUE if all listed variables are TRUE
56 FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibBpf "Please install the libbpf development package"
57- LIBBPF_LIBRARIES
58- LIBBPF_STATIC_LIBRARIES
59+ ${PATHS}
60 LIBBPF_INCLUDE_DIR)
61
62-mark_as_advanced(LIBBPF_INCLUDE_DIR LIBBPF_STATIC_LIBRARIES LIBBPF_LIBRARIES)
63+mark_as_advanced(LIBBPF_INCLUDE_DIR ${PATHS})
64+else()
65+message(Please install the libbpf development package)
66+endif()
67--
682.29.2
69
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.17.0.bb b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.20.0.bb
index 8953fd4..1c24555 100644
--- a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.17.0.bb
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.20.0.bb
@@ -18,28 +18,23 @@ LUAJIT_powerpc64 = ""
18 18
19RDEPENDS_${PN} += "bash python3 python3-core python3-setuptools xz" 19RDEPENDS_${PN} += "bash python3 python3-core python3-setuptools xz"
20 20
21# Don't fetch submodules otherwise we fetch an older, vendored libbpf version 21SRC_URI = "gitsm://github.com/iovisor/bcc \
22# We use a dynamic libbpf library instead
23SRC_URI = "git://github.com/iovisor/bcc \
24 file://0001-python-CMakeLists.txt-Remove-check-for-host-etc-debi.patch \ 22 file://0001-python-CMakeLists.txt-Remove-check-for-host-etc-debi.patch \
25 file://0001-tools-trace.py-Fix-failing-to-exit.patch \ 23 file://0001-tools-trace.py-Fix-failing-to-exit.patch \
26 file://0001-CMakeLists.txt-override-the-PY_CMD_ESCAPED.patch \ 24 file://0001-CMakeLists.txt-override-the-PY_CMD_ESCAPED.patch \
27 file://0001-fix-compilation-issues-with-latest-llvm12-trunk.patch \
28 file://0002-fix-compilation-error-with-latest-llvm12-trunk.patch \
29 file://0001-cmake-link-dynamically-to-libclang-cpp-if-found-and-.patch \
30 file://0002-cmake-always-link-to-packaged-libbpf-if-CMAKE_USE_LI.patch \
31 file://0003-Remove-libbcc-no-libbpf-shared-library-change-libbcc.patch \
32 file://0004-cmake-look-for-either-static-or-dynamic-libraries.patch \
33 " 25 "
34 26
35DEPENDS += "libbpf" 27SRCREV = "ab14fafec3fc13f89bd4678b7fc94829dcacaa7b"
36 28
37SRCREV = "ad5b82a5196b222ed2cdc738d8444e8c9546a77f" 29PV .= "+git${SRCPV}"
38 30
39S = "${WORKDIR}/git" 31S = "${WORKDIR}/git"
40 32
41PACKAGECONFIG ??= "" 33PACKAGECONFIG ??= "examples"
34PACKAGECONFIG_remove_libc-musl = "examples"
35
42PACKAGECONFIG[manpages] = "-DENABLE_MAN=ON,-DENABLE_MAN=OFF," 36PACKAGECONFIG[manpages] = "-DENABLE_MAN=ON,-DENABLE_MAN=OFF,"
37PACKAGECONFIG[examples] = "-DENABLE_EXAMPLES=ON,-DENABLE_EXAMPLES=OFF,"
43 38
44EXTRA_OECMAKE = " \ 39EXTRA_OECMAKE = " \
45 -DENABLE_LLVM_SHARED=ON \ 40 -DENABLE_LLVM_SHARED=ON \
@@ -47,7 +42,6 @@ EXTRA_OECMAKE = " \
47 -DLLVM_PACKAGE_VERSION=${LLVMVERSION} \ 42 -DLLVM_PACKAGE_VERSION=${LLVMVERSION} \
48 -DPYTHON_CMD=${PYTHON} \ 43 -DPYTHON_CMD=${PYTHON} \
49 -DPYTHON_FLAGS=--install-lib=${PYTHON_SITEPACKAGES_DIR} \ 44 -DPYTHON_FLAGS=--install-lib=${PYTHON_SITEPACKAGES_DIR} \
50 -DCMAKE_USE_LIBBPF_PACKAGE=ON \
51" 45"
52 46
53do_install_append() { 47do_install_append() {