All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCHv5 1/5] package/llvm: add BPF backend
@ 2020-12-06 17:35 Romain Naour
  2020-12-06 17:35 ` [Buildroot] [PATCHv5 2/5] package/bcc: new package Romain Naour
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Romain Naour @ 2020-12-06 17:35 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>
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] 15+ messages in thread

* [Buildroot] [PATCHv5 2/5] package/bcc: new package
  2020-12-06 17:35 [Buildroot] [PATCHv5 1/5] package/llvm: add BPF backend Romain Naour
@ 2020-12-06 17:35 ` Romain Naour
  2020-12-20  1:44   ` Qais Yousef
  2020-12-06 17:35 ` [Buildroot] [PATCHv5 3/5] package/libbpf: " Romain Naour
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 15+ messages in thread
From: Romain Naour @ 2020-12-06 17:35 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>
Cc: Qais Yousef <qais.yousef@arm.com>
---
v5
- Add a patch to disable luajit support
- remove iperf3, netperf, audit optional runtime dependencies (Qais)

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

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

V2
- Add eBPF's required Kernel flags.
- Fix submodule source fetch problem.
- Add toolchain dependency.
---
 DEVELOPERS                                    |  1 +
 package/Config.in                             |  1 +
 .../bcc/0001-fix-aarch64-cross-compile.patch  | 65 +++++++++++++++++++
 ...-an-option-to-disable-luajit-support.patch | 45 +++++++++++++
 package/bcc/Config.in                         | 39 +++++++++++
 package/bcc/bcc.hash                          |  3 +
 package/bcc/bcc.mk                            | 43 ++++++++++++
 7 files changed, 197 insertions(+)
 create mode 100644 package/bcc/0001-fix-aarch64-cross-compile.patch
 create mode 100644 package/bcc/0002-CMake-add-an-option-to-disable-luajit-support.patch
 create mode 100644 package/bcc/Config.in
 create mode 100644 package/bcc/bcc.hash
 create mode 100644 package/bcc/bcc.mk

diff --git a/DEVELOPERS b/DEVELOPERS
index b839a0d113..1f84fe7a2c 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1389,6 +1389,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/
diff --git a/package/Config.in b/package/Config.in
index 39c91645ad..79903b0044 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-fix-aarch64-cross-compile.patch b/package/bcc/0001-fix-aarch64-cross-compile.patch
new file mode 100644
index 0000000000..6b4279754c
--- /dev/null
+++ b/package/bcc/0001-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/0002-CMake-add-an-option-to-disable-luajit-support.patch b/package/bcc/0002-CMake-add-an-option-to-disable-luajit-support.patch
new file mode 100644
index 0000000000..93d3e16a7f
--- /dev/null
+++ b/package/bcc/0002-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/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] 15+ messages in thread

* [Buildroot] [PATCHv5 3/5] package/libbpf: new package
  2020-12-06 17:35 [Buildroot] [PATCHv5 1/5] package/llvm: add BPF backend Romain Naour
  2020-12-06 17:35 ` [Buildroot] [PATCHv5 2/5] package/bcc: new package Romain Naour
@ 2020-12-06 17:35 ` Romain Naour
  2020-12-20  2:07   ` Qais Yousef
  2020-12-06 17:35 ` [Buildroot] [PATCHv5 4/5] package/bpftrace: " Romain Naour
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 15+ messages in thread
From: Romain Naour @ 2020-12-06 17:35 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.
---
 package/Config.in        |  1 +
 package/libbpf/Config.in | 20 ++++++++++++++++++++
 package/libbpf/libbpf.mk | 40 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+)
 create mode 100644 package/libbpf/Config.in
 create mode 100644 package/libbpf/libbpf.mk

diff --git a/package/Config.in b/package/Config.in
index 79903b0044..2e3fe57b02 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] 15+ messages in thread

