All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCHv6 1/5] package/llvm: add BPF backend
@ 2020-12-20 15:11 Romain Naour
  2020-12-20 15:12 ` [Buildroot] [PATCHv6 2/5] package/bcc: new package Romain Naour
                   ` (4 more replies)
  0 siblings, 5 replies; 24+ messages in thread
From: Romain Naour @ 2020-12-20 15:11 UTC (permalink / raw)
  To: buildroot

From: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>

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.

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 <qais.yousef@arm.com>
---
 package/llvm/Config.in | 6 ++++++
 package/llvm/llvm.mk   | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/package/llvm/Config.in b/package/llvm/Config.in
index 1d21d879da..6ec2ffcfe6 100644
--- a/package/llvm/Config.in
+++ b/package/llvm/Config.in
@@ -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"
diff --git a/package/llvm/llvm.mk b/package/llvm/llvm.mk
index 24d033d124..48a298191c 100644
--- a/package/llvm/llvm.mk
+++ b/package/llvm/llvm.mk
@@ -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
 
-- 
2.25.4

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 2/5] package/bcc: new package
  2020-12-20 15:11 [Buildroot] [PATCHv6 1/5] package/llvm: add BPF backend Romain Naour
@ 2020-12-20 15:12 ` Romain Naour
  2020-12-21 13:41   ` Qais Yousef
  2021-05-20 20:35   ` Arnout Vandecappelle
  2020-12-20 15:12 ` [Buildroot] [PATCHv6 3/5] package/libbpf: " Romain Naour
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 24+ messages in thread
From: Romain Naour @ 2020-12-20 15:12 UTC (permalink / raw)
  To: buildroot

From: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>

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

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>
Cc: Qais Yousef <qais.yousef@arm.com>
---
v6
- Add missing python patch from Qais
- remove luajit patch since the luajit support is explicitely disabled
- keep tested-by from Qais since he tested bcc (but not the luajit support)
- drop the reviewed-by due to luajit and python changes
- Add Romain in DEVELOPERS file

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                                    |  2 +
 package/Config.in                             |  1 +
 ...-an-option-to-disable-luajit-support.patch | 45 +++++++++++++++++++
 ...sts.txt-Fix-python-installation-path.patch | 34 ++++++++++++++
 package/bcc/Config.in                         | 39 ++++++++++++++++
 package/bcc/bcc.hash                          |  3 ++
 package/bcc/bcc.mk                            | 43 ++++++++++++++++++
 7 files changed, 167 insertions(+)
 create mode 100644 package/bcc/0001-CMake-add-an-option-to-disable-luajit-support.patch
 create mode 100644 package/bcc/0002-python-CMakeLists.txt-Fix-python-installation-path.patch
 create mode 100644 package/bcc/Config.in
 create mode 100644 package/bcc/bcc.hash
 create mode 100644 package/bcc/bcc.mk

diff --git a/DEVELOPERS b/DEVELOPERS
index 9406f30cd5..681c4e18db 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1392,6 +1392,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/
@@ -2233,6 +2234,7 @@ F:	board/qemu/
 F:	configs/qemu_*
 F:	package/alure/
 F:	package/aubio/
+F:	package/bcc/
 F:	package/binutils/
 F:	package/bullet/
 F:	package/clang/
