summaryrefslogtreecommitdiffstats
path: root/dynamic-layers
diff options
context:
space:
mode:
Diffstat (limited to 'dynamic-layers')
-rw-r--r--dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland_%.bbappend6
-rw-r--r--dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-x11_%.bbappend6
-rw-r--r--dynamic-layers/chromium-browser-layer/recipes-browser/chromium/gn-native_%.bbappend6
-rw-r--r--dynamic-layers/meta-intel/recipes-multimedia/mediasdk/intel-mediasdk/intel-mediasdk-20.5.1-no-lgcc.patch30
-rw-r--r--dynamic-layers/meta-intel/recipes-multimedia/mediasdk/intel-mediasdk_%.bbappend3
-rw-r--r--dynamic-layers/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp/optee-fix-build-with-clang.patch67
-rw-r--r--dynamic-layers/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp_%.bbappend7
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Add-KBUILD_MODNAME-flag-to-default-cflags.patch27
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-CMakeLists.txt-override-the-PY_CMD_ESCAPED.patch46
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Delete-existing-kbuild_modname-definitions.patch176
-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.patch35
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-tools-trace.py-Fix-failing-to-exit.patch46
-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.17.0.bb (renamed from dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.13.0.bb)26
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-bpforc.h-Include-optional-header.patch31
-rw-r--r--dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.11.4.bb (renamed from dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.9.4.bb)7
22 files changed, 1140 insertions, 229 deletions
diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland_%.bbappend b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland_%.bbappend
new file mode 100644
index 0000000..554578e
--- /dev/null
+++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland_%.bbappend
@@ -0,0 +1,6 @@
1FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
2
3DEPENDS_remove = "compiler-rt-native libcxx-native"
4
5BUILD_CPPFLAGS_remove = "-isysroot=${STAGING_DIR_NATIVE} -stdlib=libc++"
6BUILD_LDFLAGS_remove = "-rtlib=libgcc -unwindlib=libgcc -stdlib=libc++ -lc++abi -rpath ${STAGING_LIBDIR_NATIVE}"
diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-x11_%.bbappend b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-x11_%.bbappend
new file mode 100644
index 0000000..554578e
--- /dev/null
+++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-x11_%.bbappend
@@ -0,0 +1,6 @@
1FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
2
3DEPENDS_remove = "compiler-rt-native libcxx-native"
4
5BUILD_CPPFLAGS_remove = "-isysroot=${STAGING_DIR_NATIVE} -stdlib=libc++"
6BUILD_LDFLAGS_remove = "-rtlib=libgcc -unwindlib=libgcc -stdlib=libc++ -lc++abi -rpath ${STAGING_LIBDIR_NATIVE}"
diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/gn-native_%.bbappend b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/gn-native_%.bbappend
new file mode 100644
index 0000000..cd60c58
--- /dev/null
+++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/gn-native_%.bbappend
@@ -0,0 +1,6 @@
1FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
2
3DEPENDS_remove = "compiler-rt-native libcxx-native"
4
5CXXFLAGS_remove = "-isysroot=${STAGING_DIR_NATIVE} -stdlib=libc++"
6LDFLAGS_remove = "-rtlib=libgcc -unwindlib=libgcc -stdlib=libc++ -lc++abi -rpath ${STAGING_LIBDIR_NATIVE}"
diff --git a/dynamic-layers/meta-intel/recipes-multimedia/mediasdk/intel-mediasdk/intel-mediasdk-20.5.1-no-lgcc.patch b/dynamic-layers/meta-intel/recipes-multimedia/mediasdk/intel-mediasdk/intel-mediasdk-20.5.1-no-lgcc.patch
new file mode 100644
index 0000000..866dbcd
--- /dev/null
+++ b/dynamic-layers/meta-intel/recipes-multimedia/mediasdk/intel-mediasdk/intel-mediasdk-20.5.1-no-lgcc.patch
@@ -0,0 +1,30 @@
1Author: Bernhard Rosenkraenzer <bernhard.rosenkraenzer.ext@huawei.com>
2
3Remove -lgcc -- it's unneeded and breaks building with compiler-rt.
4
5Signed-off-by: Bernhard Rosenkraenzer <bernhard.rosenkraenzer.ext@huawei.com>
6Upstream-Status: Pending
7
8diff -up git/builder/FindFunctions.cmake.omv~ git/builder/FindFunctions.cmake
9--- git/builder/FindFunctions.cmake.omv~ 2021-06-03 20:35:11.230895070 +0200
10+++ git/builder/FindFunctions.cmake 2021-06-03 20:35:49.750360067 +0200
11@@ -200,10 +200,6 @@ function( make_library name variant type
12 set_target_properties( ${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BIN_DIR}/${CMAKE_BUILD_TYPE} FOLDER ${folder} )
13 set_target_properties( ${target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_LIB_DIR}/${CMAKE_BUILD_TYPE} FOLDER ${folder} )
14
15- if( Linux )
16- target_link_libraries( ${target} "-lgcc" )
17- endif()
18-
19 set( target ${target} PARENT_SCOPE )
20 endfunction()
21
22@@ -278,7 +274,7 @@ function( make_executable name variant )
23 endforeach()
24
25 if( Linux )
26- target_link_libraries( ${target} "-Xlinker --end-group -lgcc" )
27+ target_link_libraries( ${target} "-Xlinker --end-group" )
28 endif()
29
30 set( target ${target} PARENT_SCOPE )
diff --git a/dynamic-layers/meta-intel/recipes-multimedia/mediasdk/intel-mediasdk_%.bbappend b/dynamic-layers/meta-intel/recipes-multimedia/mediasdk/intel-mediasdk_%.bbappend
new file mode 100644
index 0000000..d070d03
--- /dev/null
+++ b/dynamic-layers/meta-intel/recipes-multimedia/mediasdk/intel-mediasdk_%.bbappend
@@ -0,0 +1,3 @@
1FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
2
3SRC_URI_append_toolchain-clang = " file://intel-mediasdk-20.5.1-no-lgcc.patch"
diff --git a/dynamic-layers/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp/optee-fix-build-with-clang.patch b/dynamic-layers/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp/optee-fix-build-with-clang.patch
new file mode 100644
index 0000000..6581d77
--- /dev/null
+++ b/dynamic-layers/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp/optee-fix-build-with-clang.patch
@@ -0,0 +1,67 @@
1From: Bernhard Rosenkraenzer <bernhard.rosenkraenzer.ext@huawei.com>
2Subject: [optee-os-stm] Fix build with clang
3
4Fix build with clang: No suffix to RCC_MP_ENCLRR_OFFSET (it's used
5in assembly code), fix warning in mbedtls, look for compiler-rt
6inside the sysroot instead of on the system
7
8Signed-off-by: Bernhard Rosenkraenzer <bernhard.rosenkraenzer.ext@huawei.com>
9Upstream-Status: Pending
10
11diff -up git/core/include/drivers/stm32mp1_rcc.h.omv~ git/core/include/drivers/stm32mp1_rcc.h
12--- git/core/include/drivers/stm32mp1_rcc.h.omv~ 2021-06-04 23:35:39.741212399 +0200
13+++ git/core/include/drivers/stm32mp1_rcc.h 2021-06-04 23:37:28.856900701 +0200
14@@ -280,10 +280,10 @@
15 #define RCC_TIMGXPRER_TIMGXPRE BIT(0)
16
17 /* Offset between RCC_MP_xxxENSETR and RCC_MP_xxxENCLRR registers */
18-#define RCC_MP_ENCLRR_OFFSET 4u
19+#define RCC_MP_ENCLRR_OFFSET 4
20
21 /* Offset between RCC_MP_xxxRSTSETR and RCC_MP_xxxRSTCLRR registers */
22-#define RCC_MP_RSTCLRR_OFFSET 4u
23+#define RCC_MP_RSTCLRR_OFFSET 4
24
25 /* Fields of RCC_BDCR register */
26 #define RCC_BDCR_LSEON BIT(0)
27diff -up git/lib/libmbedtls/mbedtls/library/md5.c.omv~ git/lib/libmbedtls/mbedtls/library/md5.c
28--- git/lib/libmbedtls/mbedtls/library/md5.c.omv~ 2021-06-04 23:35:39.742212415 +0200
29+++ git/lib/libmbedtls/mbedtls/library/md5.c 2021-06-04 23:37:28.857900716 +0200
30@@ -428,8 +428,8 @@ static const unsigned char md5_test_buf[
31 { "message digest" },
32 { "abcdefghijklmnopqrstuvwxyz" },
33 { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" },
34- { "12345678901234567890123456789012345678901234567890123456789012"
35- "345678901234567890" }
36+ { ("12345678901234567890123456789012345678901234567890123456789012"
37+ "345678901234567890") }
38 };
39
40 static const size_t md5_test_buflen[7] =
41diff -up git/mk/clang.mk.omv~ git/mk/clang.mk
42--- git/mk/clang.mk.omv~ 2021-06-04 23:35:39.742212415 +0200
43+++ git/mk/clang.mk 2021-06-04 23:38:35.887937844 +0200
44@@ -25,10 +25,11 @@ nostdinc$(sm) := -nostdinc -isystem $(sh
45 comp-cflags-warns-clang := -Wno-language-extension-token \
46 -Wno-gnu-zero-variadic-macro-arguments
47
48+SYSROOT := $(shell echo $(CC) |sed -e 's,.*--sysroot=,,;s, .*,,g')
49 # Note, use the compiler runtime library (libclang_rt.builtins.*.a) instead of
50 # libgcc for clang
51-libgcc$(sm) := $(shell $(CC$(sm)) $(CFLAGS$(arch-bits-$(sm))) \
52- -rtlib=compiler-rt -print-libgcc-file-name 2> /dev/null)
53+libgcc$(sm) := $(SYSROOT)/$(shell echo $(shell $(CC$(sm)) $(CFLAGS$(arch-bits-$(sm))) \
54+ -rtlib=compiler-rt -print-libgcc-file-name 2> /dev/null) |sed -e 's,-arm\.a,-armhf.a,')
55
56 # Core ASLR relies on the executable being ready to run from its preferred load
57 # address, because some symbols are used before the MMU is enabled and the
58@@ -36,7 +37,8 @@ libgcc$(sm) := $(shell $(CC$(sm)) $(CFLA
59 ldflag-apply-dynamic-relocs := --apply-dynamic-relocs
60
61 # Define these to something to discover accidental use
62-CC := false
63+# Not CC because we need it to determine SYSROOT
64+#CC := false
65 CXX := false
66 CPP := false
67 LD := false
diff --git a/dynamic-layers/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp_%.bbappend b/dynamic-layers/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp_%.bbappend
new file mode 100644
index 0000000..cb513d3
--- /dev/null
+++ b/dynamic-layers/meta-st-stm32mp/recipes-security/optee/optee-os-stm32mp_%.bbappend
@@ -0,0 +1,7 @@
1FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
2
3SRC_URI_append_toolchain-clang = " file://optee-fix-build-with-clang.patch"
4
5EXTRA_OEMAKE_append_toolchain-clang = "COMPILER=clang"
6
7DEPENDS_append_toolchain-clang = "compiler-rt"
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Add-KBUILD_MODNAME-flag-to-default-cflags.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Add-KBUILD_MODNAME-flag-to-default-cflags.patch
deleted file mode 100644
index 1ca73ba..0000000
--- a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Add-KBUILD_MODNAME-flag-to-default-cflags.patch
+++ /dev/null
@@ -1,27 +0,0 @@
1From 9e2415679e41adacc59dd7a426d505232f0b7129 Mon Sep 17 00:00:00 2001
2From: William Findlay <william@williamfindlay.com>
3Date: Wed, 17 Jun 2020 12:07:48 -0400
4Subject: [PATCH 1/2] Add KBUILD_MODNAME flag to default cflags
5
6Upstream-Status: Backported [https://github.com/iovisor/bcc/pull/2974/commits/badd85c58549d0e7f0d536490c41213141e180c5]
7
8Signed-off-by: He Zhe <zhe.he@windriver.com>
9---
10 src/cc/frontends/clang/kbuild_helper.cc | 1 +
11 1 file changed, 1 insertion(+)
12
13diff --git a/src/cc/frontends/clang/kbuild_helper.cc b/src/cc/frontends/clang/kbuild_helper.cc
14index db5ca7f6..e3aade89 100644
15--- a/src/cc/frontends/clang/kbuild_helper.cc
16+++ b/src/cc/frontends/clang/kbuild_helper.cc
17@@ -101,6 +101,7 @@ int KBuildHelper::get_flags(const char *uname_machine, vector<string> *cflags) {
18 cflags->push_back("-D__HAVE_BUILTIN_BSWAP16__");
19 cflags->push_back("-D__HAVE_BUILTIN_BSWAP32__");
20 cflags->push_back("-D__HAVE_BUILTIN_BSWAP64__");
21+ cflags->push_back("-DKBUILD_MODNAME=\"bcc\"");
22
23 // If ARCH env variable is set, pass this along.
24 if (archenv)
25--
262.26.2
27
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-CMakeLists.txt-override-the-PY_CMD_ESCAPED.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-CMakeLists.txt-override-the-PY_CMD_ESCAPED.patch
new file mode 100644
index 0000000..a08c109
--- /dev/null
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-CMakeLists.txt-override-the-PY_CMD_ESCAPED.patch
@@ -0,0 +1,46 @@
1From 4f64ed40e1ffea7ea278627f30a01018e57dcbcf Mon Sep 17 00:00:00 2001
2From: Mingli Yu <mingli.yu@windriver.com>
3Date: Wed, 9 Sep 2020 05:48:19 +0000
4Subject: [PATCH] CMakeLists.txt: override the PY_CMD_ESCAPED
5
6Override the PY_CMD_ESCAPED as the PY_CMD_ESCAPED is constructed by
7the full path of the python3. In some cases, the path is so long and
8result in the PY_CMD_ESCAPED exceeds 255 characters and comes below
9do_configure error:
10 | CMake Error at src/python/CMakeLists.txt:18 (configure_file):
11 | configure_file Problem configuring file
12 |
13 | CMake Error: Could not open file for write in copy operation /buildarea1/test/wr_build/wr1020_20200909_bcc/bcc_long_Kernel/auto-standalone_next/200827/lxbuilds/Intel-Snow-Ridge-NS_platform_up/intel-x86-64-standard-glibc-std/wrlinux/build/tmp-glibc/work/corei7-64-wrs-linux/bcc/0.15.0-r0/build/src/python/bcc--buildarea1-test-wr_build-wr1020_20200909_bcc-bcc_long_Kernel-auto-standalone_next-200827-lxbuilds-Intel-Snow-Ridge-NS_platform_up-intel-x86-64-standard-glibc-std-wrlinux-build-tmp-glibc-work-corei7-64-wrs-linux-bcc-0.15.0-r0-recipe-sysroot-native-usr-bin-python3-native-python3/bcc/version.py.tmp
14
15Upstream-Status: Pending
16
17Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
18---
19 src/python/CMakeLists.txt | 4 ++--
20 1 file changed, 2 insertions(+), 2 deletions(-)
21
22diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt
23index 797e0d14..8afa6ffa 100644
24--- a/src/python/CMakeLists.txt
25+++ b/src/python/CMakeLists.txt
26@@ -12,7 +12,7 @@ file(GLOB_RECURSE PYTHON_INCLUDES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
27
28 foreach(PY_CMD ${PYTHON_CMD})
29 string(REPLACE "/" "-" PY_CMD_ESCAPED ${PY_CMD})
30- set(PY_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bcc-${PY_CMD_ESCAPED})
31+ set(PY_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bcc-python3)
32
33 foreach(PY_SRC ${PYTHON_SOURCES})
34 configure_file(${PY_SRC} ${PY_DIRECTORY}/${PY_SRC} COPYONLY)
35@@ -31,7 +31,7 @@ foreach(PY_CMD ${PYTHON_CMD})
36 DEPENDS ${PYTHON_SOURCES} ${PYTHON_INCLUDES}
37 COMMENT "Building sdist for ${PY_CMD}"
38 )
39- add_custom_target(bcc_py_${PY_CMD_ESCAPED} ALL DEPENDS ${PIP_INSTALLABLE})
40+ add_custom_target(bcc_py_python3 ALL DEPENDS ${PIP_INSTALLABLE})
41
42 install(
43 CODE "
44--
452.26.2
46
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Delete-existing-kbuild_modname-definitions.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Delete-existing-kbuild_modname-definitions.patch
deleted file mode 100644
index dd87997..0000000
--- a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Delete-existing-kbuild_modname-definitions.patch
+++ /dev/null
@@ -1,176 +0,0 @@
1From eb8b0487a05d650499b20fdd5edeb6e47c2c17a5 Mon Sep 17 00:00:00 2001
2From: William Findlay <william@williamfindlay.com>
3Date: Wed, 17 Jun 2020 18:59:43 -0400
4Subject: [PATCH 2/2] Delete existing kbuild_modname definitions
5
6Upstream-Status: Backported [https://github.com/iovisor/bcc/pull/2974/commits/a5bdc9c65746389d7072e1e8e583025dde78e91b]
7
8Adjust context
9
10Signed-off-by: He Zhe <zhe.he@windriver.com>
11---
12 examples/networking/xdp/xdp_drop_count.py | 1 -
13 examples/networking/xdp/xdp_macswap_count.py | 1 -
14 examples/networking/xdp/xdp_redirect_cpu.py | 1 -
15 examples/networking/xdp/xdp_redirect_map.py | 1 -
16 tests/python/test_clang.py | 8 --------
17 tools/tcplife.lua | 1 -
18 tools/tcplife.py | 1 -
19 tools/tcpstates.py | 1 -
20 8 files changed, 15 deletions(-)
21
22diff --git a/examples/networking/xdp/xdp_drop_count.py b/examples/networking/xdp/xdp_drop_count.py
23index f03273e9..512e0a20 100755
24--- a/examples/networking/xdp/xdp_drop_count.py
25+++ b/examples/networking/xdp/xdp_drop_count.py
26@@ -52,7 +52,6 @@ else:
27
28 # load BPF program
29 b = BPF(text = """
30-#define KBUILD_MODNAME "foo"
31 #include <uapi/linux/bpf.h>
32 #include <linux/in.h>
33 #include <linux/if_ether.h>
34diff --git a/examples/networking/xdp/xdp_macswap_count.py b/examples/networking/xdp/xdp_macswap_count.py
35index 0e2b21ca..770ce8ca 100755
36--- a/examples/networking/xdp/xdp_macswap_count.py
37+++ b/examples/networking/xdp/xdp_macswap_count.py
38@@ -50,7 +50,6 @@ else:
39
40 # load BPF program
41 b = BPF(text = """
42-#define KBUILD_MODNAME "foo"
43 #include <uapi/linux/bpf.h>
44 #include <linux/in.h>
45 #include <linux/if_ether.h>
46diff --git a/examples/networking/xdp/xdp_redirect_cpu.py b/examples/networking/xdp/xdp_redirect_cpu.py
47index 15b0d09b..470079f4 100755
48--- a/examples/networking/xdp/xdp_redirect_cpu.py
49+++ b/examples/networking/xdp/xdp_redirect_cpu.py
50@@ -30,7 +30,6 @@ if (cpu_id > max_cpu):
51
52 # load BPF program
53 b = BPF(text = """
54-#define KBUILD_MODNAME "foo"
55 #include <uapi/linux/bpf.h>
56 #include <linux/in.h>
57 #include <linux/if_ether.h>
58diff --git a/examples/networking/xdp/xdp_redirect_map.py b/examples/networking/xdp/xdp_redirect_map.py
59index 4a622723..4936ac1e 100755
60--- a/examples/networking/xdp/xdp_redirect_map.py
61+++ b/examples/networking/xdp/xdp_redirect_map.py
62@@ -29,7 +29,6 @@ out_idx = ip.link_lookup(ifname=out_if)[0]
63
64 # load BPF program
65 b = BPF(text = """
66-#define KBUILD_MODNAME "foo"
67 #include <uapi/linux/bpf.h>
68 #include <linux/in.h>
69 #include <linux/if_ether.h>
70diff --git a/tests/python/test_clang.py b/tests/python/test_clang.py
71index 886eebed..648494cf 100755
72--- a/tests/python/test_clang.py
73+++ b/tests/python/test_clang.py
74@@ -78,7 +78,6 @@ int count_foo(struct pt_regs *ctx, unsigned long a, unsigned long b) {
75
76 def test_probe_read3(self):
77 text = """
78-#define KBUILD_MODNAME "foo"
79 #include <net/tcp.h>
80 #define _(P) ({typeof(P) val = 0; bpf_probe_read(&val, sizeof(val), &P); val;})
81 int count_tcp(struct pt_regs *ctx, struct sk_buff *skb) {
82@@ -90,7 +89,6 @@ int count_tcp(struct pt_regs *ctx, struct sk_buff *skb) {
83
84 def test_probe_read4(self):
85 text = """
86-#define KBUILD_MODNAME "foo"
87 #include <net/tcp.h>
88 #define _(P) ({typeof(P) val = 0; bpf_probe_read(&val, sizeof(val), &P); val;})
89 int test(struct pt_regs *ctx, struct sk_buff *skb) {
90@@ -102,7 +100,6 @@ int test(struct pt_regs *ctx, struct sk_buff *skb) {
91
92 def test_probe_read_whitelist1(self):
93 text = """
94-#define KBUILD_MODNAME "foo"
95 #include <net/tcp.h>
96 int count_tcp(struct pt_regs *ctx, struct sk_buff *skb) {
97 // The below define is in net/tcp.h:
98@@ -120,7 +117,6 @@ int count_tcp(struct pt_regs *ctx, struct sk_buff *skb) {
99
100 def test_probe_read_whitelist2(self):
101 text = """
102-#define KBUILD_MODNAME "foo"
103 #include <net/tcp.h>
104 int count_tcp(struct pt_regs *ctx, struct sk_buff *skb) {
105 // The below define is in net/tcp.h:
106@@ -1072,7 +1068,6 @@ int test(struct __sk_buff *ctx) {
107
108 def test_probe_read_return(self):
109 text = """
110-#define KBUILD_MODNAME "foo"
111 #include <uapi/linux/ptrace.h>
112 #include <linux/tcp.h>
113 static inline unsigned char *my_skb_transport_header(struct sk_buff *skb) {
114@@ -1088,7 +1083,6 @@ int test(struct pt_regs *ctx, struct sock *sk, struct sk_buff *skb) {
115
116 def test_probe_read_multiple_return(self):
117 text = """
118-#define KBUILD_MODNAME "foo"
119 #include <uapi/linux/ptrace.h>
120 #include <linux/tcp.h>
121 static inline u64 error_function() {
122@@ -1109,7 +1103,6 @@ int test(struct pt_regs *ctx, struct sock *sk, struct sk_buff *skb) {
123
124 def test_probe_read_return_expr(self):
125 text = """
126-#define KBUILD_MODNAME "foo"
127 #include <uapi/linux/ptrace.h>
128 #include <linux/tcp.h>
129 static inline unsigned char *my_skb_transport_header(struct sk_buff *skb) {
130@@ -1125,7 +1118,6 @@ int test(struct pt_regs *ctx, struct sock *sk, struct sk_buff *skb) {
131
132 def test_probe_read_return_call(self):
133 text = """
134-#define KBUILD_MODNAME "foo"
135 #include <uapi/linux/ptrace.h>
136 #include <linux/tcp.h>
137 static inline struct tcphdr *my_skb_transport_header(struct sk_buff *skb) {
138diff --git a/tools/tcplife.lua b/tools/tcplife.lua
139index 3f4f6afd..5e311631 100755
140--- a/tools/tcplife.lua
141+++ b/tools/tcplife.lua
142@@ -25,7 +25,6 @@ uint16_t ntohs(uint16_t netshort);
143
144 local program = [[
145 #include <uapi/linux/ptrace.h>
146-#define KBUILD_MODNAME "foo"
147 #include <linux/tcp.h>
148 #include <net/sock.h>
149 #include <bcc/proto.h>
150diff --git a/tools/tcplife.py b/tools/tcplife.py
151index d4e679dd..c2bd8236 100755
152--- a/tools/tcplife.py
153+++ b/tools/tcplife.py
154@@ -66,7 +66,6 @@ debug = 0
155 # define BPF program
156 bpf_text = """
157 #include <uapi/linux/ptrace.h>
158-#define KBUILD_MODNAME "foo"
159 #include <linux/tcp.h>
160 #include <net/sock.h>
161 #include <bcc/proto.h>
162diff --git a/tools/tcpstates.py b/tools/tcpstates.py
163index b9a64387..09bbe0ce 100755
164--- a/tools/tcpstates.py
165+++ b/tools/tcpstates.py
166@@ -61,7 +61,6 @@ debug = 0
167 # define BPF program
168 bpf_text = """
169 #include <uapi/linux/ptrace.h>
170-#define KBUILD_MODNAME "foo"
171 #include <linux/tcp.h>
172 #include <net/sock.h>
173 #include <bcc/proto.h>
174--
1752.26.2
176
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
new file mode 100644
index 0000000..ef93296
--- /dev/null
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-Replace-kprobe-function-blk_account_io_completion-to.patch
@@ -0,0 +1,169 @@
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
new file mode 100644
index 0000000..74b2e27
--- /dev/null
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-cmake-link-dynamically-to-libclang-cpp-if-found-and-.patch
@@ -0,0 +1,68 @@
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
new file mode 100644
index 0000000..b1f56e6
--- /dev/null
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-fix-compilation-issues-with-latest-llvm12-trunk.patch
@@ -0,0 +1,89 @@
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
index f2b1495..fb659cc 100644
--- 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
@@ -1,4 +1,4 @@
1From 935f7e47f54df1af30f4a1cdfd2f385863ab9dec Mon Sep 17 00:00:00 2001 1From 8e12b10e7576a6d47e0dc2cdc36caeb9ba26fa12 Mon Sep 17 00:00:00 2001
2From: He Zhe <zhe.he@windriver.com> 2From: He Zhe <zhe.he@windriver.com>
3Date: Mon, 15 Jun 2020 07:05:24 +0000 3Date: Mon, 15 Jun 2020 07:05:24 +0000
4Subject: [PATCH] tools: opensnoop: snoop do_sys_openat2 for kernel v5.6 and 4Subject: [PATCH] tools: opensnoop: snoop do_sys_openat2 for kernel v5.6 and
@@ -12,14 +12,14 @@ Upstream-Status: Inappropriate, upstream context has changed and needs more
12 12
13Signed-off-by: He Zhe <zhe.he@windriver.com> 13Signed-off-by: He Zhe <zhe.he@windriver.com>
14--- 14---
15 tools/opensnoop.py | 13 +++++++++++-- 15 tools/opensnoop.py | 12 ++++++++++--
16 1 file changed, 11 insertions(+), 2 deletions(-) 16 1 file changed, 10 insertions(+), 2 deletions(-)
17 17
18diff --git a/tools/opensnoop.py b/tools/opensnoop.py 18diff --git a/tools/opensnoop.py b/tools/opensnoop.py
19index 6d1388b3..3f7e48a3 100755 19index 51d3dc05..522812d4 100755
20--- a/tools/opensnoop.py 20--- a/tools/opensnoop.py
21+++ b/tools/opensnoop.py 21+++ b/tools/opensnoop.py
22@@ -21,6 +21,8 @@ from bcc.utils import printb 22@@ -22,6 +22,8 @@ from bcc.utils import printb
23 import argparse 23 import argparse
24 from datetime import datetime, timedelta 24 from datetime import datetime, timedelta
25 import os 25 import os
@@ -28,24 +28,23 @@ index 6d1388b3..3f7e48a3 100755
28 28
29 # arguments 29 # arguments
30 examples = """examples: 30 examples = """examples:
31@@ -195,8 +197,15 @@ if debug or args.ebpf: 31@@ -235,8 +237,14 @@ if debug or args.ebpf:
32
33 # initialize BPF 32 # initialize BPF
34 b = BPF(text=bpf_text) 33 b = BPF(text=bpf_text)
35-b.attach_kprobe(event="do_sys_open", fn_name="trace_entry") 34 if not is_support_kfunc:
36-b.attach_kretprobe(event="do_sys_open", fn_name="trace_return") 35- b.attach_kprobe(event="do_sys_open", fn_name="trace_entry")
37+ 36- b.attach_kretprobe(event="do_sys_open", fn_name="trace_return")
38+# Since kernel v5.6, do_sys_openat2 instead of do_sys_open has been used as entry function for open 37+ # Since kernel v5.6, do_sys_openat2 instead of do_sys_open has been used as entry function for open
39+if parse_version(platform.uname().release.split('-')[0]) > parse_version('5.6.0'): 38+ if parse_version(platform.uname().release.split('-')[0]) > parse_version('5.6.0'):
40+ entry = "do_sys_openat2" 39+ entry = "do_sys_openat2"
41+else: 40+ else:
42+ entry = "do_sys_open" 41+ entry = "do_sys_open"
43+ 42+
44+b.attach_kprobe(event=entry, fn_name="trace_entry") 43+ b.attach_kprobe(event=entry, fn_name="trace_entry")
45+b.attach_kretprobe(event=entry, fn_name="trace_return") 44+ b.attach_kretprobe(event=entry, fn_name="trace_return")
46 45
47 initial_ts = 0 46 initial_ts = 0
48 47
49-- 48--
502.24.1 492.17.1
51 50
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-tools-trace.py-Fix-failing-to-exit.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-tools-trace.py-Fix-failing-to-exit.patch
new file mode 100644
index 0000000..e39e21f
--- /dev/null
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0001-tools-trace.py-Fix-failing-to-exit.patch
@@ -0,0 +1,46 @@
1From a9f59fc8605de1bcca0b6c2d8132585f40c3b9bc Mon Sep 17 00:00:00 2001
2From: He Zhe <zhe.he@windriver.com>
3Date: Thu, 13 Aug 2020 11:25:58 +0800
4Subject: [PATCH] tools/trace.py: Fix failing to exit
5
6Class Probe::print_event is used as a callback of a ctypes wrapper. With
7Yocto latest python v3.8.5, the exception raised by exit() is ignored and
8thus trace cannot exit. Use os._exit(0) instead.
9
10$ /usr/share/bcc/tools/trace do_sys_open -M 1
11PID TID COMM FUNC
123740 3740 irqbalance do_sys_open
13Exception ignored on calling ctypes callback function:
14<function PerfEventArray.open_perf_buffer.<locals>.raw_cb at 0x7f7c9efea280>
15Traceback (most recent call last):
16File "/usr/lib64/python3.8/site-packages/bcc/table.py", line 685, in raw_cb_
17callback(cpu, data, size)
18File "/usr/share/bcc/tools/trace", line 630, in print_event
19exit()
20File "/usr/lib64/python3.8/sitebuiltins.py", line 26, in __call_
21raise SystemExit(code)
22SystemExit: None
23
24Upstream-Status: Pending
25
26Signed-off-by: He Zhe <zhe.he@windriver.com>
27---
28 tools/trace.py | 2 +-
29 1 file changed, 1 insertion(+), 1 deletion(-)
30
31diff --git a/tools/trace.py b/tools/trace.py
32index 7a61594f..d09dd2a8 100755
33--- a/tools/trace.py
34+++ b/tools/trace.py
35@@ -627,7 +627,7 @@ BPF_PERF_OUTPUT(%s);
36 Probe.event_count += 1
37 if Probe.max_events is not None and \
38 Probe.event_count >= Probe.max_events:
39- exit()
40+ os._exit(0)
41 sys.stdout.flush()
42
43 def attach(self, bpf, verbose):
44--
452.17.1
46
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
new file mode 100644
index 0000000..0269fa4
--- /dev/null
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0002-cmake-always-link-to-packaged-libbpf-if-CMAKE_USE_LI.patch
@@ -0,0 +1,239 @@
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
new file mode 100644
index 0000000..ded9f28
--- /dev/null
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0002-fix-compilation-error-with-latest-llvm12-trunk.patch
@@ -0,0 +1,60 @@
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
new file mode 100644
index 0000000..25e744f
--- /dev/null
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0003-Remove-libbcc-no-libbpf-shared-library-change-libbcc.patch
@@ -0,0 +1,156 @@
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
new file mode 100644
index 0000000..31bcbcd
--- /dev/null
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc/0004-cmake-look-for-either-static-or-dynamic-libraries.patch
@@ -0,0 +1,69 @@
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.13.0.bb b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.17.0.bb
index 5a628db..8953fd4 100644
--- a/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.13.0.bb
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bcc/bcc_0.17.0.bb
@@ -8,20 +8,33 @@ inherit cmake python3native manpages
8DEPENDS += "bison-native \ 8DEPENDS += "bison-native \
9 flex-native \ 9 flex-native \
10 elfutils \ 10 elfutils \
11 luajit \ 11 ${LUAJIT} \
12 clang \ 12 clang \
13 " 13 "
14 14
15LUAJIT ?= "luajit"
16LUAJIT_powerpc64le = ""
17LUAJIT_powerpc64 = ""
18
15RDEPENDS_${PN} += "bash python3 python3-core python3-setuptools xz" 19RDEPENDS_${PN} += "bash python3 python3-core python3-setuptools xz"
16 20
17SRC_URI = "gitsm://github.com/iovisor/bcc \ 21# Don't fetch submodules otherwise we fetch an older, vendored libbpf version
22# We use a dynamic libbpf library instead
23SRC_URI = "git://github.com/iovisor/bcc \
18 file://0001-python-CMakeLists.txt-Remove-check-for-host-etc-debi.patch \ 24 file://0001-python-CMakeLists.txt-Remove-check-for-host-etc-debi.patch \
19 file://0001-tools-opensnoop-snoop-do_sys_openat2-for-kernel-v5.6.patch \ 25 file://0001-tools-trace.py-Fix-failing-to-exit.patch \
20 file://0001-Add-KBUILD_MODNAME-flag-to-default-cflags.patch \ 26 file://0001-CMakeLists.txt-override-the-PY_CMD_ESCAPED.patch \
21 file://0001-Delete-existing-kbuild_modname-definitions.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 \
22 " 33 "
23 34
24SRCREV = "942227484d3207f6a42103674001ef01fb5335a0" 35DEPENDS += "libbpf"
36
37SRCREV = "ad5b82a5196b222ed2cdc738d8444e8c9546a77f"
25 38
26S = "${WORKDIR}/git" 39S = "${WORKDIR}/git"
27 40
@@ -34,6 +47,7 @@ EXTRA_OECMAKE = " \
34 -DLLVM_PACKAGE_VERSION=${LLVMVERSION} \ 47 -DLLVM_PACKAGE_VERSION=${LLVMVERSION} \
35 -DPYTHON_CMD=${PYTHON} \ 48 -DPYTHON_CMD=${PYTHON} \
36 -DPYTHON_FLAGS=--install-lib=${PYTHON_SITEPACKAGES_DIR} \ 49 -DPYTHON_FLAGS=--install-lib=${PYTHON_SITEPACKAGES_DIR} \
50 -DCMAKE_USE_LIBBPF_PACKAGE=ON \
37" 51"
38 52
39do_install_append() { 53do_install_append() {
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-bpforc.h-Include-optional-header.patch b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-bpforc.h-Include-optional-header.patch
new file mode 100644
index 0000000..c666bfe
--- /dev/null
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace/0001-bpforc.h-Include-optional-header.patch
@@ -0,0 +1,31 @@
1From ec41ce71f8cd318ab3ca4ce727e7398289b5d7cf Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 30 Mar 2021 17:25:10 -0700
4Subject: [PATCH] bpforc.h: Include <optional> header
5
6This is required since this header had std::optional<std::tuple<uint8_t *, uintptr_t>>
7
8Fixes buiild errors with clang-12 with gcc11-runtime
9
10Upstream-Status: Submitted [https://github.com/iovisor/bpftrace/pull/1762]
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 src/bpforc.h | 2 ++
14 1 file changed, 2 insertions(+)
15
16diff --git a/src/bpforc.h b/src/bpforc.h
17index da6345be..5634c544 100644
18--- a/src/bpforc.h
19+++ b/src/bpforc.h
20@@ -22,6 +22,8 @@
21 #include <llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h>
22 #endif
23
24+#include <optional>
25+
26 namespace bpftrace {
27
28 const std::string LLVMTargetTriple = "bpf-pc-linux";
29--
302.31.1
31
diff --git a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.9.4.bb b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.11.4.bb
index ad044fd..d6ab0ce 100644
--- a/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.9.4.bb
+++ b/dynamic-layers/openembedded-layer/recipes-devtools/bpftrace/bpftrace_0.11.4.bb
@@ -10,17 +10,20 @@ DEPENDS += "bison-native \
10 bcc \ 10 bcc \
11 " 11 "
12 12
13PV .= "+git${SRCREV}"
13RDEPENDS_${PN} += "bash python3 xz" 14RDEPENDS_${PN} += "bash python3 xz"
14 15
15SRC_URI = "git://github.com/iovisor/bpftrace \ 16SRC_URI = "git://github.com/iovisor/bpftrace;branch=master \
17 file://0001-bpforc.h-Include-optional-header.patch \
16 " 18 "
17SRCREV = "b1200771b61fd77ed7c5b326e7960d24514dd961" 19SRCREV = "6bfa61f505b6b4215328f90762776edd8a22fdb7"
18 20
19S = "${WORKDIR}/git" 21S = "${WORKDIR}/git"
20 22
21inherit cmake 23inherit cmake
22 24
23EXTRA_OECMAKE = " \ 25EXTRA_OECMAKE = " \
26 -DCMAKE_ENABLE_EXPORTS=1 \
24 -DCMAKE_BUILD_TYPE=Release \ 27 -DCMAKE_BUILD_TYPE=Release \
25 -DBUILD_TESTING=OFF \ 28 -DBUILD_TESTING=OFF \
26" 29"