diff mbox series

[v7,2/2] package/bpftrace: new package

Message ID 20240120011759.2454452-3-martineau@kernel.org
State Accepted
Headers show
Series bcc and bpftrace | expand

Commit Message

Mat Martineau Jan. 20, 2024, 1:17 a.m. UTC
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.1 and later).

Only tested on x86_64.

v7 changes:
 - Ported to current buildroot release
 - Update to bpftrace 0.19.1
 - Add libcereal dependency
 - Use new configure option for USE_SYSTEM_BPF_BCC
 - Update dependencies
 - Use BUILD_SHARED_LIBS=OFF instead of patching cmake files
 - Don't install tool docs in target filesystem
 - Propagate config dependencies

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>
Cc: Qais Yousef <qyousef@layalina.io>
Signed-off-by: Mat Martineau <martineau@kernel.org>

squashme: bpftrace: more review fixups
---
 DEVELOPERS                     |  4 +++
 package/Config.in              |  1 +
 package/bpftrace/Config.in     | 54 ++++++++++++++++++++++++++++++++++
 package/bpftrace/bpftrace.hash |  3 ++
 package/bpftrace/bpftrace.mk   | 24 +++++++++++++++
 5 files changed, 86 insertions(+)
 create mode 100644 package/bpftrace/Config.in
 create mode 100644 package/bpftrace/bpftrace.hash
 create mode 100644 package/bpftrace/bpftrace.mk

Comments

Arnout Vandecappelle April 3, 2024, 9:08 p.m. UTC | #1
On 20/01/2024 02:17, Mat Martineau 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.1 and later).
> 
> Only tested on x86_64.
> 
> v7 changes:
>   - Ported to current buildroot release
>   - Update to bpftrace 0.19.1
>   - Add libcereal dependency
>   - Use new configure option for USE_SYSTEM_BPF_BCC
>   - Update dependencies
>   - Use BUILD_SHARED_LIBS=OFF instead of patching cmake files
>   - Don't install tool docs in target filesystem
>   - Propagate config dependencies

  This shouldn't be in the commit message, it should be below the --- line.

> 
> 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>
> Cc: Qais Yousef <qyousef@layalina.io>
> Signed-off-by: Mat Martineau <martineau@kernel.org>
> 
> squashme: bpftrace: more review fixups

  And this shouldn't be there :-)

  I applied both to master with this fixed up and a few more things.

[snip]
> diff --git a/package/bpftrace/Config.in b/package/bpftrace/Config.in
> new file mode 100644
> index 000000000000..e8afa37b6e63
> --- /dev/null
> +++ b/package/bpftrace/Config.in
> @@ -0,0 +1,54 @@
> +config BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS
> +	bool
> +	default y if BR2_aarch64 || BR2_aarch64_be
> +	default y if BR2_x86_64
> +	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
> +
> +config BR2_PACKAGE_BPFTRACE
> +	bool "bpftrace"
> +	depends on BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS
> +	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS # bcc

  This is already in BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS so removed.

> +	depends on BR2_TOOLCHAIN_USES_GLIBC # bcc
> +	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_7 # bcc -> clang
> +	depends on BR2_TOOLCHAIN_HAS_SYNC_4 # libbpf

  This is considered an arch dependency so moved to the beginning of the 
dependencies list, and repeated in the comment.

> +	depends on BR2_TOOLCHAIN_HAS_THREADS # libbpf
> +	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_13 # libbpf
> +	depends on BR2_INSTALL_LIBSTDCPP # bcc -> clang
> +	depends on BR2_HOST_GCC_AT_LEAST_7 # bcc -> clang
> +	depends on BR2_USE_WCHAR # bcc -> clang, bcc -> python3, libbpf
> +	depends on BR2_USE_MMU # bcc -> python3

  This is also an arch dependency.

> +	depends on BR2_TOOLCHAIN_HAS_THREADS # bcc -> clang, bcc -> python3
> +	depends on !BR2_STATIC_LIBS # bcc -> clang, bcc -> python3, libbpf
> +	select BR2_PACKAGE_BCC
> +	select BR2_PACKAGE_LIBBPF
> +	select BR2_PACKAGE_CEREAL
> +	select BR2_PACKAGE_ELFUTILS
> +	select BR2_PACKAGE_BZIP2
> +	select BR2_PACKAGE_XZ
> +	# LLVM RTTI mendatory: https://github.com/iovisor/bpftrace/issues/1156
> +	select BR2_PACKAGE_LLVM_RTTI
> +	select BR2_PACKAGE_LLVM

  I ordered all selects alphabetically.

