Skip to contentSkip to conversation

package/llvm: add BPF backend

PATCH Superseded Romain Naour 2 participants 15 messages Dec 6, 2020 – Dec 21, 2020

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/5 package/llvm: add BPF backend

From: Jugurtha BELKALEM <[email protected]>

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 to write eBPF scripts in C and PYTHON3.

BCC requires enabling LLVM backend BPF support.

---
 package/llvm/Config.in | 6 ++++++
 package/llvm/llvm.mk   | 5 +++++
 2 files changed, 11 insertions(+)
package/llvm/Config.in +6 -0
index 1d21d879da..6ec2ffcfe6 100644
@@ -47,6 +47,12 @@ config BR2_PACKAGE_LLVM_RTTI
 
 	  https://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html
 
+config BR2_PACKAGE_LLVM_BPF
+	bool "BPF backend"
+	help
+	  Build BPF target. Select this option if you are going
+	  to install bcc on the target.
+
 endif
 
 comment "llvm needs a toolchain w/ wchar, threads, C++, gcc >= 4.8, dynamic library"
package/llvm/llvm.mk +5 -0
index 24d033d124..48a298191c 100644
@@ -61,6 +61,11 @@ ifeq ($(BR2_PACKAGE_LLVM_AMDGPU),y)
 LLVM_TARGETS_TO_BUILD += AMDGPU
 endif
 
+# Build BPF backend
+ifeq ($(BR2_PACKAGE_LLVM_BPF),y)
+LLVM_TARGETS_TO_BUILD += BPF
+endif
+
 # Use native llvm-tblgen from host-llvm (needed for cross-compilation)
 LLVM_CONF_OPTS += -DLLVM_TABLEGEN=$(HOST_DIR)/bin/llvm-tblgen
 
Signature · 1 line
2.25.4
#1 lore raw

PATCH v5 2/5 package/bcc: new package

From: Jugurtha BELKALEM <[email protected]>

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 to write 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

---
v5
- Add a patch to disable luajit support
- remove iperf3, netperf, audit optional runtime dependencies (Qais)

v4
- Bump to version 0.17.0.
- Remove kernel dependency (Qais)
- Remove optional kernel option handling (Quais)
- Update ebpf url (Quais)
- Fix tools path in the commit log (Quais)
- Add full tar dependency (used to extract the kernel sources from IKHEADERS module) (Quais)
- Make luajit optional dependeny (Quais)
- Remove python module install hook (Quais)
- Keep BCC_LINUX_CONFIG_FIXUPS but only for kernel built by Buildroot.