* [Buildroot] [PATCHv5 4/5] package/bpftrace: new package
  2020-12-06 17:35 [Buildroot] [PATCHv5 1/5] package/llvm: add BPF backend Romain Naour
  2020-12-06 17:35 ` [Buildroot] [PATCHv5 2/5] package/bcc: new package Romain Naour
  2020-12-06 17:35 ` [Buildroot] [PATCHv5 3/5] package/libbpf: " Romain Naour
@ 2020-12-06 17:35 ` Romain Naour
  2020-12-20  1:47   ` Qais Yousef
  2020-12-06 17:35 ` [Buildroot] [PATCHv5 5/5] package/bcc: add optional luajit dependency Romain Naour
  2020-12-20  1:43 ` [Buildroot] [PATCHv5 1/5] package/llvm: add BPF backend Qais Yousef
  4 siblings, 1 reply; 15+ messages in thread
From: Romain Naour @ 2020-12-06 17:35 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.

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>
---
v2: patch to build bundled libraries statically
    Add glibc dependency
    Rework to select bcc, libbpf and llvm RTII dependencies.
    Add reverse dependencies
    Add BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS
    Bump the version to the latest (upcoming 0.12)
      due to many build issues (and patch to backport) with
      the latest release.
    Add binutils optional dependency to provide libbfd and libopcodes.
    Disable manpages.
---
 package/Config.in                             |  1 +
 ...resources-parser-as-static-libraries.patch | 71 +++++++++++++++++++
 package/bpftrace/Config.in                    | 40 +++++++++++
 package/bpftrace/bpftrace.hash                |  3 +
 package/bpftrace/bpftrace.mk                  | 21 ++++++
 5 files changed, 136 insertions(+)
 create mode 100644 package/bpftrace/0001-cmake-link-ast-resources-parser-as-static-libraries.patch
 create mode 100644 package/bpftrace/Config.in
 create mode 100644 package/bpftrace/bpftrace.hash
 create mode 100644 package/bpftrace/bpftrace.mk

diff --git a/package/Config.in b/package/Config.in
index 2e3fe57b02..c8e50f8cff 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] 15+ messages in thread

* [Buildroot] [PATCHv5 5/5] package/bcc: add optional luajit dependency
  2020-12-06 17:35 [Buildroot] [PATCHv5 1/5] package/llvm: add BPF backend Romain Naour
                   ` (2 preceding siblings ...)
  2020-12-06 17:35 ` [Buildroot] [PATCHv5 4/5] package/bpftrace: " Romain Naour
@ 2020-12-06 17:35 ` Romain Naour
  2020-12-20  1:47   ` Qais Yousef
  2020-12-20  1:43 ` [Buildroot] [PATCHv5 1/5] package/llvm: add BPF backend Qais Yousef
  4 siblings, 1 reply; 15+ messages in thread
From: Romain Naour @ 2020-12-06 17:35 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Romain Naour <romain.naour@gmail.com>
Cc: Qais Yousef <qais.yousef@arm.com>
---
 package/bcc/bcc.mk | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

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] 15+ messages in thread

* [Buildroot] [PATCHv5 1/5] package/llvm: add BPF backend
  2020-12-06 17:35 [Buildroot] [PATCHv5 1/5] package/llvm: add BPF backend Romain Naour
                   ` (3 preceding siblings ...)
  2020-12-06 17:35 ` [Buildroot] [PATCHv5 5/5] package/bcc: add optional luajit dependency Romain Naour
@ 2020-12-20  1:43 ` Qais Yousef
  4 siblings, 0 replies; 15+ messages in thread
From: Qais Yousef @ 2020-12-20  1:43 UTC (permalink / raw)
  To: buildroot

On 12/06/20 18:35, 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>
> Cc: Qais Yousef <qais.yousef@arm.com>
> ---

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

Thanks

--
Qais Yousef

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

