Skip to contentSkip to conversation

package/llvm: add BPF backend

PATCH New Romain Naour 3 participants 6 messages Jan 13, 2019 – Mar 14, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 package/llvm: add BPF backend

From: Romain Naour <[email protected]>

The BPF backend is needed for bcc tool.

Cc Valentin Korenblit <[email protected]>
---
 package/llvm/Config.in | 6 ++++++
 package/llvm/llvm.mk   | 5 +++++
 2 files changed, 11 insertions(+)
package/llvm/Config.in +6 -0
index 83e94660eb..72d920e226 100644
@@ -35,6 +35,12 @@ config BR2_PACKAGE_LLVM_AMDGPU
 	  Build AMDGPU target. Select this option if you are going
 	  to install mesa3d with llvm and use Gallium Radeon driver.
 
+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, host gcc >= 4.8, dynamic library"
package/llvm/llvm.mk +5 -0
index 613f5f5d47..9999389651 100644
@@ -54,6 +54,11 @@ ifeq ($(BR2_PACKAGE_LLVM_AMDGPU),y)
 LLVM_TARGETS_TO_BUILD += AMDGPU
 endif
 
+# Build BPF backend
+ifeq ($(BR2_PACKAGE_LLVM_BPF),y)
+LLVM_TARGETS_TO_BUILD += BPF
+endif
+
 # Use native llvm-tblgen from host-llvm (needed for cross-compilation)
 LLVM_CONF_OPTS += -DLLVM_TABLEGEN=$(HOST_DIR)/bin/llvm-tblgen
 
Signature · 1 line
2.14.5
#1 lore raw

PATCH 2/2 package/bcc: new package

From: Romain Naour <[email protected]>

Before using bcc, you need to copy the kernel source code to "/lib/module/<kernel version>/build" on the target. That's because the clang frontend build eBPF code at runtime.

There are some issues with this frontend due to the hardcoded architecture support and the use of GNU tuple (x86_64-unknown-linux-gnu). That's why the bcc package dependency is limited to Glibc toolchain.

bcc needs tracing support, at least CONFIG_KPROBES, CONFIG_BPFILTER and CONFIG_BPF_JIT. See [1] for details.

bcc needs BPF target support in llvm libraries.
Add a patch disabling man pages.

[1] https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md

Cc Jugurtha BELKALEM <[email protected]>

---
The needs of kernel sources on the target is anoying for small devices. At least, I'm able to complete the bcc tutorial [1] on my x86_64 target.

[1] https://github.com/iovisor/bcc/blob/master/docs/tutorial.md

---
 DEVELOPERS                                         |  1 +
 package/Config.in                                  |  1 +
 ...CMake-Allow-to-disable-building-man-pages.patch | 35 +++++++++++++++
 package/bcc/Config.in                              | 50 ++++++++++++++++++++++
 package/bcc/bcc.hash                               |  3 ++
 package/bcc/bcc.mk                                 | 23 ++++++++++
 6 files changed, 113 insertions(+)
 create mode 100644 package/bcc/0001-CMake-Allow-to-disable-building-man-pages.patch
 create mode 100644 package/bcc/Config.in
 create mode 100644 package/bcc/bcc.hash
 create mode 100644 package/bcc/bcc.mk
DEVELOPERS +1 -0
index 0d4c4f1d60..f5dc078c69 100644
@@ -1831,6 +1831,7 @@ F:	package/vnstat/
 
 N:	Romain Naour <[email protected]>
 F:	package/aubio/
+F:	package/bcc/
 F:	package/bullet/
 F:	package/darktable/
 F:	package/efl/
package/Config.in +1 -0
index 8d05303472..434427f455 100644
@@ -79,6 +79,7 @@ menu "Compressors and decompressors"
 endmenu
 
 menu "Debugging, profiling and benchmark"
+	source "package/bcc/Config.in"
 	source "package/blktrace/Config.in"
 	source "package/bonnie/Config.in"
 	source "package/cache-calibrator/Config.in"