V3
- Bump to version 0.16.0.
- Add required python dependency.
- Remove unnecessary and duplicated
kernel flags (#Testing section) in bcc.mk.

V2
- Add eBPF's required Kernel flags.
- Fix submodule source fetch problem.
- Add toolchain dependency.

---
 DEVELOPERS                                    |  1 +
 package/Config.in                             |  1 +
 .../bcc/0001-fix-aarch64-cross-compile.patch  | 65 +++++++++++++++++++
 ...-an-option-to-disable-luajit-support.patch | 45 +++++++++++++
 package/bcc/Config.in                         | 39 +++++++++++
 package/bcc/bcc.hash                          |  3 +
 package/bcc/bcc.mk                            | 43 ++++++++++++
 7 files changed, 197 insertions(+)
 create mode 100644 package/bcc/0001-fix-aarch64-cross-compile.patch
 create mode 100644 package/bcc/0002-CMake-add-an-option-to-disable-luajit-support.patch
 create mode 100644 package/bcc/Config.in
 create mode 100644 package/bcc/bcc.hash
 create mode 100644 package/bcc/bcc.mk
DEVELOPERS +1 -0
index b839a0d113..1f84fe7a2c 100644
@@ -1389,6 +1389,7 @@ N:	Joshua Henderson <[email protected]>
 F:	package/qt5/qt5wayland/
 
 N:	Jugurtha BELKALEM <[email protected]>
+F:	package/bcc/
 F:	package/python-aiofiles/
 F:	package/python-crayons/
 F:	package/python-cycler/
package/Config.in +1 -0
index 39c91645ad..79903b0044 100644
@@ -83,6 +83,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/cache-calibrator/Config.in"
package/bcc/0001-fix-aarch64-cross-compile.patch new file +65 -0

65 lines not on this page · raw message

package/bcc/0002-CMake-add-an-option-to-disable-luajit-support.patch new file +45 -0

45 lines not on this page · raw message

package/bcc/Config.in new file +39 -0
new file mode 100644
index 0000000000..087d0cb932
@@ -0,0 +1,39 @@
+config BR2_PACKAGE_BCC
+	bool "bcc"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	depends on BR2_TOOLCHAIN_USES_GLIBC # hardcode GNU tuple (x86_64-unknown-linux-gnu)
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8 # clang
+	depends on BR2_INSTALL_LIBSTDCPP # clang
+	select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS # to select tar package
+	select BR2_PACKAGE_CLANG
+	select BR2_PACKAGE_ELFUTILS
+	select BR2_PACKAGE_FLEX # needs FlexLexer.h
+	select BR2_PACKAGE_LLVM_BPF
+	select BR2_PACKAGE_PYTHON3
+	select BR2_PACKAGE_TAR # Decompress kernel headers required by BCC
+	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 >= 4.8, host gcc >= 4.8"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	depends on !BR2_TOOLCHAIN_USES_GLIBC || !BR2_INSTALL_LIBSTDCPP \
+		|| !BR2_TOOLCHAIN_GCC_AT_LEAST_4_8
package/bcc/bcc.hash new file +3 -0
new file mode 100644
index 0000000000..a9ca0a36cd
@@ -0,0 +1,3 @@
+# locally calculated
+sha256  7a3ef28a493dcd7ee0797ebca8f13b30ffca08efc93ff73ff8fa9ba0234d7947  bcc-v0.17.0.tar.gz
+sha256  b40930bbcf80744c86c46a12bc9da056641d722716c378f5659b9e555ef833e1  LICENSE.txt
package/bcc/bcc.mk new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
2.25.4
#2 lore raw

PATCH v5 2/5 package/bcc: new package

Hi Romain

Quoted 17 lines · Romain Naour

From: Jugurtha BELKALEM <[email protected]>

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 to write 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 :

Quoted 8 lines
$ mount -t debugfs none /sys/kernel/debug
$ cd /usr/share/bcc/tools
$ ./execsnoop

---

This only missed adding my patch to fix up python installation path (attached).

With that patch added

Thanks

--
Qais Yousef
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-python-CMakeLists.txt-Fix-python-installation-path.patch
Type: text/x-diff
Size: 1108 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20201220/08b94534/attachment.patch>

#3 lore raw

PATCH v5 2/5 package/bcc: new package

Hello Qais,

Le 20/12/2020 ? 02:44, Qais Yousef a ?crit?:

Quoted 24 lines

Hi Romain

Quoted 21 lines · Romain Naour

From: Jugurtha BELKALEM <[email protected]>

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 to write 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
Quoted 6 lines
Quoted 4 lines

---

This only missed adding my patch to fix up python installation path (attached).

Sorry I missed it.

Quoted 2 lines

With that patch added

Added for the next submission.

Quoted 3 lines

Thanks for your tests and review!

Best regards,
Romain

Quoted 6 lines

Thanks

--
Qais Yousef

#4 lore raw

PATCH v5 3/5 package/libbpf: new package

In reply to Romain Naour

A mirror of bpf-next linux tree bpf-next/tools/lib/bpf directory plus its supporting header files. The version of the package reflects the version of ABI.

---
I'm not sure if updating the bpf.h provided by the toolchain linux-headers is the right things to do.

---
 package/Config.in        |  1 +
 package/libbpf/Config.in | 20 ++++++++++++++++++++
 package/libbpf/libbpf.mk | 40 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+)
 create mode 100644 package/libbpf/Config.in
 create mode 100644 package/libbpf/libbpf.mk