> +	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 >= 7"
> +	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS

  This should have been BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS. In addition, as 
mentioned, the SYNC_4 and MMU dependencies are missing.

> +	depends on !BR2_TOOLCHAIN_USES_GLIBC || !BR2_INSTALL_LIBSTDCPP \
> +		|| !BR2_TOOLCHAIN_GCC_AT_LEAST_7

  host GCC 7 and kernel headers 4.13 dependencies are missing here.

> diff --git a/package/bpftrace/bpftrace.hash b/package/bpftrace/bpftrace.hash
> new file mode 100644
> index 000000000000..c2ecc927da35
> --- /dev/null
> +++ b/package/bpftrace/bpftrace.hash
> @@ -0,0 +1,3 @@
> +# locally calculated
> +sha256  b520340f28ce4d6f2fb2355f1675b6801ff8498ed9e8bff14abbbf6baff5a08e  bpftrace-0.19.1.tar.gz
> +sha256  cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30  LICENSE
> diff --git a/package/bpftrace/bpftrace.mk b/package/bpftrace/bpftrace.mk
> new file mode 100644
> index 000000000000..072cee4ae72e
> --- /dev/null
> +++ b/package/bpftrace/bpftrace.mk
> @@ -0,0 +1,24 @@
> +################################################################################
> +#
> +# bpftrace
> +#
> +################################################################################
> +
> +BPFTRACE_VERSION = 0.19.1
> +BPFTRACE_SITE = $(call github,iovisor,bpftrace,v$(BPFTRACE_VERSION))
> +BPFTRACE_LICENSE = Apache-2.0
> +BPFTRACE_LICENSE_FILES = LICENSE
> +BPFTRACE_DEPENDENCIES = host-bison host-flex bcc libbpf cereal bzip2 xz elfutils llvm

  I ordered these alphabetically, and changed to one per line.

> +
> +# libbfd, libopcodes
> +ifeq ($(BR2_PACKAGE_BINUTILS),y)
> +BPFTRACE_DEPENDENCIES += binutils
> +endif
> +
> +BPFTRACE_CONF_OPTS += -DENABLE_MAN:BOOL=OFF \
> +	-DUSE_SYSTEM_BPF_BCC:BOOL=ON \
> +	-DBUILD_SHARED_LIBS:BOOL=OFF \
> +	-DBUILD_TESTING:BOOL=OFF \
> +	-DINSTALL_TOOL_DOCS:BOOL=OFF

  I ordered these alphabetically as well.

  Regards,
  Arnout

> +
> +$(eval $(cmake-package))
Mat Martineau April 4, 2024, 11:35 p.m. UTC | #2
On Wed, 3 Apr 2024, Arnout Vandecappelle wrote:

>
>
> On 20/01/2024 02:17, Mat Martineau 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.1 and later).
>> 
>> Only tested on x86_64.
>> 
>> v7 changes:
>>   - Ported to current buildroot release
>>   - Update to bpftrace 0.19.1
>>   - Add libcereal dependency
>>   - Use new configure option for USE_SYSTEM_BPF_BCC
>>   - Update dependencies
>>   - Use BUILD_SHARED_LIBS=OFF instead of patching cmake files
>>   - Don't install tool docs in target filesystem
>>   - Propagate config dependencies
>
> This shouldn't be in the commit message, it should be below the --- line.
>
>> 
>> 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>
>> Cc: Qais Yousef <qyousef@layalina.io>
>> Signed-off-by: Mat Martineau <martineau@kernel.org>
>>

Hi Arnout,

>> squashme: bpftrace: more review fixups
>
> And this shouldn't be there :-)

Whoops, sorry about that!

>
> I applied both to master with this fixed up and a few more things.

Thanks so much for the review and fixups, I'll take that information in to 
account for future patches. I will send followup patches for the latest 
bcc and bpftrace versions.


Regards,

Mat
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index 0af50f1f848d..2218b13f1121 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -2505,6 +2505,9 @@  F:	package/synergy/
 N:	Prabhu Sannachi <prabhu.sannachi@collins.com>
 F:	package/redis-plus-plus/
 
+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
@@ -2606,6 +2609,7 @@  F:	package/alure/
 F:	package/aubio/
 F:	package/bcc/
 F:	package/binutils/