package/bcc/0001-CMake-Allow-to-disable-building-man-pages.patch new file +35 -0
new file mode 100644
index 0000000000..c5c87d52e9
@@ -0,0 +1,35 @@
+From a99f097aedbf964356e62c0c4bba1257f108c3eb Mon Sep 17 00:00:00 2001
+From: Romain Naour <[email protected]>
+Date: Fri, 7 Dec 2018 22:36:21 +0100
+Subject: [PATCH] CMake: Allow to disable building man pages
+
+Signed-off-by: Romain Naour <[email protected]>
+---
+ CMakeLists.txt | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index bb3f53b9..5e95d555 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -19,6 +19,7 @@ include(cmake/FindCompilerFlag.cmake)
+ 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_CPP_API "Enable C++ API" ON "ENABLE_USDT" OFF)
+ 
+ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
+@@ -88,7 +89,9 @@ add_subdirectory(src)
+ add_subdirectory(introspection)
+ if(ENABLE_CLANG_JIT)
+ add_subdirectory(examples)
++if(ENABLE_MAN)
+ add_subdirectory(man)
++endif(ENABLE_MAN)
+ add_subdirectory(tests)
+ add_subdirectory(tools)
+ endif(ENABLE_CLANG_JIT)
+-- 
+2.14.5
+
package/bcc/Config.in new file +50 -0

50 lines not on this page · raw message

package/bcc/bcc.hash new file +3 -0
new file mode 100644
index 0000000000..19eccb37ca
@@ -0,0 +1,3 @@
+# locally calculated
+sha256 269949a47f9ed2ff01b5ebca20ec4a52341f7ff14b033b9dc1669b72a87af042  bcc-v0.8.0.tar.gz
+sha256 b40930bbcf80744c86c46a12bc9da056641d722716c378f5659b9e555ef833e1  LICENSE.txt
package/bcc/bcc.mk new file +23 -0
new file mode 100644
index 0000000000..401727c68a
@@ -0,0 +1,23 @@
+################################################################################
+#
+# bcc
+#
+################################################################################
+
+BCC_VERSION = v0.8.0
+BCC_SITE = $(call github,iovisor,bcc,$(BCC_VERSION))
+BCC_LICENSE = Apache-2.0
+BCC_LICENSE_FILES = LICENSE.txt
+# libbcc.so and libbpf.so
+BCC_INSTALL_STAGING = YES
+
+BCC_DEPENDENCIES = host-bison host-flex clang elfutils flex llvm luajit
+
+# 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
+
+$(eval $(cmake-package))
Signature · 1 line
2.14.5
#2 lore raw

PATCH 2/2 package/bcc: new package

Hi All,

Le 13/01/2019 ? 22:21, Romain Naour a ?crit?:

Quoted 5 lines

From: Romain Naour <[email protected]>

Before using bcc, you need to copy the kernel source code to "/lib/module/<kernel version>/build" on the target. That's because the clang frontend build eBPF code at runtime.

This PR seems interesting:

"This patch separates BPFModule clang- and runtime functionality."
https://github.com/iovisor/bcc/pull/2078

Best regards,
Romain

Quoted 193 lines

There are some issues with this frontend due to the hardcoded architecture support and the use of GNU tuple (x86_64-unknown-linux-gnu). That's why the bcc package dependency is limited to Glibc toolchain.

bcc needs tracing support, at least CONFIG_KPROBES, CONFIG_BPFILTER and CONFIG_BPF_JIT. See [1] for details.

bcc needs BPF target support in llvm libraries.
Add a patch disabling man pages.

[1] https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md

Cc Jugurtha BELKALEM <[email protected]>

---
The needs of kernel sources on the target is anoying for small devices. At least, I'm able to complete the bcc tutorial [1] on my x86_64 target.

[1] https://github.com/iovisor/bcc/blob/master/docs/tutorial.md

---
 DEVELOPERS                                         |  1 +
 package/Config.in                                  |  1 +
 ...CMake-Allow-to-disable-building-man-pages.patch | 35 +++++++++++++++
 package/bcc/Config.in                              | 50 ++++++++++++++++++++++
 package/bcc/bcc.hash                               |  3 ++
 package/bcc/bcc.mk                                 | 23 ++++++++++
 6 files changed, 113 insertions(+)
 create mode 100644 package/bcc/0001-CMake-Allow-to-disable-building-man-pages.patch
 create mode 100644 package/bcc/Config.in
 create mode 100644 package/bcc/bcc.hash
 create mode 100644 package/bcc/bcc.mk