package/Config.in +1 -0
index 79903b0044..2e3fe57b02 100644
@@ -107,6 +107,7 @@ menu "Debugging, profiling and benchmark"
 	source "package/kvm-unit-tests/Config.in"
 	source "package/kyua/Config.in"
 	source "package/latencytop/Config.in"
+	source "package/libbpf/Config.in"
 	source "package/lmbench/Config.in"
 	source "package/lsof/Config.in"
 	source "package/ltp-testsuite/Config.in"
package/libbpf/Config.in new file +20 -0
new file mode 100644
index 0000000000..c5b24c5eb5
@@ -0,0 +1,20 @@
+config BR2_PACKAGE_LIBBPF
+	bool "libbpf"
+	depends on BR2_USE_WCHAR # elfutils
+	depends on !BR2_STATIC_LIBS # elfutils
+	depends on BR2_TOOLCHAIN_HAS_THREADS # elfutils
+	depends on BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_GLIBC # elfutils
+	select BR2_PACKAGE_ELFUTILS
+	select BR2_PACKAGE_ZLIB
+	help
+	  libbpf library.
+	  A mirror of bpf-next linux tree bpf-next/tools/lib/bpf
+	  directory plus its supporting header files. The version
+	  of the package reflects the version of ABI.
+
+	  https://github.com/libbpf/libbpf
+
+comment "libbpf needs a uClibc or glibc toolchain w/ wchar, dynamic library, threads"
+	depends on !BR2_USE_WCHAR || BR2_STATIC_LIBS \
+		|| !BR2_TOOLCHAIN_HAS_THREADS \
+		|| !(BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_GLIBC)
package/libbpf/libbpf.mk new file +40 -0
new file mode 100644
index 0000000000..33e303db16
@@ -0,0 +1,40 @@
+################################################################################
+#
+# libbpf
+#
+################################################################################
+
+LIBBPF_VERSION = 0.2
+LIBBPF_SITE = $(call github,libbpf,libbpf,v$(LIBBPF_VERSION))
+LIBBPF_LICENSE = GPL-2.0, LGPL-2.1, BSD-2-Clause
+LIBBPF_LICENSE_FILES = LICENSE LICENSE.BSD-2-Clause LICENSE.LPGL-2.1
+LIBBPF_DEPENDENCIES = host-bison host-flex host-pkgconf elfutils zlib
+LIBBPF_INSTALL_STAGING = YES
+
+define LIBBPF_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) \
+		-C $(@D)/src
+endef
+
+# bpf/bpf.h installed by libbpf use enm bpf_iter_link_info that was added since
+# kernel 5.9, so we need to update some uapi headers in STAGING_DIR if the
+# toolchain is build with linux-headers < 5.9.
+# Otherwise bpf/bpf.h is broken due to out of date linux/bpf.h installed by the
+# toolchain.
+# https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=a5cbe05a6673b85bed2a63ffcfea6a96c6410cff
+ifeq ($(BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_9),)
+LIBBPF_UPDATE_UAPI_HEADERS = install_uapi_headers
+endif
+
+define LIBBPF_INSTALL_STAGING_CMDS
+	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) \
+		-C $(@D)/src install $(LIBBPF_UPDATE_UAPI_HEADERS) \
+		DESTDIR=$(STAGING_DIR)
+endef
+
+define LIBBPF_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) \
+		-C $(@D)/src install DESTDIR=$(TARGET_DIR)
+endef
+
+$(eval $(generic-package))
Signature · 1 line
2.25.4
#5 lore raw

PATCH v5 3/5 package/libbpf: new package

Quoted 8 lines · Romain Naour

A mirror of bpf-next linux tree bpf-next/tools/lib/bpf directory plus its supporting header files. The version of the package reflects the version of ABI.