* [Buildroot] [PATCHv5 2/5] package/bcc: new package
  2020-12-06 17:35 ` [Buildroot] [PATCHv5 2/5] package/bcc: new package Romain Naour
@ 2020-12-20  1:44   ` Qais Yousef
  2020-12-20  9:17     ` Romain Naour
  0 siblings, 1 reply; 15+ messages in thread
From: Qais Yousef @ 2020-12-20  1:44 UTC (permalink / raw)
  To: buildroot

Hi Romain

On 12/06/20 18:35, 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>
> Cc: Qais Yousef <qais.yousef@arm.com>
> ---

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

With that patch added

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

Thanks

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

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

* [Buildroot] [PATCHv5 4/5] package/bpftrace: new package
  2020-12-06 17:35 ` [Buildroot] [PATCHv5 4/5] package/bpftrace: " Romain Naour
@ 2020-12-20  1:47   ` Qais Yousef
  2020-12-20 10:01     ` Romain Naour
  0 siblings, 1 reply; 15+ messages in thread
From: Qais Yousef @ 2020-12-20  1:47 UTC (permalink / raw)
  To: buildroot

On 12/06/20 18:35, 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.
> 
> 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>
> ---
> v2: patch to build bundled libraries statically
>     Add glibc dependency
>     Rework to select bcc, libbpf and llvm RTII dependencies.
>     Add reverse dependencies
>     Add BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS
>     Bump the version to the latest (upcoming 0.12)
>       due to many build issues (and patch to backport) with
>       the latest release.
>     Add binutils optional dependency to provide libbfd and libopcodes.
>     Disable manpages.
> ---

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

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

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

Thanks for the rework!

Cheers

--
Qais Yousef

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

* [Buildroot] [PATCHv5 5/5] package/bcc: add optional luajit dependency
  2020-12-06 17:35 ` [Buildroot] [PATCHv5 5/5] package/bcc: add optional luajit dependency Romain Naour
@ 2020-12-20  1:47   ` Qais Yousef
  2020-12-20 10:11     ` Romain Naour
  0 siblings, 1 reply; 15+ messages in thread
From: Qais Yousef @ 2020-12-20  1:47 UTC (permalink / raw)
  To: buildroot

On 12/06/20 18:35, Romain Naour wrote:
> Signed-off-by: Romain Naour <romain.naour@gmail.com>
> Cc: Qais Yousef <qais.yousef@arm.com>
> ---

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

Anyway;

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

Thanks

--
Qais Yousef

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

* [Buildroot] [PATCHv5 3/5] package/libbpf: new package
  2020-12-06 17:35 ` [Buildroot] [PATCHv5 3/5] package/libbpf: " Romain Naour
@ 2020-12-20  2:07   ` Qais Yousef
  0 siblings, 0 replies; 15+ messages in thread
From: Qais Yousef @ 2020-12-20  2:07 UTC (permalink / raw)
  To: buildroot

On 12/06/20 18:35, 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 admit, I'm not sure how to use this on its own. It did compile fine for me
though for arm64.

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

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

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

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

Thanks

--
Qais Yousef

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

* [Buildroot] [PATCHv5 2/5] package/bcc: new package
  2020-12-20  1:44   ` Qais Yousef
@ 2020-12-20  9:17     ` Romain Naour
  0 siblings, 0 replies; 15+ messages in thread
From: Romain Naour @ 2020-12-20  9:17 UTC (permalink / raw)
  To: buildroot

Hello Qais,

Le 20/12/2020 ? 02:44, Qais Yousef a ?crit?:
> Hi Romain
> 
> On 12/06/20 18:35, 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>
>> Cc: Qais Yousef <qais.yousef@arm.com>
>> ---
> 
> This only missed adding my patch to fix up python installation path (attached).

Sorry I missed it.

> 
> With that patch added

Added for the next submission.

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

Thanks for your tests and review!

Best regards,
Romain


> 
> Thanks
> 
> --
> Qais Yousef
> 

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

* [Buildroot] [PATCHv5 4/5] package/bpftrace: new package
  2020-12-20  1:47   ` Qais Yousef