DEVELOPERS +1 -0
index 0d4c4f1d60..f5dc078c69 100644
@@ -1831,6 +1831,7 @@ F:	package/vnstat/
 
 N:	Romain Naour <[email protected]>
 F:	package/aubio/
+F:	package/bcc/
 F:	package/bullet/
 F:	package/darktable/
 F:	package/efl/
package/Config.in +1 -0
index 8d05303472..434427f455 100644
@@ -79,6 +79,7 @@ menu "Compressors and decompressors"
 endmenu
 
 menu "Debugging, profiling and benchmark"
+	source "package/bcc/Config.in"
 	source "package/blktrace/Config.in"
 	source "package/bonnie/Config.in"
 	source "package/cache-calibrator/Config.in"
package/bcc/0001-CMake-Allow-to-disable-building-man-pages.patch new file +35 -0
new file mode 100644
index 0000000000..c5c87d52e9
@@ -0,0 +1,35 @@
+From a99f097aedbf964356e62c0c4bba1257f108c3eb Mon Sep 17 00:00:00 2001
+From: Romain Naour <[email protected]>
+Date: Fri, 7 Dec 2018 22:36:21 +0100
+Subject: [PATCH] CMake: Allow to disable building man pages
+
+Signed-off-by: Romain Naour <[email protected]>
+---
+ CMakeLists.txt | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index bb3f53b9..5e95d555 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -19,6 +19,7 @@ include(cmake/FindCompilerFlag.cmake)
+ 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_CPP_API "Enable C++ API" ON "ENABLE_USDT" OFF)
+ 
+ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
+@@ -88,7 +89,9 @@ add_subdirectory(src)
+ add_subdirectory(introspection)
+ if(ENABLE_CLANG_JIT)
+ add_subdirectory(examples)
++if(ENABLE_MAN)
+ add_subdirectory(man)
++endif(ENABLE_MAN)
+ add_subdirectory(tests)
+ add_subdirectory(tools)
+ endif(ENABLE_CLANG_JIT)
+-- 
+2.14.5
+
package/bcc/Config.in new file +50 -0
new file mode 100644
index 0000000000..7bc681e639
@@ -0,0 +1,50 @@
+config BR2_PACKAGE_BCC
+	bool "bcc"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	depends on BR2_PACKAGE_LUAJIT_ARCH_SUPPORTS
+	depends on BR2_TOOLCHAIN_USES_GLIBC # hardcode GNU tuple (x86_64-unknown-linux-gnu)
+	depends on BR2_LINUX_KERNEL # needs kernel sources on the target
+	depends on BR2_HOST_GCC_AT_LEAST_4_8 # clang
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8 # clang
+	depends on BR2_TOOLCHAIN_HAS_THREADS # clang
+	depends on BR2_INSTALL_LIBSTDCPP # clang
+	depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_64735 # clang
+	depends on !BR2_STATIC_LIBS # clang, luajit
+	depends on BR2_USE_WCHAR # clang
+	select BR2_PACKAGE_CLANG
+	select BR2_PACKAGE_ELFUTILS
+	select BR2_PACKAGE_FLEX # needs FlexLexer.h
+	select BR2_PACKAGE_LLVM_BPF
+	select BR2_PACKAGE_LUAJIT
+	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 to copy the kernel source
+	  code to the target. By default bcc use:
+	  "/lib/module/<kernel version>/build". That's because the
+	  clang frontend build eBPF code at runtime.
+
+	  https://github.com/iovisor/bcc
+
+comment "bcc needs a Linux kernel to be built"
+	depends on !BR2_LINUX_KERNEL
+
+comment "bcc needs a glibc toolchain w/ wchar, threads, C++, gcc >= 4.8, host gcc >= 4.8, dynamic library"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	depends on BR2_LINUX_KERNEL
+	depends on !BR2_TOOLCHAIN_USES_GLIBC || !BR2_TOOLCHAIN_HAS_THREADS \
+		|| !BR2_INSTALL_LIBSTDCPP || !BR2_HOST_GCC_AT_LEAST_4_8 \
+		|| !BR2_TOOLCHAIN_GCC_AT_LEAST_4_8 || BR2_STATIC_LIBS \
+		|| !BR2_USE_WCHAR
+
+comment "bcc needs a toolchain not affected by GCC bug 64735"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	depends on BR2_LINUX_KERNEL
+	depends on BR2_TOOLCHAIN_HAS_GCC_BUG_64735
package/bcc/bcc.hash new file +3 -0
new file mode 100644
index 0000000000..19eccb37ca
@@ -0,0 +1,3 @@
+# locally calculated
+sha256 269949a47f9ed2ff01b5ebca20ec4a52341f7ff14b033b9dc1669b72a87af042  bcc-v0.8.0.tar.gz
+sha256 b40930bbcf80744c86c46a12bc9da056641d722716c378f5659b9e555ef833e1  LICENSE.txt
package/bcc/bcc.mk new file +23 -0
new file mode 100644
index 0000000000..401727c68a
@@ -0,0 +1,23 @@
+################################################################################
+#
+# bcc
+#
+################################################################################
+
+BCC_VERSION = v0.8.0
+BCC_SITE = $(call github,iovisor,bcc,$(BCC_VERSION))
+BCC_LICENSE = Apache-2.0
+BCC_LICENSE_FILES = LICENSE.txt
+# libbcc.so and libbpf.so
+BCC_INSTALL_STAGING = YES
+
+BCC_DEPENDENCIES = host-bison host-flex clang elfutils flex llvm luajit
+
+# 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
+
+$(eval $(cmake-package))
#3 lore raw