---

I admit, I'm not sure how to use this on its own. It did compile fine for me though for arm64.

Is it just a library that is required to build bpf apps or there's more to it?

I think bpftrace dependency on it is not right by the way. BCC has its own copy of libbpf and bpftrace already depends on that.

Quoted 2 lines

I'm not sure if updating the bpf.h provided by the toolchain linux-headers is the right things to do.

If it needs linux-header 5.9, shouldn't it depend on that then?

Thanks

--
Qais Yousef

#6 lore raw

PATCH v5 4/5 package/bpftrace: new package

In reply to Romain Naour

From: Qais Yousef <[email protected]>

bpftrace is a high-level tracing language for Linux enhanced Berkeley Packet Filter (eBPF) available in recent Linux kernels (4.x).

Only tested on x86_64 and aarch64. The package doesn't support i386 and aarch32.

---
v2: patch to build bundled libraries statically
Add glibc dependency
Rework to select bcc, libbpf and llvm RTII dependencies. Add reverse dependencies
Add BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS
Bump the version to the latest (upcoming 0.12)
due to many build issues (and patch to backport) with the latest release.
Add binutils optional dependency to provide libbfd and libopcodes. Disable manpages.

---
 package/Config.in                             |  1 +
 ...resources-parser-as-static-libraries.patch | 71 +++++++++++++++++++
 package/bpftrace/Config.in                    | 40 +++++++++++
 package/bpftrace/bpftrace.hash                |  3 +
 package/bpftrace/bpftrace.mk                  | 21 ++++++
 5 files changed, 136 insertions(+)
 create mode 100644 package/bpftrace/0001-cmake-link-ast-resources-parser-as-static-libraries.patch
 create mode 100644 package/bpftrace/Config.in
 create mode 100644 package/bpftrace/bpftrace.hash
 create mode 100644 package/bpftrace/bpftrace.mk
package/Config.in +1 -0
index 2e3fe57b02..c8e50f8cff 100644
@@ -86,6 +86,7 @@ menu "Debugging, profiling and benchmark"
 	source "package/bcc/Config.in"
 	source "package/blktrace/Config.in"
 	source "package/bonnie/Config.in"
+	source "package/bpftrace/Config.in"
 	source "package/cache-calibrator/Config.in"
 	source "package/clinfo/Config.in"
 	source "package/dacapo/Config.in"
package/bpftrace/0001-cmake-link-ast-resources-parser-as-static-libraries.patch new file +71 -0

71 lines not on this page · raw message