+F:	package/bpftrace/
 F:	package/bullet/
 F:	package/clinfo/
 F:	package/efl/
diff --git a/package/Config.in b/package/Config.in
index 662c935a1f1c..1fc983dfd8aa 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -91,6 +91,7 @@  menu "Debugging, profiling and benchmark"
 	source "package/blktrace/Config.in"
 	source "package/bonnie/Config.in"
 	source "package/bpftool/Config.in"
+	source "package/bpftrace/Config.in"
 	source "package/cache-calibrator/Config.in"
 	source "package/clinfo/Config.in"
 	source "package/clpeak/Config.in"
diff --git a/package/bpftrace/Config.in b/package/bpftrace/Config.in
new file mode 100644
index 000000000000..e8afa37b6e63
--- /dev/null
+++ b/package/bpftrace/Config.in
@@ -0,0 +1,54 @@ 
+config BR2_PACKAGE_BPFTRACE_ARCH_SUPPORTS
+	bool
+	default y if BR2_aarch64 || BR2_aarch64_be
+	default y if BR2_x86_64
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+
+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_7 # bcc -> clang
+	depends on BR2_TOOLCHAIN_HAS_SYNC_4 # libbpf
+	depends on BR2_TOOLCHAIN_HAS_THREADS # libbpf
+	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_13 # libbpf
+	depends on BR2_INSTALL_LIBSTDCPP # bcc -> clang
+	depends on BR2_HOST_GCC_AT_LEAST_7 # bcc -> clang
+	depends on BR2_USE_WCHAR # bcc -> clang, bcc -> python3, libbpf
+	depends on BR2_USE_MMU # bcc -> python3
+	depends on BR2_TOOLCHAIN_HAS_THREADS # bcc -> clang, bcc -> python3
+	depends on !BR2_STATIC_LIBS # bcc -> clang, bcc -> python3, libbpf
+	select BR2_PACKAGE_BCC
+	select BR2_PACKAGE_LIBBPF
+	select BR2_PACKAGE_CEREAL
+	select BR2_PACKAGE_ELFUTILS
+	select BR2_PACKAGE_BZIP2
+	select BR2_PACKAGE_XZ
+	# LLVM RTTI mendatory: https://github.com/iovisor/bpftrace/issues/1156
+	select BR2_PACKAGE_LLVM_RTTI
+	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 >= 7"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	depends on !BR2_TOOLCHAIN_USES_GLIBC || !BR2_INSTALL_LIBSTDCPP \
+		|| !BR2_TOOLCHAIN_GCC_AT_LEAST_7
diff --git a/package/bpftrace/bpftrace.hash b/package/bpftrace/bpftrace.hash
new file mode 100644
index 000000000000..c2ecc927da35
--- /dev/null
+++ b/package/bpftrace/bpftrace.hash
@@ -0,0 +1,3 @@ 
+# locally calculated
+sha256  b520340f28ce4d6f2fb2355f1675b6801ff8498ed9e8bff14abbbf6baff5a08e  bpftrace-0.19.1.tar.gz
+sha256  cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30  LICENSE
diff --git a/package/bpftrace/bpftrace.mk b/package/bpftrace/bpftrace.mk
new file mode 100644
index 000000000000..072cee4ae72e
--- /dev/null
+++ b/package/bpftrace/bpftrace.mk
@@ -0,0 +1,24 @@ 
+################################################################################
+#
+# bpftrace
+#
+################################################################################
+
+BPFTRACE_VERSION = 0.19.1
+BPFTRACE_SITE = $(call github,iovisor,bpftrace,v$(BPFTRACE_VERSION))
+BPFTRACE_LICENSE = Apache-2.0
+BPFTRACE_LICENSE_FILES = LICENSE
+BPFTRACE_DEPENDENCIES = host-bison host-flex bcc libbpf cereal bzip2 xz elfutils llvm
+
+# libbfd, libopcodes
+ifeq ($(BR2_PACKAGE_BINUTILS),y)
+BPFTRACE_DEPENDENCIES += binutils
+endif
+
+BPFTRACE_CONF_OPTS += -DENABLE_MAN:BOOL=OFF \
+	-DUSE_SYSTEM_BPF_BCC:BOOL=ON \
+	-DBUILD_SHARED_LIBS:BOOL=OFF \
+	-DBUILD_TESTING:BOOL=OFF \
+	-DINSTALL_TOOL_DOCS:BOOL=OFF
+
+$(eval $(cmake-package))