PATCH 2/2 package/bcc: new package

In reply to Romain Naour

Romain,

Quoted 17 lines · Romain Naour

From: Romain Naour <[email protected]>

Before using bcc, you need to copy the kernel source code to "/lib/module/<kernel version>/build" on the target. That's because the clang frontend build eBPF code at runtime.

There are some issues with this frontend due to the hardcoded architecture support and the use of GNU tuple (x86_64-unknown-linux-gnu). That's why the bcc package dependency is limited to Glibc toolchain.

bcc needs tracing support, at least CONFIG_KPROBES, CONFIG_BPFILTER and CONFIG_BPF_JIT. See [1] for details.

bcc needs BPF target support in llvm libraries.
Add a patch disabling man pages.

Quoted 7 lines

[1] https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md

Cc Jugurtha BELKALEM <[email protected]>

---
The needs of kernel sources on the target is anoying for small devices. At least, I'm able to complete the bcc tutorial [1] on my x86_64 target.

Suggest updating LINUX_KCONFIG_FIXUP_CMDS to include enabling of the BPF features when this package is selected.

Quoted 108 lines

[1] https://github.com/iovisor/bcc/blob/master/docs/tutorial.md

---
 DEVELOPERS                                         |  1 +
 package/Config.in                                  |  1 +
 ...CMake-Allow-to-disable-building-man-pages.patch | 35 +++++++++++++++
 package/bcc/Config.in                              | 50 ++++++++++++++++++++++
 package/bcc/bcc.hash                               |  3 ++
 package/bcc/bcc.mk                                 | 23 ++++++++++
 6 files changed, 113 insertions(+)
 create mode 100644 package/bcc/0001-CMake-Allow-to-disable-building-man-pages.patch
 create mode 100644 package/bcc/Config.in
 create mode 100644 package/bcc/bcc.hash
 create mode 100644 package/bcc/bcc.mk
DEVELOPERS +1 -0
index 0d4c4f1d60..f5dc078c69 100644
@@ -1831,6 +1831,7 @@ F:        package/vnstat/
 
 N:     Romain Naour <[email protected]>
 F:     package/aubio/
+F:     package/bcc/
 F:     package/bullet/
 F:     package/darktable/
 F:     package/efl/
package/Config.in +1 -0
index 8d05303472..434427f455 100644
@@ -79,6 +79,7 @@ menu "Compressors and decompressors"
 endmenu
 
 menu "Debugging, profiling and benchmark"
+       source "package/bcc/Config.in"
        source "package/blktrace/Config.in"
        source "package/bonnie/Config.in"
        source "package/cache-calibrator/Config.in"