package/bpftrace/Config.in new file +40 -0
new file mode 100644
index 0000000000..f627725afe
@@ -0,0 +1,40 @@
+config BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS
+	bool
+	default y if BR2_aarch64 || BR2_aarch64_be
+	default y if BR2_x86_64
+
+config BR2_PACKAGE_BPFTRACE
+	bool "bpftrace"
+	depends on BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS # bcc
+	depends on BR2_TOOLCHAIN_USES_GLIBC # bcc
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8 # bcc, clang
+	depends on BR2_INSTALL_LIBSTDCPP # bcc, clang
+	select BR2_PACKAGE_BCC
+	select BR2_PACKAGE_LIBBPF
+	# LLVM RTTI mendatory: https://github.com/iovisor/bpftrace/issues/1156
+	select BR2_PACKAGE_LLVM_RTTI
+	help
+	  bpftrace is a high-level tracing language for Linux enhanced
+	  Berkeley Packet Filter (eBPF) available in recent Linux
+	  kernels (4.x).
+
+	  bpftrace uses LLVM as a backend to compile scripts to
+	  BPF-bytecode and makes use of BCC for interacting with the
+	  Linux BPF system, as well as existing Linux tracing
+	  capabilities: kernel dynamic tracing (kprobes), user-level
+	  dynamic tracing (uprobes), and tracepoints. The bpftrace
+	  language is inspired by awk and C, and predecessor tracers
+	  such as DTrace and SystemTap.
+
+	  It's highly recommended to NOT strip bpftrace binary.
+	  To do so, add "bpftrace" to BR2_STRIP_EXCLUDE_FILES.
+	  See:
+	    https://bugzilla.redhat.com/show_bug.cgi?id=1865787
+
+	  https://www.github.com/iovisor/bpftrace
+
+comment "bpftrace needs a glibc toolchain w/ C++, gcc >= 4.8"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	depends on !BR2_TOOLCHAIN_USES_GLIBC || !BR2_INSTALL_LIBSTDCPP \
+		|| !BR2_TOOLCHAIN_GCC_AT_LEAST_4_8
package/bpftrace/bpftrace.hash new file +3 -0
new file mode 100644
index 0000000000..b48d9555fd
@@ -0,0 +1,3 @@
+# locally calculated
+sha256  cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30  LICENSE
+sha256  1f08661bac9dfa7d3d76b54b3b4d1738b02c3847049da90a5cff25093a9dc9c9  bpftrace-487dd815bfe4a24908950552f35ef17d6653b2f8.tar.gz
package/bpftrace/bpftrace.mk new file +21 -0
new file mode 100644
index 0000000000..0d8640a184
@@ -0,0 +1,21 @@
+################################################################################
+#
+# bpftrace
+#
+################################################################################
+
+# upcoming 0.12 version.
+BPFTRACE_VERSION = 487dd815bfe4a24908950552f35ef17d6653b2f8
+BPFTRACE_SITE = $(call github,iovisor,bpftrace,$(BPFTRACE_VERSION))
+BPFTRACE_LICENSE = Apache-2.0
+BPFTRACE_LICENSE_FILES = LICENSE
+BPFTRACE_DEPENDENCIES = host-bison host-flex bcc libbpf llvm
+
+# libbfd, libopcodes
+ifeq ($(BR2_PACKAGE_BINUTILS),y)
+BPFTRACE_DEPENDENCIES += binutils
+endif
+
+BPFTRACE_CONF_OPTS += -DENABLE_MAN=OFF
+
+$(eval $(cmake-package))
Signature · 1 line
2.25.4
#7 lore raw

PATCH v5 4/5 package/bpftrace: new package

Quoted 11 lines · Romain Naour

From: Qais Yousef <[email protected]>

bpftrace is a high-level tracing language for Linux enhanced Berkeley Packet Filter (eBPF) available in recent Linux kernels (4.x).

Only tested on x86_64 and aarch64. The package doesn't support i386 and aarch32.

Quoted 12 lines

---
v2: patch to build bundled libraries statically
Add glibc dependency
Rework to select bcc, libbpf and llvm RTII dependencies. Add reverse dependencies
Add BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS
Bump the version to the latest (upcoming 0.12)
due to many build issues (and patch to backport) with the latest release.
Add binutils optional dependency to provide libbfd and libopcodes. Disable manpages.
---

I don't think we need the dependency on libbpf? BCC provides it and we depend on it.

Feel free to add my name to DEVELOPERS file too and your name too.

Beside the question on the addition of libbpf dependency, this looks good to me.

Thanks for the rework!

Cheers

--
Qais Yousef

#8 lore raw

PATCH v5 4/5 package/bpftrace: new package

Le 20/12/2020 ? 02:47, Qais Yousef a ?crit?:

Quoted 25 lines · Romain Naour
Quoted 11 lines

From: Qais Yousef <[email protected]>

bpftrace is a high-level tracing language for Linux enhanced Berkeley Packet Filter (eBPF) available in recent Linux kernels (4.x).

Only tested on x86_64 and aarch64. The package doesn't support i386 and aarch32.

Quoted 12 lines

---
v2: patch to build bundled libraries statically
Add glibc dependency
Rework to select bcc, libbpf and llvm RTII dependencies. Add reverse dependencies
Add BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS
Bump the version to the latest (upcoming 0.12)
due to many build issues (and patch to backport) with the latest release.
Add binutils optional dependency to provide libbfd and libopcodes. Disable manpages.
---

