package/bcc: new package

bcc is a front-end tool for eBPF:
https://github.com/iovisor/bcc/blob/master/README.md
eBPF is the most powerful Linux tracer, and bcc allows writing eBPF
scripts in C and PYTHON3.

bcc can help to troubleshoot issues quickly on embedded systems (as long
as Linux kernel version >= 4.1).

bcc can also make it easy to create observabilty tools, SDN
configuration, ddos mitigation, intrusion detection and secure
containers. More information is available at: https://ebpf.io/

BCC can be tested on the target :
$ mount -t debugfs none /sys/kernel/debug
$ cd /usr/share/bcc/tools
$ ./execsnoop

Signed-off-by: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>
Signed-off-by: Romain Naour <romain.naour@gmail.com>
Tested-by: Qais Yousef <qais.yousef@arm.com>
Reviewed-by: Qais Yousef <qais.yousef@arm.com>
Cc: Qais Yousef <qyousef@layalina.io>
Signed-off-by: Mat Martineau <martineau@kernel.org>
[Arnout: order dependencies alphabetically, fix Config.in comment]
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
This commit is contained in:
Jugurtha BELKALEM 2024-01-19 17:17:58 -08:00 committed by Arnout Vandecappelle
parent a26701a0db
commit 146498d13c
5 changed files with 103 additions and 0 deletions

View File

@ -1682,6 +1682,7 @@ N: Joshua Henderson <joshua.henderson@microchip.com>
F: package/qt5/qt5wayland/
N: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>
F: package/bcc/
F: package/python-aiofiles/
F: package/python-crayons/
F: package/python-cycler/
@ -2683,6 +2684,7 @@ F: configs/qemu_*
F: configs/am574x_idk_defconfig
F: package/alure/
F: package/aubio/
F: package/bcc/
F: package/binutils/
F: package/bullet/
F: package/clinfo/

View File

@ -87,6 +87,7 @@ endmenu
menu "Debugging, profiling and benchmark"
source "package/babeltrace2/Config.in"
source "package/bcc/Config.in"
source "package/blktrace/Config.in"
source "package/bonnie/Config.in"
source "package/bpftool/Config.in"

45
package/bcc/Config.in Normal file
View File

@ -0,0 +1,45 @@
config BR2_PACKAGE_BCC
bool "bcc"
depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
depends on BR2_USE_MMU # python3
depends on BR2_TOOLCHAIN_USES_GLIBC # hardcode GNU tuple (x86_64-unknown-linux-gnu)
depends on BR2_TOOLCHAIN_GCC_AT_LEAST_7 # clang
depends on BR2_INSTALL_LIBSTDCPP # clang
depends on BR2_HOST_GCC_AT_LEAST_7 # clang
depends on BR2_USE_WCHAR # clang, python3
depends on BR2_TOOLCHAIN_HAS_THREADS # clang, python3
depends on !BR2_STATIC_LIBS # clang, python3
select BR2_PACKAGE_CLANG
select BR2_PACKAGE_ELFUTILS
select BR2_PACKAGE_FLEX # needs FlexLexer.h
select BR2_PACKAGE_HOST_ZIP
select BR2_PACKAGE_LLVM
select BR2_PACKAGE_LLVM_BPF
select BR2_PACKAGE_PYTHON3
help
BPF Compiler Collection (BCC)
BCC is a toolkit for creating efficient kernel tracing and
manipulation programs, and includes several useful tools and
examples. It makes use of extended BPF (Berkeley Packet
Filters), formally known as eBPF, a new feature that was
first added to Linux 3.15. Much of what BCC uses requires
Linux 4.1 and above.
Note: Before using bcc, you need either need to :
- For kernel_ver = [4.1, 5.2) : Copy kernel source code
to target folder /lib/module/<kernel_ver>/build.
- Or kernel_ver >= 5.2 : Compile kernel with CONFIG_IKHEADERS
and use generated headers under /sys/kernel/kheaders.tar.xz
to populate /lib/module/<kernel_ver>/build.
That's because the clang frontend build eBPF code at runtime.
https://github.com/iovisor/bcc
http://www.ebpf.io
comment "bcc needs a glibc toolchain, C++, gcc >= 7, host gcc >= 7"
depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
depends on BR2_USE_MMU
depends on !BR2_TOOLCHAIN_USES_GLIBC || !BR2_INSTALL_LIBSTDCPP \
|| !BR2_TOOLCHAIN_GCC_AT_LEAST_7 || !BR2_HOST_GCC_AT_LEAST_7

3
package/bcc/bcc.hash Normal file
View File

@ -0,0 +1,3 @@
# locally calculated
sha256 321575fa94f3274040379dd2d4535217f45099f4240b58a4dfc171aa8c78402f bcc-src-with-submodule.tar.gz
sha256 b40930bbcf80744c86c46a12bc9da056641d722716c378f5659b9e555ef833e1 LICENSE.txt

52
package/bcc/bcc.mk Normal file
View File

@ -0,0 +1,52 @@
################################################################################
#
# bcc
#
################################################################################
BCC_VERSION = 0.29.1
BCC_SITE = https://github.com/iovisor/bcc/releases/download/v$(BCC_VERSION)
BCC_SOURCE = bcc-src-with-submodule.tar.gz
BCC_LICENSE = Apache-2.0
BCC_LICENSE_FILES = LICENSE.txt
BCC_INSTALL_STAGING = YES
BCC_DEPENDENCIES = \
clang \
elfutils \
flex \
host-bison \
host-flex \
host-python-setuptools \
host-zip \
llvm \
python3
# ENABLE_LLVM_SHARED=ON to use llvm.so - we only support shared libs
# Force REVISION otherwise bcc will use git describe to generate a version number.
BCC_CONF_OPTS = \
-DENABLE_LLVM_SHARED:BOOL=ON \
-DREVISION:STRING=$(BCC_VERSION) \
-DENABLE_CLANG_JIT:BOOL=ON \
-DENABLE_MAN:BOOL=OFF \
-DENABLE_EXAMPLES:BOOL=OFF \
-DPY_SKIP_DEB_LAYOUT:BOOL=ON
define BCC_LINUX_CONFIG_FIXUPS
# Enable kernel support for eBPF
$(call KCONFIG_ENABLE_OPT,CONFIG_BPF)
$(call KCONFIG_ENABLE_OPT,CONFIG_BPF_SYSCALL)
$(call KCONFIG_ENABLE_OPT,CONFIG_NET_CLS_BPF)
$(call KCONFIG_ENABLE_OPT,CONFIG_NET_ACT_BPF)
$(call KCONFIG_ENABLE_OPT,CONFIG_BPF_JIT)
# [for Linux kernel versions 4.1 through 4.6]
$(call KCONFIG_ENABLE_OPT,CONFIG_HAVE_BPF_JIT)
# [for Linux kernel versions 4.7 and later]
$(call KCONFIG_ENABLE_OPT,CONFIG_HAVE_EBPF_JIT)
$(call KCONFIG_ENABLE_OPT,CONFIG_BPF_EVENTS)
# [for Linux kernel versions 5.2 and later]
$(call KCONFIG_ENABLE_OPT,CONFIG_IKHEADERS)
# bcc needs debugfs at runtime
$(call KCONFIG_ENABLE_OPT,CONFIG_DEBUG_FS)
endef
$(eval $(cmake-package))