diff --git a/package/Config.in b/package/Config.in
index dc7139a49a..c04392126c 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -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"
diff --git a/package/bcc/0001-CMake-add-an-option-to-disable-luajit-support.patch b/package/bcc/0001-CMake-add-an-option-to-disable-luajit-support.patch
new file mode 100644
index 0000000000..93d3e16a7f
--- /dev/null
+++ b/package/bcc/0001-CMake-add-an-option-to-disable-luajit-support.patch
@@ -0,0 +1,45 @@
+From b61c5eb0b2c385a6d3bbabf2396cb363588b32ab Mon Sep 17 00:00:00 2001
+From: Romain Naour <romain.naour@gmail.com>
+Date: Sun, 6 Dec 2020 17:15:25 +0100
+Subject: [PATCH] CMake: add an option to disable luajit support
+
+bcc luajit support is optional and should be disabled
+when luajit is not available.
+
+This option allow to explicitely disable luajit when
+cross-compiling.
+
+Signed-off-by: Romain Naour <romain.naour@gmail.com>
+---
+ CMakeLists.txt     | 2 ++
+ src/CMakeLists.txt | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 74fe4f19..c87b28c4 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -40,6 +40,8 @@ option(ENABLE_LLVM_SHARED "Enable linking LLVM as a shared library" OFF)
+ option(ENABLE_CLANG_JIT "Enable Loading BPF through Clang Frontend" ON)
+ option(ENABLE_USDT "Enable User-level Statically Defined Tracing" ON)
+ option(ENABLE_MAN "Build man pages" ON)
++cmake_dependent_option(ENABLE_LUAJIT "Use Luajit" ON "ENABLE_CLANG_JIT" OFF)
++
+ CMAKE_DEPENDENT_OPTION(ENABLE_CPP_API "Enable C++ API" ON "ENABLE_USDT" OFF)
+ 
+ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index 37b7e289..78c5fe58 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -17,5 +17,7 @@ add_subdirectory(cc)
+ endif()
+ if(ENABLE_CLANG_JIT)
+ add_subdirectory(python)
++if(ENABLE_LUAJIT)
+ add_subdirectory(lua)
+ endif()
++endif()
+-- 
+2.25.4
+
diff --git a/package/bcc/0002-python-CMakeLists.txt-Fix-python-installation-path.patch b/package/bcc/0002-python-CMakeLists.txt-Fix-python-installation-path.patch
new file mode 100644
index 0000000000..507a5aced7
--- /dev/null
+++ b/package/bcc/0002-python-CMakeLists.txt-Fix-python-installation-path.patch
@@ -0,0 +1,34 @@
+From 15d8445905b6023eb369083392dd1018d31e9664 Mon Sep 17 00:00:00 2001
+From: Qais Yousef <qais.yousef@arm.com>
+Date: Fri, 18 Dec 2020 16:36:15 +0000
+Subject: [PATCH] python/CMakeLists.txt: Fix python installation path
+
+The check for /etc/debian_version is unfriendly to cross build
+environment like buildroot. It tries to identify the distro of the host,
+but since we're in cross build environment this obviously breaks.
+
+Remove this check for now.
+
+Signed-off-by: Qais Yousef <qais.yousef@arm.com>
+---
+ src/python/CMakeLists.txt | 4 ----
+ 1 file changed, 4 deletions(-)
+
+diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt
+index fa602397..797e0d14 100644
+--- a/src/python/CMakeLists.txt
++++ b/src/python/CMakeLists.txt
+@@ -5,10 +5,6 @@ if(NOT PYTHON_CMD)
+   set(PYTHON_CMD "python")
+ endif()
+ 
+-if(EXISTS "/etc/debian_version")
+-  set(PYTHON_FLAGS "${PYTHON_FLAGS} --install-layout deb")
+-endif()
+-
+ file(GLOB_RECURSE PYTHON_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+   ${CMAKE_CURRENT_SOURCE_DIR}/*.py)
+ file(GLOB_RECURSE PYTHON_INCLUDES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+-- 
+2.25.1
+
diff --git a/package/bcc/Config.in b/package/bcc/Config.in
new file mode 100644
index 0000000000..087d0cb932
--- /dev/null
+++ b/package/bcc/Config.in
@@ -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
diff --git a/package/bcc/bcc.hash b/package/bcc/bcc.hash
new file mode 100644
index 0000000000..a9ca0a36cd
--- /dev/null
+++ b/package/bcc/bcc.hash
@@ -0,0 +1,3 @@
+# locally calculated
+sha256  7a3ef28a493dcd7ee0797ebca8f13b30ffca08efc93ff73ff8fa9ba0234d7947  bcc-v0.17.0.tar.gz
+sha256  b40930bbcf80744c86c46a12bc9da056641d722716c378f5659b9e555ef833e1  LICENSE.txt
diff --git a/package/bcc/bcc.mk b/package/bcc/bcc.mk
new file mode 100644
index 0000000000..bafa9e2096
--- /dev/null
+++ b/package/bcc/bcc.mk
@@ -0,0 +1,43 @@
+################################################################################
+#
+# bcc
+#
+################################################################################
+
+BCC_VERSION = v0.17.0
+BCC_SITE = https://github.com/iovisor/bcc.git
+BCC_SITE_METHOD = git
+BCC_GIT_SUBMODULES = YES
+BCC_LICENSE = Apache-2.0
+BCC_LICENSE_FILES = LICENSE.txt
+# libbcc.so and libbcc_bpf.so
+BCC_INSTALL_STAGING = YES
+BCC_DEPENDENCIES = host-bison host-flex clang elfutils flex llvm python3 tar
+
+# ENABLE_LLVM_SHARED=ON to use llvm.so.
+# Force REVISION otherwise bcc will use git describe to generate a version number.
+BCC_CONF_OPTS = -DENABLE_LLVM_SHARED=ON \
+	-DREVISION=$(BCC_VERSION) \
+	-DENABLE_CLANG_JIT=ON \
+	-DENABLE_MAN=OFF \
+	-DENABLE_LUAJIT=OFF
+
+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))
-- 
2.25.4

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 3/5] package/libbpf: new package
  2020-12-20 15:11 [Buildroot] [PATCHv6 1/5] package/llvm: add BPF backend Romain Naour
  2020-12-20 15:12 ` [Buildroot] [PATCHv6 2/5] package/bcc: new package Romain Naour
@ 2020-12-20 15:12 ` Romain Naour
  2020-12-21 13:43   ` Qais Yousef
  2021-05-20 20:47   ` Arnout Vandecappelle
  2020-12-20 15:12 ` [Buildroot] [PATCHv6 4/5] package/bpftrace: " Romain Naour
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 24+ messages in thread
From: Romain Naour @ 2020-12-20 15:12 UTC (permalink / raw)
  To: buildroot

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.

Signed-off-by: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>
Signed-off-by: Romain Naour <romain.naour@gmail.com>
Cc: Qais Yousef <qais.yousef@arm.com>
---
I'm not sure if updating the bpf.h provided by the toolchain linux-headers
is the right things to do.

v6: Update DEVELOPERS file
---
 DEVELOPERS               |  1 +
 package/Config.in        |  1 +
 package/libbpf/Config.in | 20 ++++++++++++++++++++
 package/libbpf/libbpf.mk | 40 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 62 insertions(+)
 create mode 100644 package/libbpf/Config.in
 create mode 100644 package/libbpf/libbpf.mk

diff --git a/DEVELOPERS b/DEVELOPERS
index 681c4e18db..00e12af974 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -2249,6 +2249,7 @@ F:	package/glibc/
 F:	package/irrlicht/
 F:	package/liblinear/
 F:	package/lensfun/
+F:	package/libbpf/
 F:	package/libclc/
 F:	package/libgta/
 F:	package/libspatialindex/
diff --git a/package/Config.in b/package/Config.in
index c04392126c..4dc27694d1 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -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"
diff --git a/package/libbpf/Config.in b/package/libbpf/Config.in
new file mode 100644
index 0000000000..c5b24c5eb5
--- /dev/null
+++ b/package/libbpf/Config.in
@@ -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)
diff --git a/package/libbpf/libbpf.mk b/package/libbpf/libbpf.mk
new file mode 100644
index 0000000000..33e303db16
--- /dev/null
+++ b/package/libbpf/libbpf.mk
@@ -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))
-- 
2.25.4

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 4/5] package/bpftrace: new package
  2020-12-20 15:11 [Buildroot] [PATCHv6 1/5] package/llvm: add BPF backend Romain Naour
  2020-12-20 15:12 ` [Buildroot] [PATCHv6 2/5] package/bcc: new package Romain Naour
  2020-12-20 15:12 ` [Buildroot] [PATCHv6 3/5] package/libbpf: " Romain Naour
@ 2020-12-20 15:12 ` Romain Naour
  2020-12-21 13:45   ` Qais Yousef
  2021-05-20 20:58   ` Arnout Vandecappelle
  2020-12-20 15:12 ` [Buildroot] [PATCHv6 5/5] package/bcc: add optional luajit dependency Romain Naour
  2021-05-20 20:04 ` [Buildroot] [PATCHv6 1/5] package/llvm: add BPF backend Arnout Vandecappelle
  4 siblings, 2 replies; 24+ messages in thread
From: Romain Naour @ 2020-12-20 15:12 UTC (permalink / raw)
  To: buildroot

From: Qais Yousef <qais.yousef@arm.com>

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.

The libbpf dependency allow to enable the BTF support:
 # bpftrace --info
 System
   OS: Linux 5.4.58 #1 SMP Sun Dec 20 15:56:56 CET 2020
   Arch: aarch64

 Build
   version: 2020.11-328-g019a9
   LLVM: 9.0.1
   foreach_sym: yes
   unsafe uprobe: no
   bfd: yes
   bpf_attach_kfunc: yes
   bcc_usdt_addsem: yes
   bcc bpf_attach_uprobe refcount: yes
   libbpf: yes
   libbpf btf dump: yes
   libbpf btf dump type decl: yes

bfptrace doesn't use the libbpf_bcc library provided by bcc package.

Signed-off-by: Qais Yousef <qais.yousef@arm.com>
Signed-off-by: Romain Naour <romain.naour@gmail.com>
Cc: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>
---
v6: Update DEVELOPERS file
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.
---
 DEVELOPERS                                    |  4 ++
 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 ++++++
 6 files changed, 140 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

diff --git a/DEVELOPERS b/DEVELOPERS
index 00e12af974..793137b798 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -2159,6 +2159,9 @@ F:	package/libdvbpsi/
 F:	package/mraa/
 F:	package/synergy/
 
+N:	Qais Yousef <qais.yousef@arm.com>
+F:	package/bpftrace/
+
 N:	Rafal Susz <rafal.susz@gmail.com>
 F:	board/avnet/s6lx9_microboard/
 F:	configs/s6lx9_microboard_defconfig
@@ -2236,6 +2239,7 @@ F:	package/alure/
 F:	package/aubio/
 F:	package/bcc/
 F:	package/binutils/
+F:	package/bpftrace/
 F:	package/bullet/
 F:	package/clang/
 F:	package/clinfo/
diff --git a/package/Config.in b/package/Config.in
index 4dc27694d1..6a40e17303 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -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"
diff --git a/package/bpftrace/0001-cmake-link-ast-resources-parser-as-static-libraries.patch b/package/bpftrace/0001-cmake-link-ast-resources-parser-as-static-libraries.patch
new file mode 100644
index 0000000000..d99b97c3a4
--- /dev/null
+++ b/package/bpftrace/0001-cmake-link-ast-resources-parser-as-static-libraries.patch
@@ -0,0 +1,71 @@
+From 960d2b69975462e445733482ac8d6ea319d3c5b2 Mon Sep 17 00:00:00 2001
+From: Romain Naour <romain.naour@gmail.com>
+Date: Thu, 5 Nov 2020 01:19:54 +0100
+Subject: [PATCH] cmake: link ast, resources parser as static libraries
+
+Signed-off-by: Romain Naour <romain.naour@gmail.com>
+---
+ CMakeLists.txt           | 2 +-
+ resources/CMakeLists.txt | 2 +-
+ src/arch/CMakeLists.txt  | 8 ++++----
+ src/ast/CMakeLists.txt   | 2 +-
+ 4 files changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index d732d23..4ebd3ce 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -91,7 +91,7 @@ find_package(FLEX REQUIRED)
+ bison_target(bison_parser src/parser.yy ${CMAKE_BINARY_DIR}/parser.tab.cc VERBOSE)
+ flex_target(flex_lexer src/lexer.l ${CMAKE_BINARY_DIR}/lex.yy.cc)
+ add_flex_bison_dependency(flex_lexer bison_parser)
+-add_library(parser ${BISON_bison_parser_OUTPUTS} ${FLEX_flex_lexer_OUTPUTS})
++add_library(parser STATIC ${BISON_bison_parser_OUTPUTS} ${FLEX_flex_lexer_OUTPUTS})
+ target_compile_options(parser PRIVATE "-w")
+ target_include_directories(parser PUBLIC src src/ast ${CMAKE_BINARY_DIR})
+ 
+diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt
+index a95c60a..2b05a68 100644
+--- a/resources/CMakeLists.txt
++++ b/resources/CMakeLists.txt
+@@ -1,4 +1,4 @@
+-add_library(resources headers.cpp)
++add_library(resources STATIC headers.cpp)
+ 
+ target_include_directories(resources PUBLIC ../src)
+ 
+diff --git a/src/arch/CMakeLists.txt b/src/arch/CMakeLists.txt
+index a26c1c8..fca9a6b 100644
+--- a/src/arch/CMakeLists.txt
++++ b/src/arch/CMakeLists.txt
+@@ -1,13 +1,13 @@
+ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
+-    add_library(arch aarch64.cpp)
++    add_library(arch STATIC aarch64.cpp)
+ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64" OR
+        CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le")
+-    add_library(arch ppc64.cpp)
++    add_library(arch STATIC ppc64.cpp)
+ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "s390" OR
+        CMAKE_SYSTEM_PROCESSOR STREQUAL "s390x")
+-    add_library(arch s390.cpp)
++    add_library(arch STATIC s390.cpp)
+ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+-    add_library(arch x86_64.cpp)
++    add_library(arch STATIC x86_64.cpp)
+ else()
+   message(FATAL_ERROR "Unsupported architecture: ${CMAKE_SYSTEM_PROCESSOR}")
+ endif()
+diff --git a/src/ast/CMakeLists.txt b/src/ast/CMakeLists.txt
+index 649bf0a..477d809 100644
+--- a/src/ast/CMakeLists.txt
++++ b/src/ast/CMakeLists.txt
+@@ -1,4 +1,4 @@
+-add_library(ast
++add_library(ast STATIC
+   ast.cpp
+   attachpoint_parser.cpp
+   codegen_llvm.cpp
+-- 
+2.25.4
+
diff --git a/package/bpftrace/Config.in b/package/bpftrace/Config.in
new file mode 100644
index 0000000000..f627725afe
--- /dev/null
+++ b/package/bpftrace/Config.in
@@ -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
diff --git a/package/bpftrace/bpftrace.hash b/package/bpftrace/bpftrace.hash
new file mode 100644
index 0000000000..b48d9555fd
--- /dev/null
+++ b/package/bpftrace/bpftrace.hash
@@ -0,0 +1,3 @@
+# locally calculated
+sha256  cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30  LICENSE
+sha256  1f08661bac9dfa7d3d76b54b3b4d1738b02c3847049da90a5cff25093a9dc9c9  bpftrace-487dd815bfe4a24908950552f35ef17d6653b2f8.tar.gz
diff --git a/package/bpftrace/bpftrace.mk b/package/bpftrace/bpftrace.mk
new file mode 100644
index 0000000000..0d8640a184
--- /dev/null
+++ b/package/bpftrace/bpftrace.mk
@@ -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))
-- 
2.25.4

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 5/5] package/bcc: add optional luajit dependency
  2020-12-20 15:11 [Buildroot] [PATCHv6 1/5] package/llvm: add BPF backend Romain Naour
                   ` (2 preceding siblings ...)
  2020-12-20 15:12 ` [Buildroot] [PATCHv6 4/5] package/bpftrace: " Romain Naour
@ 2020-12-20 15:12 ` Romain Naour
  2020-12-21 14:30   ` Qais Yousef
  2021-05-20 21:02   ` Arnout Vandecappelle
  2021-05-20 20:04 ` [Buildroot] [PATCHv6 1/5] package/llvm: add BPF backend Arnout Vandecappelle
  4 siblings, 2 replies; 24+ messages in thread
From: Romain Naour @ 2020-12-20 15:12 UTC (permalink / raw)
  To: buildroot

The luajit dependency was explicitely disabled when bcc has
been added to Buildroot.
Even if the python binding is probably more used, enable
luajit binding if luajit package is enabled in the defconfig.

Fix the luajit command line used to build bcc.o, otherwise
bcc.o is build for the host.

Signed-off-by: Romain Naour <romain.naour@gmail.com>
Cc: Qais Yousef <qais.yousef@arm.com>
---
 .../bcc/0003-fix-aarch64-cross-compile.patch  | 65 +++++++++++++++++++
 package/bcc/bcc.mk                            | 10 ++-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 package/bcc/0003-fix-aarch64-cross-compile.patch

diff --git a/package/bcc/0003-fix-aarch64-cross-compile.patch b/package/bcc/0003-fix-aarch64-cross-compile.patch
new file mode 100644
index 0000000000..6b4279754c
--- /dev/null
+++ b/package/bcc/0003-fix-aarch64-cross-compile.patch
@@ -0,0 +1,65 @@
+From 5a5b0f04484e00c88e7be902101367d6d591fb96 Mon Sep 17 00:00:00 2001
+From: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>
+Date: Thu, 2 May 2019 11:06:23 +0200
+Subject: [PATCH] cmake/luajit: Provide the target architecture to luaJIT while
+ cross-compiling
+
+Unlike CMAKE_SYSTEM_PROCESSOR which identifies aarch64
+as a valid architecture, luajit does not recognize it.
+luajit defines aarch64 as arm64.
+
+LuaJIT doesn't use usual arch naming, so we have to convert
+between CMake and Luajit for each architectures while
+cross-compiling.
+
+Signed-off-by: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>
+Signed-off-by: Romain Naour <romain.naour@smile.fr>
+---
+v2: Do the same for other architecture supported by LuaJIT.
+https://github.com/iovisor/bcc/pull/2480
+---
+ src/lua/CMakeLists.txt | 29 ++++++++++++++++++++++++++++-
+ 1 file changed, 28 insertions(+), 1 deletion(-)
+
+diff --git a/src/lua/CMakeLists.txt b/src/lua/CMakeLists.txt
+index 7541d48df..226e1b1d2 100644
+--- a/src/lua/CMakeLists.txt
++++ b/src/lua/CMakeLists.txt
+@@ -13,9 +13,36 @@ if (LUAJIT_LIBRARIES AND LUAJIT)
+ 		DEPENDS ${SRC_LUA} ${CMAKE_CURRENT_SOURCE_DIR}/squishy
+ 	)
+ 
++	# LuaJIT doesn't use usual arch naming, so we have to convert
++	# between CMake and Luajit while cross-compiling.
++	if (CMAKE_CROSSCOMPILING)
++		SET (LUAJIT_TARGET_ARCH "-a")
++		# https://github.com/LuaJIT/LuaJIT/blob/f0e865dd4861520258299d0f2a56491bd9d602e1/src/jit/bcsave.lua#L30
++		# https://github.com/LuaJIT/LuaJIT/blob/f0e865dd4861520258299d0f2a56491bd9d602e1/src/jit/bcsave.lua#L65
++		if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
++			SET (LUAJIT_TARGET_ARCH ${LUAJIT_TARGET_ARCH} "arm64")
++		elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64_be")
++			SET (LUAJIT_TARGET_ARCH ${LUAJIT_TARGET_ARCH} "arm64be")
++		elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
++			SET (LUAJIT_TARGET_ARCH ${LUAJIT_TARGET_ARCH} "arm")
++		elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86)$")
++			SET (LUAJIT_TARGET_ARCH ${LUAJIT_TARGET_ARCH} "x86")
++		elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "mips")
++			SET (LUAJIT_TARGET_ARCH ${LUAJIT_TARGET_ARCH} "mips")
++		elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel")
++			SET (LUAJIT_TARGET_ARCH ${LUAJIT_TARGET_ARCH} "mipsel")
++		elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "powerpc")
++			SET (LUAJIT_TARGET_ARCH ${LUAJIT_TARGET_ARCH} "ppc")
++		elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
++			SET (LUAJIT_TARGET_ARCH ${LUAJIT_TARGET_ARCH} "x64")
++		else()
++			MESSAGE(FATAL_ERROR "${CMAKE_SYSTEM_PROCESSOR} is not supported by LuaJIT")
++		endif()
++	endif()
++
+ 	ADD_CUSTOM_COMMAND(
+ 		OUTPUT bcc.o
+-		COMMAND ${LUAJIT} -bg bcc.lua bcc.o
++		COMMAND ${LUAJIT} -bg bcc.lua ${LUAJIT_TARGET_ARCH} bcc.o
+ 		DEPENDS bcc.lua
+ 	)
+ 
diff --git a/package/bcc/bcc.mk b/package/bcc/bcc.mk
index bafa9e2096..8b6ba63f90 100644
--- a/package/bcc/bcc.mk
+++ b/package/bcc/bcc.mk
@@ -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
-- 
2.25.4

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 2/5] package/bcc: new package
  2020-12-20 15:12 ` [Buildroot] [PATCHv6 2/5] package/bcc: new package Romain Naour
@ 2020-12-21 13:41   ` Qais Yousef
  2021-05-20 20:35   ` Arnout Vandecappelle
  1 sibling, 0 replies; 24+ messages in thread
From: Qais Yousef @ 2020-12-21 13:41 UTC (permalink / raw)
  To: buildroot

On 12/20/20 16:12, Romain Naour wrote:
> From: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>
> 
> 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
> 
> 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>
> Cc: Qais Yousef <qais.yousef@arm.com>
> ---
> v6
> - Add missing python patch from Qais
> - remove luajit patch since the luajit support is explicitely disabled
> - keep tested-by from Qais since he tested bcc (but not the luajit support)
> - drop the reviewed-by due to luajit and python changes
> - Add Romain in DEVELOPERS file

Reviewed-by: Qais Yousef <qais.yousef@arm.com>

Thanks!

--
Qais Yousef

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 3/5] package/libbpf: new package
  2020-12-20 15:12 ` [Buildroot] [PATCHv6 3/5] package/libbpf: " Romain Naour
@ 2020-12-21 13:43   ` Qais Yousef
  2021-05-20 20:47   ` Arnout Vandecappelle
  1 sibling, 0 replies; 24+ messages in thread
From: Qais Yousef @ 2020-12-21 13:43 UTC (permalink / raw)
  To: buildroot

On 12/20/20 16:12, Romain Naour wrote:
> 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.
> 
> Signed-off-by: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>
> Signed-off-by: Romain Naour <romain.naour@gmail.com>
> Cc: Qais Yousef <qais.yousef@arm.com>
> ---
> I'm not sure if updating the bpf.h provided by the toolchain linux-headers
> is the right things to do.
> 
> v6: Update DEVELOPERS file

LGTM.

Reviewed-by: Qais Yousef <qais.yousef@arm.com>

Thanks

--
Qais Yousef

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 4/5] package/bpftrace: new package
  2020-12-20 15:12 ` [Buildroot] [PATCHv6 4/5] package/bpftrace: " Romain Naour
@ 2020-12-21 13:45   ` Qais Yousef
  2021-01-23 19:44     ` Qais Yousef
  2021-05-20 20:58   ` Arnout Vandecappelle
  1 sibling, 1 reply; 24+ messages in thread
From: Qais Yousef @ 2020-12-21 13:45 UTC (permalink / raw)
  To: buildroot

On 12/20/20 16:12, Romain Naour wrote:
> From: Qais Yousef <qais.yousef@arm.com>
> 
> 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.
> 
> The libbpf dependency allow to enable the BTF support:
>  # bpftrace --info
>  System
>    OS: Linux 5.4.58 #1 SMP Sun Dec 20 15:56:56 CET 2020
>    Arch: aarch64
> 
>  Build
>    version: 2020.11-328-g019a9
>    LLVM: 9.0.1
>    foreach_sym: yes
>    unsafe uprobe: no
>    bfd: yes
>    bpf_attach_kfunc: yes
>    bcc_usdt_addsem: yes
>    bcc bpf_attach_uprobe refcount: yes
>    libbpf: yes
>    libbpf btf dump: yes
>    libbpf btf dump type decl: yes
> 
> bfptrace doesn't use the libbpf_bcc library provided by bcc package.
> 
> Signed-off-by: Qais Yousef <qais.yousef@arm.com>
> Signed-off-by: Romain Naour <romain.naour@gmail.com>
> Cc: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>
> ---
> v6: Update DEVELOPERS file

LGTM.

Thanks

--
Qais Yousef

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 5/5] package/bcc: add optional luajit dependency
  2020-12-20 15:12 ` [Buildroot] [PATCHv6 5/5] package/bcc: add optional luajit dependency Romain Naour
@ 2020-12-21 14:30   ` Qais Yousef
  2020-12-21 16:42     ` Qais Yousef
  2021-05-20 21:02   ` Arnout Vandecappelle
  1 sibling, 1 reply; 24+ messages in thread
From: Qais Yousef @ 2020-12-21 14:30 UTC (permalink / raw)
  To: buildroot

On 12/20/20 16:12, Romain Naour wrote:
> The luajit dependency was explicitely disabled when bcc has
> been added to Buildroot.
> Even if the python binding is probably more used, enable
> luajit binding if luajit package is enabled in the defconfig.
> 
> Fix the luajit command line used to build bcc.o, otherwise
> bcc.o is build for the host.
> 
> Signed-off-by: Romain Naour <romain.naour@gmail.com>
> Cc: Qais Yousef <qais.yousef@arm.com>
> ---

This compiles fine for me. And the patch looks good to me too. But when I tried
to test it by following the example from the website

	$ sudo src/lua/bcc-probe examples/lua/task_switch.lua

I noticed there's no bcc-probe in the target. When I copied it manually and
tried to run the above command I ended up with the below error.

	# /root/bcc-probe examples/lua/task_switch.lua
	luajit: /root/bcc-probe:20: module 'bcc.run' not found:
		no field package.preload['bcc.run']
		no file '/root//bcc/run.lua'
		no file './bcc/run.lua'
		no file '/usr/share/luajit-2.1.2/bcc/run.lua'
		no file '/usr/local/share/lua/5.1/bcc/run.lua'
		no file '/usr/local/share/lua/5.1/bcc/run/init.lua'
		no file '/usr/share/lua/5.1/bcc/run.lua'
		no file '/usr/share/lua/5.1/bcc/run/init.lua'
		no file './bcc/run.so'
		no file '/usr/local/lib/lua/5.1/bcc/run.so'
		no file '/usr/lib/lua/5.1/bcc/run.so'
		no file '/usr/local/lib/lua/5.1/loadall.so'
		no file './bcc.so'
		no file '/usr/local/lib/lua/5.1/bcc.so'
		no file '/usr/lib/lua/5.1/bcc.so'
		no file '/usr/local/lib/lua/5.1/loadall.so'
	stack traceback:
		[C]: in function 'require'
		/root/bcc-probe:20: in main chunk
		[C]: at 0x00402414

I admit I enabled luajit after initially building bcc without it. Although
I deleted output/build/bcc* to ensure it gets rebuilt against the new
dependency.

I'll try again with a full clean build to see if this fixes it.

Thanks

--
Qais Yousef

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 5/5] package/bcc: add optional luajit dependency
  2020-12-21 14:30   ` Qais Yousef
@ 2020-12-21 16:42     ` Qais Yousef
  0 siblings, 0 replies; 24+ messages in thread
From: Qais Yousef @ 2020-12-21 16:42 UTC (permalink / raw)
  To: buildroot

On 12/21/20 14:30, Qais Yousef wrote:
> On 12/20/20 16:12, Romain Naour wrote:
> > The luajit dependency was explicitely disabled when bcc has
> > been added to Buildroot.
> > Even if the python binding is probably more used, enable
> > luajit binding if luajit package is enabled in the defconfig.
> > 
> > Fix the luajit command line used to build bcc.o, otherwise
> > bcc.o is build for the host.
> > 
> > Signed-off-by: Romain Naour <romain.naour@gmail.com>
> > Cc: Qais Yousef <qais.yousef@arm.com>
> > ---
> 
> This compiles fine for me. And the patch looks good to me too. But when I tried
> to test it by following the example from the website
> 
> 	$ sudo src/lua/bcc-probe examples/lua/task_switch.lua
> 
> I noticed there's no bcc-probe in the target. When I copied it manually and
> tried to run the above command I ended up with the below error.
> 
> 	# /root/bcc-probe examples/lua/task_switch.lua
> 	luajit: /root/bcc-probe:20: module 'bcc.run' not found:
> 		no field package.preload['bcc.run']
> 		no file '/root//bcc/run.lua'
> 		no file './bcc/run.lua'
> 		no file '/usr/share/luajit-2.1.2/bcc/run.lua'
> 		no file '/usr/local/share/lua/5.1/bcc/run.lua'
> 		no file '/usr/local/share/lua/5.1/bcc/run/init.lua'
> 		no file '/usr/share/lua/5.1/bcc/run.lua'
> 		no file '/usr/share/lua/5.1/bcc/run/init.lua'
> 		no file './bcc/run.so'
> 		no file '/usr/local/lib/lua/5.1/bcc/run.so'
> 		no file '/usr/lib/lua/5.1/bcc/run.so'
> 		no file '/usr/local/lib/lua/5.1/loadall.so'
> 		no file './bcc.so'
> 		no file '/usr/local/lib/lua/5.1/bcc.so'
> 		no file '/usr/lib/lua/5.1/bcc.so'
> 		no file '/usr/local/lib/lua/5.1/loadall.so'
> 	stack traceback:
> 		[C]: in function 'require'
> 		/root/bcc-probe:20: in main chunk
> 		[C]: at 0x00402414
> 
> I admit I enabled luajit after initially building bcc without it. Although
> I deleted output/build/bcc* to ensure it gets rebuilt against the new
> dependency.
> 
> I'll try again with a full clean build to see if this fixes it.

Same thing with a new clean build. I just enabled BR2_PACKAGE_LUAJIT. Is there
a dependency on lua 5.1 too?

Thanks

--
Qais Yousef

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 4/5] package/bpftrace: new package
  2020-12-21 13:45   ` Qais Yousef
@ 2021-01-23 19:44     ` Qais Yousef
  2021-02-25 10:18       ` Qais Yousef
  0 siblings, 1 reply; 24+ messages in thread
From: Qais Yousef @ 2021-01-23 19:44 UTC (permalink / raw)
  To: buildroot

On 12/21/20 13:45, Qais Yousef wrote:
> On 12/20/20 16:12, Romain Naour wrote:
> > From: Qais Yousef <qais.yousef@arm.com>
> > 
> > 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.
> > 
> > The libbpf dependency allow to enable the BTF support:
> >  # bpftrace --info
> >  System
> >    OS: Linux 5.4.58 #1 SMP Sun Dec 20 15:56:56 CET 2020
> >    Arch: aarch64
> > 
> >  Build
> >    version: 2020.11-328-g019a9
> >    LLVM: 9.0.1
> >    foreach_sym: yes
> >    unsafe uprobe: no
> >    bfd: yes
> >    bpf_attach_kfunc: yes
> >    bcc_usdt_addsem: yes
> >    bcc bpf_attach_uprobe refcount: yes
> >    libbpf: yes
> >    libbpf btf dump: yes
> >    libbpf btf dump type decl: yes
> > 
> > bfptrace doesn't use the libbpf_bcc library provided by bcc package.
> > 
> > Signed-off-by: Qais Yousef <qais.yousef@arm.com>
> > Signed-off-by: Romain Naour <romain.naour@gmail.com>
> > Cc: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>
> > ---
> > v6: Update DEVELOPERS file
> 
> LGTM.

Ping.

I had issues with building patch 5, but the rest of the series is in good shape
IMO and can be merged independently at least.

Is there anything more needs to be done to help get this support merged?

Thanks

--
Qais Yousef

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 4/5] package/bpftrace: new package
  2021-01-23 19:44     ` Qais Yousef
@ 2021-02-25 10:18       ` Qais Yousef
  2021-02-25 11:01         ` Romain Naour
  0 siblings, 1 reply; 24+ messages in thread
From: Qais Yousef @ 2021-02-25 10:18 UTC (permalink / raw)
  To: buildroot

On 01/23/21 19:44, Qais Yousef wrote:
> On 12/21/20 13:45, Qais Yousef wrote:
> > On 12/20/20 16:12, Romain Naour wrote:
> > > From: Qais Yousef <qais.yousef@arm.com>
> > > 
> > > 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.
> > > 
> > > The libbpf dependency allow to enable the BTF support:
> > >  # bpftrace --info
> > >  System
> > >    OS: Linux 5.4.58 #1 SMP Sun Dec 20 15:56:56 CET 2020
> > >    Arch: aarch64
> > > 
> > >  Build
> > >    version: 2020.11-328-g019a9
> > >    LLVM: 9.0.1
> > >    foreach_sym: yes
> > >    unsafe uprobe: no
> > >    bfd: yes
> > >    bpf_attach_kfunc: yes
> > >    bcc_usdt_addsem: yes
> > >    bcc bpf_attach_uprobe refcount: yes
> > >    libbpf: yes
> > >    libbpf btf dump: yes
> > >    libbpf btf dump type decl: yes
> > > 
> > > bfptrace doesn't use the libbpf_bcc library provided by bcc package.
> > > 
> > > Signed-off-by: Qais Yousef <qais.yousef@arm.com>
> > > Signed-off-by: Romain Naour <romain.naour@gmail.com>
> > > Cc: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>
> > > ---
> > > v6: Update DEVELOPERS file
> > 
> > LGTM.
> 
> Ping.
> 
> I had issues with building patch 5, but the rest of the series is in good shape
> IMO and can be merged independently at least.
> 
> Is there anything more needs to be done to help get this support merged?

Ping again. It'd be great to finally have these merged.

Thanks

--
Qais Yousef

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 4/5] package/bpftrace: new package
  2021-02-25 10:18       ` Qais Yousef
@ 2021-02-25 11:01         ` Romain Naour
  2021-04-06 11:54           ` Qais Yousef
  0 siblings, 1 reply; 24+ messages in thread
From: Romain Naour @ 2021-02-25 11:01 UTC (permalink / raw)
  To: buildroot

Hello Quais, All,

Le jeu. 25 f?vr. 2021 ? 11:18, Qais Yousef <qais.yousef@arm.com> a ?crit :

> On 01/23/21 19:44, Qais Yousef wrote:
> > On 12/21/20 13:45, Qais Yousef wrote:
> > > On 12/20/20 16:12, Romain Naour wrote:
> > > > From: Qais Yousef <qais.yousef@arm.com>
> > > >
> > > > 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.
> > > >
> > > > The libbpf dependency allow to enable the BTF support:
> > > >  # bpftrace --info
> > > >  System
> > > >    OS: Linux 5.4.58 #1 SMP Sun Dec 20 15:56:56 CET 2020
> > > >    Arch: aarch64
> > > >
> > > >  Build
> > > >    version: 2020.11-328-g019a9
> > > >    LLVM: 9.0.1
> > > >    foreach_sym: yes
> > > >    unsafe uprobe: no
> > > >    bfd: yes
> > > >    bpf_attach_kfunc: yes
> > > >    bcc_usdt_addsem: yes
> > > >    bcc bpf_attach_uprobe refcount: yes
> > > >    libbpf: yes
> > > >    libbpf btf dump: yes
> > > >    libbpf btf dump type decl: yes
> > > >
> > > > bfptrace doesn't use the libbpf_bcc library provided by bcc package.
> > > >
> > > > Signed-off-by: Qais Yousef <qais.yousef@arm.com>
> > > > Signed-off-by: Romain Naour <romain.naour@gmail.com>
> > > > Cc: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>
> > > > ---
> > > > v6: Update DEVELOPERS file
> > >
> > > LGTM.
> >
> > Ping.
> >
> > I had issues with building patch 5, but the rest of the series is in
> good shape
> > IMO and can be merged independently at least.
> >
> > Is there anything more needs to be done to help get this support merged?
>
> Ping again. It'd be great to finally have these merged.
>

Maintainers are currently busy at the release 2021.02 version of Buildroot.

But yes, this work has been reviewed and reworked by Quais and me.

I guess It's good to go.

Best regards,
Romain


> Thanks
>
> --
> Qais Yousef
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20210225/9267291c/attachment.html>

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 4/5] package/bpftrace: new package
  2021-02-25 11:01         ` Romain Naour
@ 2021-04-06 11:54           ` Qais Yousef
  2021-04-10 10:15             ` Romain Naour
  0 siblings, 1 reply; 24+ messages in thread
From: Qais Yousef @ 2021-04-06 11:54 UTC (permalink / raw)
  To: buildroot

On 02/25/21 12:01, Romain Naour wrote:
> Hello Quais, All,
> 
> Le jeu. 25 f?vr. 2021 ? 11:18, Qais Yousef <qais.yousef@arm.com> a ?crit :
> 
>     On 01/23/21 19:44, Qais Yousef wrote:
>     > On 12/21/20 13:45, Qais Yousef wrote:
>     > > On 12/20/20 16:12, Romain Naour wrote:
>     > > > From: Qais Yousef <qais.yousef@arm.com>
>     > > >
>     > > > 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.
>     > > >
>     > > > The libbpf dependency allow to enable the BTF support:
>     > > >  # bpftrace --info
>     > > >  System
>     > > >    OS: Linux 5.4.58 #1 SMP Sun Dec 20 15:56:56 CET 2020
>     > > >    Arch: aarch64
>     > > >
>     > > >  Build
>     > > >    version: 2020.11-328-g019a9
>     > > >    LLVM: 9.0.1
>     > > >    foreach_sym: yes
>     > > >    unsafe uprobe: no
>     > > >    bfd: yes
>     > > >    bpf_attach_kfunc: yes
>     > > >    bcc_usdt_addsem: yes
>     > > >    bcc bpf_attach_uprobe refcount: yes
>     > > >    libbpf: yes
>     > > >    libbpf btf dump: yes
>     > > >    libbpf btf dump type decl: yes
>     > > >
>     > > > bfptrace doesn't use the libbpf_bcc library provided by bcc package.
>     > > >
>     > > > Signed-off-by: Qais Yousef <qais.yousef@arm.com>
>     > > > Signed-off-by: Romain Naour <romain.naour@gmail.com>
>     > > > Cc: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>
>     > > > ---
>     > > > v6: Update DEVELOPERS file
>     > >
>     > > LGTM.
>     >
>     > Ping.
>     >
>     > I had issues with building patch 5, but the rest of the series is in good
>     shape
>     > IMO and can be merged independently at least.
>     >
>     > Is there anything more needs to be done to help get this support merged?
> 
>     Ping again. It'd be great to finally have these merged.
> 
> 
> Maintainers are currently busy at the release 2021.02 version of Buildroot.
> 
> But yes, this work has been reviewed and reworked by Quais and me.
> 
> I guess It's good to go.

Another gentle ping. Hopefully the release is done now for this to be
considered.

Thanks

--
Qais Yousef

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 4/5] package/bpftrace: new package
  2021-04-06 11:54           ` Qais Yousef
@ 2021-04-10 10:15             ` Romain Naour
  2021-05-19 18:07               ` Qais Yousef
  0 siblings, 1 reply; 24+ messages in thread
From: Romain Naour @ 2021-04-10 10:15 UTC (permalink / raw)
  To: buildroot

Hello,

Le 06/04/2021 ? 13:54, Qais Yousef a ?crit?:
> On 02/25/21 12:01, Romain Naour wrote:
>> Hello Quais, All,
>>
>> Le jeu. 25 f?vr. 2021 ? 11:18, Qais Yousef <qais.yousef@arm.com> a ?crit :
>>
>>     On 01/23/21 19:44, Qais Yousef wrote:
>>     > On 12/21/20 13:45, Qais Yousef wrote:
>>     > > On 12/20/20 16:12, Romain Naour wrote:
>>     > > > From: Qais Yousef <qais.yousef@arm.com>
>>     > > >
>>     > > > 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.
>>     > > >
>>     > > > The libbpf dependency allow to enable the BTF support:
>>     > > >  # bpftrace --info
>>     > > >  System
>>     > > >    OS: Linux 5.4.58 #1 SMP Sun Dec 20 15:56:56 CET 2020
>>     > > >    Arch: aarch64
>>     > > >
>>     > > >  Build
>>     > > >    version: 2020.11-328-g019a9
>>     > > >    LLVM: 9.0.1
>>     > > >    foreach_sym: yes
>>     > > >    unsafe uprobe: no
>>     > > >    bfd: yes
>>     > > >    bpf_attach_kfunc: yes
>>     > > >    bcc_usdt_addsem: yes
>>     > > >    bcc bpf_attach_uprobe refcount: yes
>>     > > >    libbpf: yes
>>     > > >    libbpf btf dump: yes
>>     > > >    libbpf btf dump type decl: yes
>>     > > >
>>     > > > bfptrace doesn't use the libbpf_bcc library provided by bcc package.
>>     > > >
>>     > > > Signed-off-by: Qais Yousef <qais.yousef@arm.com>
>>     > > > Signed-off-by: Romain Naour <romain.naour@gmail.com>
>>     > > > Cc: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>
>>     > > > ---
>>     > > > v6: Update DEVELOPERS file
>>     > >
>>     > > LGTM.
>>     >
>>     > Ping.
>>     >
>>     > I had issues with building patch 5, but the rest of the series is in good
>>     shape
>>     > IMO and can be merged independently at least.
>>     >
>>     > Is there anything more needs to be done to help get this support merged?
>>
>>     Ping again. It'd be great to finally have these merged.
>>
>>
>> Maintainers are currently busy at the release 2021.02 version of Buildroot.
>>
>> But yes, this work has been reviewed and reworked by Quais and me.
>>
>> I guess It's good to go.
> 
> Another gentle ping. Hopefully the release is done now for this to be
> considered.

Gentle ping too.

The patch series is here:
http://patchwork.ozlabs.org/project/buildroot/list/?series=221413

I didn't work on it since then, only the patch 5/5 needs to be reworked.

Best regards,
Romain


> 
> Thanks
> 
> --
> Qais Yousef
> 

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 4/5] package/bpftrace: new package
  2021-04-10 10:15             ` Romain Naour
@ 2021-05-19 18:07               ` Qais Yousef
  0 siblings, 0 replies; 24+ messages in thread
From: Qais Yousef @ 2021-05-19 18:07 UTC (permalink / raw)
  To: buildroot

On 04/10/21 12:15, Romain Naour wrote:
> Hello,
> 
> Le 06/04/2021 ? 13:54, Qais Yousef a ?crit?:
> > On 02/25/21 12:01, Romain Naour wrote:
> >> Hello Quais, All,
> >>
> >> Le jeu. 25 f?vr. 2021 ? 11:18, Qais Yousef <qais.yousef@arm.com> a ?crit :
> >>
> >>     On 01/23/21 19:44, Qais Yousef wrote:
> >>     > On 12/21/20 13:45, Qais Yousef wrote:
> >>     > > On 12/20/20 16:12, Romain Naour wrote:
> >>     > > > From: Qais Yousef <qais.yousef@arm.com>
> >>     > > >
> >>     > > > 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.
> >>     > > >
> >>     > > > The libbpf dependency allow to enable the BTF support:
> >>     > > >  # bpftrace --info
> >>     > > >  System
> >>     > > >    OS: Linux 5.4.58 #1 SMP Sun Dec 20 15:56:56 CET 2020
> >>     > > >    Arch: aarch64
> >>     > > >
> >>     > > >  Build
> >>     > > >    version: 2020.11-328-g019a9
> >>     > > >    LLVM: 9.0.1
> >>     > > >    foreach_sym: yes
> >>     > > >    unsafe uprobe: no
> >>     > > >    bfd: yes
> >>     > > >    bpf_attach_kfunc: yes
> >>     > > >    bcc_usdt_addsem: yes
> >>     > > >    bcc bpf_attach_uprobe refcount: yes
> >>     > > >    libbpf: yes
> >>     > > >    libbpf btf dump: yes
> >>     > > >    libbpf btf dump type decl: yes
> >>     > > >
> >>     > > > bfptrace doesn't use the libbpf_bcc library provided by bcc package.
> >>     > > >
> >>     > > > Signed-off-by: Qais Yousef <qais.yousef@arm.com>
> >>     > > > Signed-off-by: Romain Naour <romain.naour@gmail.com>
> >>     > > > Cc: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>
> >>     > > > ---
> >>     > > > v6: Update DEVELOPERS file
> >>     > >
> >>     > > LGTM.
> >>     >
> >>     > Ping.
> >>     >
> >>     > I had issues with building patch 5, but the rest of the series is in good
> >>     shape
> >>     > IMO and can be merged independently at least.
> >>     >
> >>     > Is there anything more needs to be done to help get this support merged?
> >>
> >>     Ping again. It'd be great to finally have these merged.
> >>
> >>
> >> Maintainers are currently busy at the release 2021.02 version of Buildroot.
> >>
> >> But yes, this work has been reviewed and reworked by Quais and me.
> >>
> >> I guess It's good to go.
> > 
> > Another gentle ping. Hopefully the release is done now for this to be
> > considered.
> 
> Gentle ping too.
> 
> The patch series is here:
> http://patchwork.ozlabs.org/project/buildroot/list/?series=221413
> 
> I didn't work on it since then, only the patch 5/5 needs to be reworked.

Ping!

This series has been setting around since forever now. What's the right way
forward to get this over the fence?

Thanks

--
Qais Yousef

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 1/5] package/llvm: add BPF backend
  2020-12-20 15:11 [Buildroot] [PATCHv6 1/5] package/llvm: add BPF backend Romain Naour
                   ` (3 preceding siblings ...)
  2020-12-20 15:12 ` [Buildroot] [PATCHv6 5/5] package/bcc: add optional luajit dependency Romain Naour
@ 2021-05-20 20:04 ` Arnout Vandecappelle
  2021-05-20 20:04   ` Arnout Vandecappelle
  4 siblings, 1 reply; 24+ messages in thread
From: Arnout Vandecappelle @ 2021-05-20 20:04 UTC (permalink / raw)
  To: buildroot



On 20/12/2020 16:11, Romain Naour wrote:
> From: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>
> 
> 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.
> 
> 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 <qais.yousef@arm.com>

 Applied to master, thanks.

 Regards,
 Arnout

> ---
>  package/llvm/Config.in | 6 ++++++
>  package/llvm/llvm.mk   | 5 +++++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/package/llvm/Config.in b/package/llvm/Config.in
> index 1d21d879da..6ec2ffcfe6 100644
> --- a/package/llvm/Config.in
> +++ b/package/llvm/Config.in
> @@ -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"
> diff --git a/package/llvm/llvm.mk b/package/llvm/llvm.mk
> index 24d033d124..48a298191c 100644
> --- a/package/llvm/llvm.mk
> +++ b/package/llvm/llvm.mk
> @@ -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
>  
> 

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 1/5] package/llvm: add BPF backend
  2021-05-20 20:04 ` [Buildroot] [PATCHv6 1/5] package/llvm: add BPF backend Arnout Vandecappelle
@ 2021-05-20 20:04   ` Arnout Vandecappelle
  0 siblings, 0 replies; 24+ messages in thread
From: Arnout Vandecappelle @ 2021-05-20 20:04 UTC (permalink / raw)
  To: buildroot



On 20/05/2021 22:04, Arnout Vandecappelle wrote:
> 
> 
> On 20/12/2020 16:11, Romain Naour wrote:
>> From: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>
>>
>> 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.
>>
>> 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 <qais.yousef@arm.com>
> 
>  Applied to master, thanks.

 I mean to next!

 Regards,
 Arnout

> 
>  Regards,
>  Arnout
> 
>> ---
>>  package/llvm/Config.in | 6 ++++++
>>  package/llvm/llvm.mk   | 5 +++++
>>  2 files changed, 11 insertions(+)
>>
>> diff --git a/package/llvm/Config.in b/package/llvm/Config.in
>> index 1d21d879da..6ec2ffcfe6 100644
>> --- a/package/llvm/Config.in
>> +++ b/package/llvm/Config.in
>> @@ -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"
>> diff --git a/package/llvm/llvm.mk b/package/llvm/llvm.mk
>> index 24d033d124..48a298191c 100644
>> --- a/package/llvm/llvm.mk
>> +++ b/package/llvm/llvm.mk
>> @@ -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
>>  
>>

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 2/5] package/bcc: new package
  2020-12-20 15:12 ` [Buildroot] [PATCHv6 2/5] package/bcc: new package Romain Naour
  2020-12-21 13:41   ` Qais Yousef
@ 2021-05-20 20:35   ` Arnout Vandecappelle
  2021-05-20 20:49     ` Arnout Vandecappelle
  1 sibling, 1 reply; 24+ messages in thread
From: Arnout Vandecappelle @ 2021-05-20 20:35 UTC (permalink / raw)
  To: buildroot

 I still have comments and it's a bit too much to fix up while applying :-(

On 20/12/2020 16:12, Romain Naour wrote:
> From: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>
> 
> 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

 It would be nice to create a runtime test that does exactly this!

> 
> 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>
> Cc: Qais Yousef <qais.yousef@arm.com>
> ---
> v6
> - Add missing python patch from Qais
> - remove luajit patch since the luajit support is explicitely disabled
> - keep tested-by from Qais since he tested bcc (but not the luajit support)
> - drop the reviewed-by due to luajit and python changes
> - Add Romain in DEVELOPERS file
> 
> 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                                    |  2 +
>  package/Config.in                             |  1 +
>  ...-an-option-to-disable-luajit-support.patch | 45 +++++++++++++++++++
>  ...sts.txt-Fix-python-installation-path.patch | 34 ++++++++++++++
>  package/bcc/Config.in                         | 39 ++++++++++++++++
>  package/bcc/bcc.hash                          |  3 ++
>  package/bcc/bcc.mk                            | 43 ++++++++++++++++++
>  7 files changed, 167 insertions(+)
>  create mode 100644 package/bcc/0001-CMake-add-an-option-to-disable-luajit-support.patch
>  create mode 100644 package/bcc/0002-python-CMakeLists.txt-Fix-python-installation-path.patch
>  create mode 100644 package/bcc/Config.in
>  create mode 100644 package/bcc/bcc.hash
>  create mode 100644 package/bcc/bcc.mk
> 
> diff --git a/DEVELOPERS b/DEVELOPERS
> index 9406f30cd5..681c4e18db 100644
> --- a/DEVELOPERS
> +++ b/DEVELOPERS
> @@ -1392,6 +1392,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/
> @@ -2233,6 +2234,7 @@ F:	board/qemu/
>  F:	configs/qemu_*
>  F:	package/alure/
>  F:	package/aubio/
> +F:	package/bcc/
>  F:	package/binutils/
>  F:	package/bullet/
>  F:	package/clang/
> diff --git a/package/Config.in b/package/Config.in
> index dc7139a49a..c04392126c 100644
> --- a/package/Config.in
> +++ b/package/Config.in
> @@ -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"
> diff --git a/package/bcc/0001-CMake-add-an-option-to-disable-luajit-support.patch b/package/bcc/0001-CMake-add-an-option-to-disable-luajit-support.patch
> new file mode 100644
> index 0000000000..93d3e16a7f
> --- /dev/null
> +++ b/package/bcc/0001-CMake-add-an-option-to-disable-luajit-support.patch
> @@ -0,0 +1,45 @@
> +From b61c5eb0b2c385a6d3bbabf2396cb363588b32ab Mon Sep 17 00:00:00 2001
> +From: Romain Naour <romain.naour@gmail.com>
> +Date: Sun, 6 Dec 2020 17:15:25 +0100
> +Subject: [PATCH] CMake: add an option to disable luajit support
> +
> +bcc luajit support is optional and should be disabled
> +when luajit is not available.
> +
> +This option allow to explicitely disable luajit when
> +cross-compiling.
> +
> +Signed-off-by: Romain Naour <romain.naour@gmail.com>

 Was this patch sent upstream?

> +---
> + CMakeLists.txt     | 2 ++
> + src/CMakeLists.txt | 2 ++
> + 2 files changed, 4 insertions(+)
> +
> +diff --git a/CMakeLists.txt b/CMakeLists.txt
> +index 74fe4f19..c87b28c4 100644
> +--- a/CMakeLists.txt
> ++++ b/CMakeLists.txt
> +@@ -40,6 +40,8 @@ option(ENABLE_LLVM_SHARED "Enable linking LLVM as a shared library" OFF)
> + option(ENABLE_CLANG_JIT "Enable Loading BPF through Clang Frontend" ON)
> + option(ENABLE_USDT "Enable User-level Statically Defined Tracing" ON)
> + option(ENABLE_MAN "Build man pages" ON)
> ++cmake_dependent_option(ENABLE_LUAJIT "Use Luajit" ON "ENABLE_CLANG_JIT" OFF)
> ++
> + CMAKE_DEPENDENT_OPTION(ENABLE_CPP_API "Enable C++ API" ON "ENABLE_USDT" OFF)
> + 
> + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
> +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
> +index 37b7e289..78c5fe58 100644
> +--- a/src/CMakeLists.txt
> ++++ b/src/CMakeLists.txt
> +@@ -17,5 +17,7 @@ add_subdirectory(cc)
> + endif()
> + if(ENABLE_CLANG_JIT)
> + add_subdirectory(python)
> ++if(ENABLE_LUAJIT)
> + add_subdirectory(lua)
> + endif()
> ++endif()> +--
> +2.25.4
> +
> diff --git a/package/bcc/0002-python-CMakeLists.txt-Fix-python-installation-path.patch b/package/bcc/0002-python-CMakeLists.txt-Fix-python-installation-path.patch
> new file mode 100644
> index 0000000000..507a5aced7
> --- /dev/null
> +++ b/package/bcc/0002-python-CMakeLists.txt-Fix-python-installation-path.patch
> @@ -0,0 +1,34 @@
> +From 15d8445905b6023eb369083392dd1018d31e9664 Mon Sep 17 00:00:00 2001
> +From: Qais Yousef <qais.yousef@arm.com>
> +Date: Fri, 18 Dec 2020 16:36:15 +0000
> +Subject: [PATCH] python/CMakeLists.txt: Fix python installation path
> +
> +The check for /etc/debian_version is unfriendly to cross build
> +environment like buildroot. It tries to identify the distro of the host,
> +but since we're in cross build environment this obviously breaks.
> +
> +Remove this check for now.
> +
> +Signed-off-by: Qais Yousef <qais.yousef@arm.com>

 Was this patch sent upstream? Or was an issue created?

> +---
> + src/python/CMakeLists.txt | 4 ----
> + 1 file changed, 4 deletions(-)
> +
> +diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt
> +index fa602397..797e0d14 100644
> +--- a/src/python/CMakeLists.txt
> ++++ b/src/python/CMakeLists.txt
> +@@ -5,10 +5,6 @@ if(NOT PYTHON_CMD)
> +   set(PYTHON_CMD "python")
> + endif()
> + 
> +-if(EXISTS "/etc/debian_version")
> +-  set(PYTHON_FLAGS "${PYTHON_FLAGS} --install-layout deb")
> +-endif()
> +-
> + file(GLOB_RECURSE PYTHON_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
> +   ${CMAKE_CURRENT_SOURCE_DIR}/*.py)
> + file(GLOB_RECURSE PYTHON_INCLUDES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
> +-- 
> +2.25.1
> +
> diff --git a/package/bcc/Config.in b/package/bcc/Config.in
> new file mode 100644
> index 0000000000..087d0cb932
> --- /dev/null
> +++ b/package/bcc/Config.in
> @@ -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

 Busybox tar is not sufficient? Why not? Is it for xz support?

> +	select BR2_PACKAGE_CLANG

 You didn't propagate

         depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_64735 # std::shared_future

> +	select BR2_PACKAGE_ELFUTILS
> +	select BR2_PACKAGE_FLEX # needs FlexLexer.h
> +	select BR2_PACKAGE_LLVM_BPF

 This looks weird because it depends on LLVM. It's implicit through clang, of
course, but still I think we should have select BR2_PACKAGE_LLVM as well.


> +	select BR2_PACKAGE_PYTHON3

 Isn't python optional on ENABLE_CLANG_JIT?

 You didn't propagate python3's dependencies. Most are implied by glibc, but the
glibc constraint may go away in the future, and it does not include the MMU
dependency.

> +	select BR2_PACKAGE_TAR # Decompress kernel headers required by BCC

 Isn't this a runtime dependency? tar doesn't install to staging so it's
unlikely to be a build-time dependency.

> +	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.
                                            builds

> +
> +	  https://github.com/iovisor/bcc
> +	  http://www.ebpf.io
> +
> +comment "bcc needs a glibc toolchain, C++, gcc >= 4.8, host gcc >= 4.8"

 There's no host gcc dependency...

> +	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
> +	depends on !BR2_TOOLCHAIN_USES_GLIBC || !BR2_INSTALL_LIBSTDCPP \
> +		|| !BR2_TOOLCHAIN_GCC_AT_LEAST_4_8
> diff --git a/package/bcc/bcc.hash b/package/bcc/bcc.hash
> new file mode 100644
> index 0000000000..a9ca0a36cd
> --- /dev/null
> +++ b/package/bcc/bcc.hash
> @@ -0,0 +1,3 @@
> +# locally calculated
> +sha256  7a3ef28a493dcd7ee0797ebca8f13b30ffca08efc93ff73ff8fa9ba0234d7947  bcc-v0.17.0.tar.gz
> +sha256  b40930bbcf80744c86c46a12bc9da056641d722716c378f5659b9e555ef833e1  LICENSE.txt
> diff --git a/package/bcc/bcc.mk b/package/bcc/bcc.mk
> new file mode 100644
> index 0000000000..bafa9e2096
> --- /dev/null
> +++ b/package/bcc/bcc.mk
> @@ -0,0 +1,43 @@
> +################################################################################
> +#
> +# bcc
> +#
> +################################################################################
> +
> +BCC_VERSION = v0.17.0
> +BCC_SITE = https://github.com/iovisor/bcc.git
> +BCC_SITE_METHOD = git
> +BCC_GIT_SUBMODULES = YES

 Can't the tarball be used?

https://github.com/iovisor/bcc/releases/download/v0.17.0/bcc-src-with-submodule.tar.gz


> +BCC_LICENSE = Apache-2.0
> +BCC_LICENSE_FILES = LICENSE.txt
> +# libbcc.so and libbcc_bpf.so

 This comment is not very useful - you'd normally put that in the commit message.

 However, if it's just .so files, then that's normally not a reason to install
it in staging. Staging is for when another package can have a build-time
dependency on it. Typically, that implies headers as well as a library.

> +BCC_INSTALL_STAGING = YES
> +BCC_DEPENDENCIES = host-bison host-flex clang elfutils flex llvm python3 tar

 So I'm surprised to see tar here.


> +
> +# ENABLE_LLVM_SHARED=ON to use llvm.so.
> +# Force REVISION otherwise bcc will use git describe to generate a version number.
> +BCC_CONF_OPTS = -DENABLE_LLVM_SHARED=ON \

 If the line is split, prefer to do it like this:

BCC_CONF_OPTS = \
	-DENABLE_LLVM_SHARED=ON \



 Regards,
 Arnout

> +	-DREVISION=$(BCC_VERSION) \
> +	-DENABLE_CLANG_JIT=ON \
> +	-DENABLE_MAN=OFF \
> +	-DENABLE_LUAJIT=OFF
> +
> +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))
> 

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 3/5] package/libbpf: new package
  2020-12-20 15:12 ` [Buildroot] [PATCHv6 3/5] package/libbpf: " Romain Naour
  2020-12-21 13:43   ` Qais Yousef
@ 2021-05-20 20:47   ` Arnout Vandecappelle
  1 sibling, 0 replies; 24+ messages in thread
From: Arnout Vandecappelle @ 2021-05-20 20:47 UTC (permalink / raw)
  To: buildroot



On 20/12/2020 16:12, Romain Naour wrote:
> 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.
> 
> Signed-off-by: Jugurtha BELKALEM <jugurtha.belkalem@smile.fr>
> Signed-off-by: Romain Naour <romain.naour@gmail.com>
> Cc: Qais Yousef <qais.yousef@arm.com>
> ---
> I'm not sure if updating the bpf.h provided by the toolchain linux-headers
> is the right things to do.
> 
> v6: Update DEVELOPERS file
> ---
>  DEVELOPERS               |  1 +
>  package/Config.in        |  1 +
>  package/libbpf/Config.in | 20 ++++++++++++++++++++
>  package/libbpf/libbpf.mk | 40 ++++++++++++++++++++++++++++++++++++++++

 hash file is missing.

>  4 files changed, 62 insertions(+)
>  create mode 100644 package/libbpf/Config.in
>  create mode 100644 package/libbpf/libbpf.mk
> 

[snip]
> +# bpf/bpf.h installed by libbpf use enm bpf_iter_link_info that was added since

 I don't know what you meant with "enm", so I just removed it.

 Applied to next with those two fixes, thanks.

 Regards,
 Arnout

> +# 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))
> 

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 2/5] package/bcc: new package
  2021-05-20 20:35   ` Arnout Vandecappelle
@ 2021-05-20 20:49     ` Arnout Vandecappelle
  0 siblings, 0 replies; 24+ messages in thread
From: Arnout Vandecappelle @ 2021-05-20 20:49 UTC (permalink / raw)
  To: buildroot



On 20/05/2021 22:35, Arnout Vandecappelle wrote:
>> BCC can be tested on the target :
>> $ mount -t debugfs none /sys/kernel/debug
>> $ cd /usr/share/bcc/tools
>> $ ./execsnoop
>  It would be nice to create a runtime test that does exactly this!

 Such a runtime test should build the kernel itself (with a minimal config),
because that way we test if the KCONFIG_ENABLE_OPT calls are correct.


 Regards,
 Arnout

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 4/5] package/bpftrace: new package
  2020-12-20 15:12 ` [Buildroot] [PATCHv6 4/5] package/bpftrace: " Romain Naour
  2020-12-21 13:45   ` Qais Yousef
@ 2021-05-20 20:58   ` Arnout Vandecappelle
  2021-06-01 15:34     ` Qais Yousef
  1 sibling, 1 reply; 24+ messages in thread
From: Arnout Vandecappelle @ 2021-05-20 20:58 UTC (permalink / raw)
  To: buildroot



On 20/12/2020 16:12, Romain Naour wrote:
[snip]
> diff --git a/package/bpftrace/0001-cmake-link-ast-resources-parser-as-static-libraries.patch b/package/bpftrace/0001-cmake-link-ast-resources-parser-as-static-libraries.patch
> new file mode 100644
> index 0000000000..d99b97c3a4
> --- /dev/null
> +++ b/package/bpftrace/0001-cmake-link-ast-resources-parser-as-static-libraries.patch
> @@ -0,0 +1,71 @@
> +From 960d2b69975462e445733482ac8d6ea319d3c5b2 Mon Sep 17 00:00:00 2001
> +From: Romain Naour <romain.naour@gmail.com>
> +Date: Thu, 5 Nov 2020 01:19:54 +0100
> +Subject: [PATCH] cmake: link ast, resources parser as static libraries

 Why is this needed?

 Has the patch been sent upstream?

> +
> +Signed-off-by: Romain Naour <romain.naour@gmail.com>

[snip]]
> diff --git a/package/bpftrace/Config.in b/package/bpftrace/Config.in
> new file mode 100644
> index 0000000000..f627725afe
> --- /dev/null
> +++ b/package/bpftrace/Config.in
> @@ -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

 You can add

	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS # bcc

here as well. The point of _ARCH_SUPPORTS is to make it easier for dependent
packages to express the arch dependency, so that should include recursive arch
dependencies.

> +
> +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

 We write this as # 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

 Again, I prefer an explicit select BR2_PACKAGE_LLVM

> +	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
> diff --git a/package/bpftrace/bpftrace.hash b/package/bpftrace/bpftrace.hash
> new file mode 100644
> index 0000000000..b48d9555fd
> --- /dev/null
> +++ b/package/bpftrace/bpftrace.hash
> @@ -0,0 +1,3 @@
> +# locally calculated
> +sha256  cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30  LICENSE
> +sha256  1f08661bac9dfa7d3d76b54b3b4d1738b02c3847049da90a5cff25093a9dc9c9  bpftrace-487dd815bfe4a24908950552f35ef17d6653b2f8.tar.gz
> diff --git a/package/bpftrace/bpftrace.mk b/package/bpftrace/bpftrace.mk
> new file mode 100644
> index 0000000000..0d8640a184
> --- /dev/null
> +++ b/package/bpftrace/bpftrace.mk
> @@ -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

 What happens if target binutils is not built? Is it using a bundled version? In
that case, we prefer to unbundle it (i.e. select binutils).

 Regards,
 Arnout

> +ifeq ($(BR2_PACKAGE_BINUTILS),y)
> +BPFTRACE_DEPENDENCIES += binutils
> +endif
> +
> +BPFTRACE_CONF_OPTS += -DENABLE_MAN=OFF
> +
> +$(eval $(cmake-package))
> 

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 5/5] package/bcc: add optional luajit dependency
  2020-12-20 15:12 ` [Buildroot] [PATCHv6 5/5] package/bcc: add optional luajit dependency Romain Naour
  2020-12-21 14:30   ` Qais Yousef
@ 2021-05-20 21:02   ` Arnout Vandecappelle
  1 sibling, 0 replies; 24+ messages in thread
From: Arnout Vandecappelle @ 2021-05-20 21:02 UTC (permalink / raw)
  To: buildroot



On 20/12/2020 16:12, Romain Naour wrote:
> ++		SET (LUAJIT_TARGET_ARCH "-a")
> ++		# https://github.com/LuaJIT/LuaJIT/blob/f0e865dd4861520258299d0f2a56491bd9d602e1/src/jit/bcsave.lua#L30
> ++		# https://github.com/LuaJIT/LuaJIT/blob/f0e865dd4861520258299d0f2a56491bd9d602e1/src/jit/bcsave.lua#L65
> ++		if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
> ++			SET (LUAJIT_TARGET_ARCH ${LUAJIT_TARGET_ARCH} "arm64")

 This is a very weird way of adding the -a. Why not just:

		SET (LUAJIT_TARGET_ARCH "arm64")
> ++		elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64_be")
> ++			SET (LUAJIT_TARGET_ARCH ${LUAJIT_TARGET_ARCH} "arm64be")
> ++		elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
> ++			SET (LUAJIT_TARGET_ARCH ${LUAJIT_TARGET_ARCH} "arm")
> ++		elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86)$")
> ++			SET (LUAJIT_TARGET_ARCH ${LUAJIT_TARGET_ARCH} "x86")
> ++		elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "mips")
> ++			SET (LUAJIT_TARGET_ARCH ${LUAJIT_TARGET_ARCH} "mips")
> ++		elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel")
> ++			SET (LUAJIT_TARGET_ARCH ${LUAJIT_TARGET_ARCH} "mipsel")
> ++		elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "powerpc")
> ++			SET (LUAJIT_TARGET_ARCH ${LUAJIT_TARGET_ARCH} "ppc")
> ++		elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
> ++			SET (LUAJIT_TARGET_ARCH ${LUAJIT_TARGET_ARCH} "x64")
> ++		else()
> ++			MESSAGE(FATAL_ERROR "${CMAKE_SYSTEM_PROCESSOR} is not supported by LuaJIT")
> ++		endif()
> ++	endif()
> ++
> + 	ADD_CUSTOM_COMMAND(
> + 		OUTPUT bcc.o
> +-		COMMAND ${LUAJIT} -bg bcc.lua bcc.o
> ++		COMMAND ${LUAJIT} -bg bcc.lua ${LUAJIT_TARGET_ARCH} bcc.o

 and here

		COMMAND ${LUAJIT} -bg bcc.lua -a ${LUAJIT_TARGET_ARCH} bcc.o


 Also, has this patch been sent upstream?

 Regards,
 Arnout


> + 		DEPENDS bcc.lua
> + 	)
> +

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Buildroot] [PATCHv6 4/5] package/bpftrace: new package
  2021-05-20 20:58   ` Arnout Vandecappelle
@ 2021-06-01 15:34     ` Qais Yousef
  0 siblings, 0 replies; 24+ messages in thread
From: Qais Yousef @ 2021-06-01 15:34 UTC (permalink / raw)
  To: buildroot

Hi Arnout

Thanks for having a look! Sorry I was away all of last week.

On 05/20/21 22:58, Arnout Vandecappelle wrote:
> 
> 
> On 20/12/2020 16:12, Romain Naour wrote:
> [snip]
> > diff --git a/package/bpftrace/0001-cmake-link-ast-resources-parser-as-static-libraries.patch b/package/bpftrace/0001-cmake-link-ast-resources-parser-as-static-libraries.patch
> > new file mode 100644
> > index 0000000000..d99b97c3a4
> > --- /dev/null
> > +++ b/package/bpftrace/0001-cmake-link-ast-resources-parser-as-static-libraries.patch
> > @@ -0,0 +1,71 @@
> > +From 960d2b69975462e445733482ac8d6ea319d3c5b2 Mon Sep 17 00:00:00 2001
> > +From: Romain Naour <romain.naour@gmail.com>
> > +Date: Thu, 5 Nov 2020 01:19:54 +0100
> > +Subject: [PATCH] cmake: link ast, resources parser as static libraries
> 
>  Why is this needed?

In my original posting I added

	install(TARGETS parser LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

Which Romain suggested building as static is a better option.

The problem IIRC was that these libraries weren't installed correctly on the
target.

> 
>  Has the patch been sent upstream?

I don't think there was an attempt to do that yet.

If Romain doesn't get a chance to address your review comments soon enough I'll
address them and post a new version. Both of us have been driving this during
our free time on the weekends.

Thanks for the review.

Cheers

--
Qais Yousef

> 
> > +
> > +Signed-off-by: Romain Naour <romain.naour@gmail.com>
> 
> [snip]]
> > diff --git a/package/bpftrace/Config.in b/package/bpftrace/Config.in
> > new file mode 100644
> > index 0000000000..f627725afe
> > --- /dev/null
> > +++ b/package/bpftrace/Config.in
> > @@ -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
> 
>  You can add
> 
> 	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS # bcc
> 
> here as well. The point of _ARCH_SUPPORTS is to make it easier for dependent
> packages to express the arch dependency, so that should include recursive arch
> dependencies.
> 
> > +
> > +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
> 
>  We write this as # 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
> 
>  Again, I prefer an explicit select BR2_PACKAGE_LLVM
> 
> > +	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
> > diff --git a/package/bpftrace/bpftrace.hash b/package/bpftrace/bpftrace.hash
> > new file mode 100644
> > index 0000000000..b48d9555fd
> > --- /dev/null
> > +++ b/package/bpftrace/bpftrace.hash
> > @@ -0,0 +1,3 @@
> > +# locally calculated
> > +sha256  cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30  LICENSE
> > +sha256  1f08661bac9dfa7d3d76b54b3b4d1738b02c3847049da90a5cff25093a9dc9c9  bpftrace-487dd815bfe4a24908950552f35ef17d6653b2f8.tar.gz
> > diff --git a/package/bpftrace/bpftrace.mk b/package/bpftrace/bpftrace.mk
> > new file mode 100644
> > index 0000000000..0d8640a184
> > --- /dev/null
> > +++ b/package/bpftrace/bpftrace.mk
> > @@ -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
> 
>  What happens if target binutils is not built? Is it using a bundled version? In
> that case, we prefer to unbundle it (i.e. select binutils).
> 
>  Regards,
>  Arnout
> 
> > +ifeq ($(BR2_PACKAGE_BINUTILS),y)
> > +BPFTRACE_DEPENDENCIES += binutils
> > +endif
> > +
> > +BPFTRACE_CONF_OPTS += -DENABLE_MAN=OFF
> > +
> > +$(eval $(cmake-package))
> > 

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2021-06-01 15:34 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-20 15:11 [Buildroot] [PATCHv6 1/5] package/llvm: add BPF backend Romain Naour
2020-12-20 15:12 ` [Buildroot] [PATCHv6 2/5] package/bcc: new package Romain Naour
2020-12-21 13:41   ` Qais Yousef
2021-05-20 20:35   ` Arnout Vandecappelle
2021-05-20 20:49     ` Arnout Vandecappelle
2020-12-20 15:12 ` [Buildroot] [PATCHv6 3/5] package/libbpf: " Romain Naour
2020-12-21 13:43   ` Qais Yousef
2021-05-20 20:47   ` Arnout Vandecappelle
2020-12-20 15:12 ` [Buildroot] [PATCHv6 4/5] package/bpftrace: " Romain Naour
2020-12-21 13:45   ` Qais Yousef
2021-01-23 19:44     ` Qais Yousef
2021-02-25 10:18       ` Qais Yousef
2021-02-25 11:01         ` Romain Naour
2021-04-06 11:54           ` Qais Yousef
2021-04-10 10:15             ` Romain Naour
2021-05-19 18:07               ` Qais Yousef
2021-05-20 20:58   ` Arnout Vandecappelle
2021-06-01 15:34     ` Qais Yousef
2020-12-20 15:12 ` [Buildroot] [PATCHv6 5/5] package/bcc: add optional luajit dependency Romain Naour
2020-12-21 14:30   ` Qais Yousef
2020-12-21 16:42     ` Qais Yousef
2021-05-20 21:02   ` Arnout Vandecappelle
2021-05-20 20:04 ` [Buildroot] [PATCHv6 1/5] package/llvm: add BPF backend Arnout Vandecappelle
2021-05-20 20:04   ` Arnout Vandecappelle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.