Quoted 2 lines

I don't think we need the dependency on libbpf? BCC provides it and we depend on it.

The libbpf provided by BCC is named libbcc_bpf.so but bpftrace really expect libbpf.so

I added libbpf package since distribution packages use it.
https://archlinux.org/packages/community/x86_64/bpftrace/
https://src.fedoraproject.org/rpms/bpftrace/blob/master/f/bpftrace.spec#_27

But bpftrace try to find bcc_bpf only for static linking.
It's not clear what's the libbpf implementation the buildsystem is trying to use. Why it is not using the same bpf library for both static ans shared linking ?

I think it's better use use the library from upstream (libbpf) rather than a library bundled in another software (bcc_libbpf).

Quoted 2 lines

Feel free to add my name to DEVELOPERS file too and your name too.

Indeed, the DEVELOPERS file update is missing :-/

Quoted 5 lines

Beside the question on the addition of libbpf dependency, this looks good to me.

Thanks for the rework!

Thanks again for your help!

Best regards,
Romain

Quoted 6 lines

Cheers

--
Qais Yousef

#9 lore raw

PATCH v5 4/5 package/bpftrace: new package

Le 20/12/2020 ? 11:01, Romain Naour a ?crit?:

Quoted 36 lines

Le 20/12/2020 ? 02:47, Qais Yousef a ?crit?:

Quoted 25 lines · Romain Naour
Quoted 11 lines

From: Qais Yousef <[email protected]>

bpftrace is a high-level tracing language for Linux enhanced Berkeley Packet Filter (eBPF) available in recent Linux kernels (4.x).

Only tested on x86_64 and aarch64. The package doesn't support i386 and aarch32.

Quoted 12 lines

---
v2: patch to build bundled libraries statically
Add glibc dependency
Rework to select bcc, libbpf and llvm RTII dependencies. Add reverse dependencies
Add BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS
Bump the version to the latest (upcoming 0.12)
due to many build issues (and patch to backport) with the latest release.
Add binutils optional dependency to provide libbfd and libopcodes. Disable manpages.
---

Quoted 2 lines

I don't think we need the dependency on libbpf? BCC provides it and we depend on it.

The libbpf provided by BCC is named libbcc_bpf.so but bpftrace really expect libbpf.so

I added libbpf package since distribution packages use it.
https://archlinux.org/packages/community/x86_64/bpftrace/
https://src.fedoraproject.org/rpms/bpftrace/blob/master/f/bpftrace.spec#_27

Quoted 6 lines

But bpftrace try to find bcc_bpf only for static linking.
It's not clear what's the libbpf implementation the buildsystem is trying to use. Why it is not using the same bpf library for both static ans shared linking ?

I think it's better use use the library from upstream (libbpf) rather than a library bundled in another software (bcc_libbpf).

I added a new comment about the libbpf dependency needed for BTF support. The buildsystem really want to use libbpf, so I kept bpftrace as it was.

Best regards,
Romain

Quoted 24 lines
Quoted 3 lines

Feel free to add my name to DEVELOPERS file too and your name too.

Indeed, the DEVELOPERS file update is missing :-/

Quoted 5 lines

Beside the question on the addition of libbpf dependency, this looks good to me.

Thanks for the rework!

Thanks again for your help!

Best regards,
Romain

Quoted 6 lines

Cheers

--
Qais Yousef

#10 lore raw

PATCH v5 4/5 package/bpftrace: new package

In reply to Romain Naour
Quoted 32 lines · Romain Naour

Le 20/12/2020 ? 02:47, Qais Yousef a ?crit?:

Quoted 25 lines · Romain Naour
Quoted 11 lines

From: Qais Yousef <[email protected]>

bpftrace is a high-level tracing language for Linux enhanced Berkeley Packet Filter (eBPF) available in recent Linux kernels (4.x).