@ 2020-12-20 10:01     ` Romain Naour
  2020-12-20 15:22       ` Romain Naour
  2020-12-21 11:44       ` Qais Yousef
  0 siblings, 2 replies; 15+ messages in thread
From: Romain Naour @ 2020-12-20 10:01 UTC (permalink / raw)
  To: buildroot

Le 20/12/2020 ? 02:47, Qais Yousef a ?crit?:
> On 12/06/20 18:35, 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.
>>
>> 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>
>> ---
>> v2: patch to build bundled libraries statically
>>     Add glibc dependency
>>     Rework to select bcc, libbpf and llvm RTII dependencies.
>>     Add reverse dependencies
>>     Add BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS
>>     Bump the version to the latest (upcoming 0.12)
>>       due to many build issues (and patch to backport) with
>>       the latest release.
>>     Add binutils optional dependency to provide libbfd and libopcodes.
>>     Disable manpages.
>> ---
> 
> I don't think we need the dependency on libbpf? BCC provides it and we depend
> on it.

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

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

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

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

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

Indeed, the DEVELOPERS file update is missing :-/

> 
> Beside the question on the addition of libbpf dependency, this looks good to
> me.
> 
> Thanks for the rework!

Thanks again for your help!

Best regards,
Romain

> 
> Cheers
> 
> --
> Qais Yousef
> 

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

* [Buildroot] [PATCHv5 5/5] package/bcc: add optional luajit dependency
  2020-12-20  1:47   ` Qais Yousef
@ 2020-12-20 10:11     ` Romain Naour
  0 siblings, 0 replies; 15+ messages in thread
From: Romain Naour @ 2020-12-20 10:11 UTC (permalink / raw)
  To: buildroot

Le 20/12/2020 ? 02:47, Qais Yousef a ?crit?:
> On 12/06/20 18:35, Romain Naour wrote:
>> Signed-off-by: Romain Naour <romain.naour@gmail.com>
>> Cc: Qais Yousef <qais.yousef@arm.com>
>> ---
> 
> Empty commit message looks weird to me. But maybe buildroot community don't
> mind this.

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

Best regards,
Romain

> 
> Anyway;
> 
> Tested-by: Qais Yousef <qais.yousef@arm.com>
> Reviewed-by: Qais Yousef <qais.yousef@arm.com>
> 
> Thanks
> 
> --
> Qais Yousef
> 

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

* [Buildroot] [PATCHv5 4/5] package/bpftrace: new package
  2020-12-20 10:01     ` Romain Naour
@ 2020-12-20 15:22       ` Romain Naour
  2020-12-21 11:44       ` Qais Yousef
  1 sibling, 0 replies; 15+ messages in thread
From: Romain Naour @ 2020-12-20 15:22 UTC (permalink / raw)
  To: buildroot

Le 20/12/2020 ? 11:01, Romain Naour a ?crit?:
> Le 20/12/2020 ? 02:47, Qais Yousef a ?crit?:
>> On 12/06/20 18:35, 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.
>>>
>>> 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>
>>> ---
>>> v2: patch to build bundled libraries statically
>>>     Add glibc dependency
>>>     Rework to select bcc, libbpf and llvm RTII dependencies.
>>>     Add reverse dependencies
>>>     Add BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS
>>>     Bump the version to the latest (upcoming 0.12)
>>>       due to many build issues (and patch to backport) with
>>>       the latest release.
>>>     Add binutils optional dependency to provide libbfd and libopcodes.
>>>     Disable manpages.
>>> ---
>>
>> I don't think we need the dependency on libbpf? BCC provides it and we depend
>> on it.
> 
> The libbpf provided by BCC is named libbcc_bpf.so but bpftrace really expect
> libbpf.so
> 
> I added libbpf package since distribution packages use it.
> https://archlinux.org/packages/community/x86_64/bpftrace/
> https://src.fedoraproject.org/rpms/bpftrace/blob/master/f/bpftrace.spec#_27
> 
> But bpftrace try to find bcc_bpf only for static linking.
> It's not clear what's the libbpf implementation the buildsystem is trying to
> use. Why it is not using the same bpf library for both static ans shared linking ?
> 
> I think it's better use use the library from upstream (libbpf) rather than a
> library bundled in another software (bcc_libbpf).

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