package/bcc/0001-CMake-Allow-to-disable-building-man-pages.patch new file +35 -0
new file mode 100644
index 0000000000..c5c87d52e9
@@ -0,0 +1,35 @@
+From a99f097aedbf964356e62c0c4bba1257f108c3eb Mon Sep 17 00:00:00 2001
+From: Romain Naour <[email protected]>
+Date: Fri, 7 Dec 2018 22:36:21 +0100
+Subject: [PATCH] CMake: Allow to disable building man pages
+
+Signed-off-by: Romain Naour <[email protected]>
+---
+ CMakeLists.txt | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index bb3f53b9..5e95d555 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -19,6 +19,7 @@ include(cmake/FindCompilerFlag.cmake)
+ 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_CPP_API "Enable C++ API" ON "ENABLE_USDT" OFF)
+
+ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
+@@ -88,7 +89,9 @@ add_subdirectory(src)
+ add_subdirectory(introspection)
+ if(ENABLE_CLANG_JIT)
+ add_subdirectory(examples)
++if(ENABLE_MAN)
+ add_subdirectory(man)
++endif(ENABLE_MAN)
+ add_subdirectory(tests)
+ add_subdirectory(tools)
+ endif(ENABLE_CLANG_JIT)
+--
+2.14.5
+
package/bcc/Config.in new file +22 -0
new file mode 100644
index 0000000000..7bc681e639
@@ -0,0 +1,50 @@
+config BR2_PACKAGE_BCC
+       bool "bcc"
+       depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+       depends on BR2_PACKAGE_LUAJIT_ARCH_SUPPORTS
+       depends on BR2_TOOLCHAIN_USES_GLIBC # hardcode GNU tuple (x86_64-unknown-linux-gnu)
+       depends on BR2_LINUX_KERNEL # needs kernel sources on the target
+       depends on BR2_HOST_GCC_AT_LEAST_4_8 # clang
+       depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8 # clang
+       depends on BR2_TOOLCHAIN_HAS_THREADS # clang
+       depends on BR2_INSTALL_LIBSTDCPP # clang
+       depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_64735 # clang
+       depends on !BR2_STATIC_LIBS # clang, luajit
+       depends on BR2_USE_WCHAR # clang
+       select BR2_PACKAGE_CLANG
+       select BR2_PACKAGE_ELFUTILS
+       select BR2_PACKAGE_FLEX # needs FlexLexer.h
+       select BR2_PACKAGE_LLVM_BPF
+       select BR2_PACKAGE_LUAJIT
+       help
+         BPF Compiler Collection (BCC)
+
+         BCC is a toolkit for creating efficient kernel tracing and

package/bcc/Config.in line 32

Quoted 10 lines
package/bcc/Config.in new file +10 -0
+         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 to copy the kernel source
+         code to the target. By default bcc use:
+         "/lib/module/<kernel version>/build". That's because the
+         clang frontend build eBPF code at runtime.

Very interesting patch and package. Thanks for sending it in. I know I've added it to my list to tinker with.

Matt

#4 lore raw

PATCH 2/2 package/bcc: new package

Hi Matt,

Le 14/01/2019 ? 21:43, Matthew Weber a ?crit?:

Quoted 23 lines

Romain,

Quoted 19 lines · Romain Naour

From: Romain Naour <[email protected]>

Before using bcc, you need to copy the kernel source code to "/lib/module/<kernel version>/build" on the target. That's because the clang frontend build eBPF code at runtime.

There are some issues with this frontend due to the hardcoded architecture support and the use of GNU tuple (x86_64-unknown-linux-gnu). That's why the bcc package dependency is limited to Glibc toolchain.

bcc needs tracing support, at least CONFIG_KPROBES, CONFIG_BPFILTER and CONFIG_BPF_JIT. See [1] for details.

bcc needs BPF target support in llvm libraries.
Add a patch disabling man pages.

[1] https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md

Quoted 8 lines
Quoted 5 lines
Cc Jugurtha BELKALEM <[email protected]>

---
The needs of kernel sources on the target is anoying for small devices. At least, I'm able to complete the bcc tutorial [1] on my x86_64 target.

Suggest updating LINUX_KCONFIG_FIXUP_CMDS to include enabling of the BPF features when this package is selected.

Indeed, I thought about it but I need to double check the kernel options that are mandatory.

Quoted 4 lines
Quoted 4 lines

[1] https://github.com/iovisor/bcc/blob/master/docs/tutorial.md
---

[...]

Quoted 9 lines
Quoted 9 lines
package/bcc/Config.in new file +9 -0
+       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.
Quoted 8 lines