Only tested on x86_64 and aarch64. The package doesn't support i386 and aarch32.

Quoted 12 lines

---
v2: patch to build bundled libraries statically
Add glibc dependency
Rework to select bcc, libbpf and llvm RTII dependencies. Add reverse dependencies
Add BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS
Bump the version to the latest (upcoming 0.12)
due to many build issues (and patch to backport) with the latest release.
Add binutils optional dependency to provide libbfd and libopcodes. Disable manpages.
---

Quoted 2 lines

I don't think we need the dependency on libbpf? BCC provides it and we depend on it.

The libbpf provided by BCC is named libbcc_bpf.so but bpftrace really expect libbpf.so

Quoted 7 lines

I added libbpf package since distribution packages use it.
https://archlinux.org/packages/community/x86_64/bpftrace/
https://src.fedoraproject.org/rpms/bpftrace/blob/master/f/bpftrace.spec#_27

But bpftrace try to find bcc_bpf only for static linking.
It's not clear what's the libbpf implementation the buildsystem is trying to use. Why it is not using the same bpf library for both static ans shared linking ?

I don't know to be honest. I saw that bpftrace uses bcc/libbpf.h in all places, except for btf handling which is guarded by HAVE_LIBBPF_BTF_DUMP.

The INSTALL.md doesn't mention libbpf as dependency too..

https://github.com/iovisor/bpftrace/blob/master/INSTALL.md#building-bpftrace
https://github.com/iovisor/bpftrace/blob/master/INSTALL.md#generic-build-process

I think you have better experience than myself in this packaging related problems. We could ask the bpftrace developers directly too to clarify the dependencies.

Quoted 2 lines

I think it's better use use the library from upstream (libbpf) rather than a library bundled in another software (bcc_libbpf).

I don't see this dependency will break anything. So I will trust your judgement here.

Thanks

--
Qais Yousef

#11 lore raw

PATCH v5 5/5 package/bcc: add optional luajit dependency

In reply to Romain Naour
---
 package/bcc/bcc.mk | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
package/bcc/bcc.mk +8 -2
index bafa9e2096..8b6ba63f90 100644
@@ -19,8 +19,14 @@ BCC_DEPENDENCIES = host-bison host-flex clang elfutils flex llvm python3 tar
 BCC_CONF_OPTS = -DENABLE_LLVM_SHARED=ON \
 	-DREVISION=$(BCC_VERSION) \
 	-DENABLE_CLANG_JIT=ON \
-	-DENABLE_MAN=OFF \
-	-DENABLE_LUAJIT=OFF
+	-DENABLE_MAN=OFF
+
+ifeq ($(BR2_PACKAGE_LUAJIT),y)
+BCC_DEPENDENCIES += luajit
+BCC_CONF_OPTS += -DENABLE_LUAJIT=ON
+else
+BCC_CONF_OPTS += -DENABLE_LUAJIT=OFF
+endif
 
 define BCC_LINUX_CONFIG_FIXUPS
 	# Enable kernel support for eBPF
Signature · 1 line
2.25.4
#13 lore raw

PATCH v5 5/5 package/bcc: add optional luajit dependency

Le 20/12/2020 ? 02:47, Qais Yousef a ?crit?:

Quoted 7 lines · Romain Naour
Quoted 3 lines

---

Empty commit message looks weird to me. But maybe buildroot community don't mind this.

Ok, I'll write the commit log.
It doesn't seems always required for such patch (even it's always better to have one :p)

Best regards,
Romain

Quoted 11 lines

Anyway;

Thanks

--
Qais Yousef

#14 lore raw

PATCH v5 1/5 package/llvm: add BPF backend

In reply to Romain Naour
Quoted 7 lines · Romain Naour

From: Jugurtha BELKALEM <[email protected]>

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 to write eBPF scripts in C and PYTHON3.

Quoted 6 lines

BCC requires enabling LLVM backend BPF support.

---

Thanks

--
Qais Yousef