Best regards,
Romain

> 
>>
>> Feel free to add my name to DEVELOPERS file too and your name too.
> 
> Indeed, the DEVELOPERS file update is missing :-/
> 
>>
>> Beside the question on the addition of libbpf dependency, this looks good to
>> me.
>>
>> Thanks for the rework!
> 
> Thanks again for your help!
> 
> Best regards,
> Romain
> 
>>
>> Cheers
>>
>> --
>> Qais Yousef
>>
> 

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

* [Buildroot] [PATCHv5 4/5] package/bpftrace: new package
  2020-12-20 10:01     ` Romain Naour
  2020-12-20 15:22       ` Romain Naour
@ 2020-12-21 11:44       ` Qais Yousef
  1 sibling, 0 replies; 15+ messages in thread
From: Qais Yousef @ 2020-12-21 11:44 UTC (permalink / raw)
  To: buildroot

On 12/20/20 11:01, Romain Naour wrote:
> Le 20/12/2020 ? 02:47, Qais Yousef a ?crit?:
> > On 12/06/20 18:35, 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.
> >>
> >> 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>
> >> ---
> >> v2: patch to build bundled libraries statically
> >>     Add glibc dependency
> >>     Rework to select bcc, libbpf and llvm RTII dependencies.
> >>     Add reverse dependencies
> >>     Add BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS
> >>     Bump the version to the latest (upcoming 0.12)
> >>       due to many build issues (and patch to backport) with
> >>       the latest release.
> >>     Add binutils optional dependency to provide libbfd and libopcodes.
> >>     Disable manpages.
> >> ---
> > 
> > I don't think we need the dependency on libbpf? BCC provides it and we depend
> > on it.
> 
> The libbpf provided by BCC is named libbcc_bpf.so but bpftrace really expect
> libbpf.so
> 
> I added libbpf package since distribution packages use it.
> https://archlinux.org/packages/community/x86_64/bpftrace/
> https://src.fedoraproject.org/rpms/bpftrace/blob/master/f/bpftrace.spec#_27
> 
> But bpftrace try to find bcc_bpf only for static linking.
> It's not clear what's the libbpf implementation the buildsystem is trying to
> use. Why it is not using the same bpf library for both static ans shared linking ?

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

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

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

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

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

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

Thanks

--
Qais Yousef

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

end of thread, other threads:[~2020-12-21 11:44 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-06 17:35 [Buildroot] [PATCHv5 1/5] package/llvm: add BPF backend Romain Naour
2020-12-06 17:35 ` [Buildroot] [PATCHv5 2/5] package/bcc: new package Romain Naour
2020-12-20  1:44   ` Qais Yousef
2020-12-20  9:17     ` Romain Naour
2020-12-06 17:35 ` [Buildroot] [PATCHv5 3/5] package/libbpf: " Romain Naour
2020-12-20  2:07   ` Qais Yousef
2020-12-06 17:35 ` [Buildroot] [PATCHv5 4/5] package/bpftrace: " Romain Naour
2020-12-20  1:47   ` Qais Yousef
2020-12-20 10:01     ` Romain Naour
2020-12-20 15:22       ` Romain Naour
2020-12-21 11:44       ` Qais Yousef
2020-12-06 17:35 ` [Buildroot] [PATCHv5 5/5] package/bcc: add optional luajit dependency Romain Naour
2020-12-20  1:47   ` Qais Yousef
2020-12-20 10:11     ` Romain Naour
2020-12-20  1:43 ` [Buildroot] [PATCHv5 1/5] package/llvm: add BPF backend Qais Yousef

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.