package/bcc/Config.in line 32

Quoted 5 lines
package/bcc/Config.in new file +5 -0
+
+         Note: Before using bcc, you need to copy the kernel source
+         code to the target. By default bcc use:
+         "/lib/module/<kernel version>/build". That's because the
+         clang frontend build eBPF code at runtime.

Very interesting patch and package. Thanks for sending it in. I know I've added it to my list to tinker with.

You're welcome :)

My colleague Jugurtha was working on debugging tools like bcc during his internship. We are experimenting bcc in the context of Buildroot.

Also, it allow to have (yet) another use case for llvm/clang merged this year thanks to Valentin's work.

Best regards,
Romain

Quoted 3 lines

Matt

#5 lore raw

PATCH 2/2 package/bcc: new package

Hi Jugurtha,

Le 14/01/2019 ? 22:00, Romain Naour a ?crit?:

Quoted 63 lines

Hi Matt,

Le 14/01/2019 ? 21:43, Matthew Weber a ?crit?:

Quoted 23 lines

Romain,

Quoted 19 lines · Romain Naour

From: Romain Naour <[email protected]>

Before using bcc, you need to copy the kernel source code to "/lib/module/<kernel version>/build" on the target. That's because the clang frontend build eBPF code at runtime.

There are some issues with this frontend due to the hardcoded architecture support and the use of GNU tuple (x86_64-unknown-linux-gnu). That's why the bcc package dependency is limited to Glibc toolchain.

bcc needs tracing support, at least CONFIG_KPROBES, CONFIG_BPFILTER and CONFIG_BPF_JIT. See [1] for details.

bcc needs BPF target support in llvm libraries.
Add a patch disabling man pages.

[1] https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md

Quoted 8 lines
Quoted 5 lines
Cc Jugurtha BELKALEM <[email protected]>

---
The needs of kernel sources on the target is anoying for small devices. At least, I'm able to complete the bcc tutorial [1] on my x86_64 target.

Suggest updating LINUX_KCONFIG_FIXUP_CMDS to include enabling of the BPF features when this package is selected.

Indeed, I thought about it but I need to double check the kernel options that are mandatory.

Quoted 4 lines
Quoted 4 lines

[1] https://github.com/iovisor/bcc/blob/master/docs/tutorial.md
---

[...]

Quoted 9 lines
Quoted 9 lines
package/bcc/Config.in new file +9 -0
+       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.
Quoted 8 lines

package/bcc/Config.in line 32

Quoted 5 lines
package/bcc/Config.in new file +5 -0
+
+         Note: Before using bcc, you need to copy the kernel source
+         code to the target. By default bcc use:
+         "/lib/module/<kernel version>/build". That's because the
+         clang frontend build eBPF code at runtime.

Very interesting patch and package. Thanks for sending it in. I know I've added it to my list to tinker with.

Quoted 4 lines

You're welcome :)

My colleague Jugurtha was working on debugging tools like bcc during his internship. We are experimenting bcc in the context of Buildroot.

Jugurtha tried today to build an image including BCC for a rpi3 for aarch64 and ARM.

For now, we can't enable BCC for aarch64 due to the luajit dependency (luajit 2.0.5 doesn't support aarch64 yet).

He tried to build for ARM and get the following error:
https://lists.iovisor.org/g/iovisor-dev/message/1610

It seems that BCC's User-level Statically Defined Tracing (USDT) only support a limited number of architecture (aarch64, powerpc64 and x86_64).

Also, during the investigation we discover that luajit (from the host) is used to build bcc.o, even while cross-compiling.

/usr/bin/luajit -bg bcc.lua bcc.o [1]

Which produce x86_64 binary on x86_64 host.

$ file ./lua/bcc.o
./lua/bcc.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped

So we got an error while linking BCC.

In the end, BCC doesn't seem cross-compilation friendly :-/

BPFd seems an interesting alternative in the context of Buildroot [2].

Best regards,
Romain

[1] https://github.com/iovisor/bcc/blob/master/src/lua/CMakeLists.txt#L18
[2] https://lwn.net/Articles/744522/

Quoted 11 lines

Also, it allow to have (yet) another use case for llvm/clang merged this year thanks to Valentin's work.

Best regards,
Romain

Quoted 3 lines

Matt