diff mbox series

[meta-oe,2/2] fluentbit: add support for in-ebpf plugin

Message ID 20251104093017.474084-2-timotheus.giuliani@philips.com
State Under Review
Headers show
Series [meta-oe,1/2] fluentbit: set source directory to enable patch application | expand

Commit Message

Timotheus Giuliani Nov. 4, 2025, 9:30 a.m. UTC
Introduce support for the in-ebpf plugin in the Fluent Bit recipe,
which was added as an experimental feature in Fluent Bit version 4.0.
The new PACKAGECONFIG option enables building the eBPF input plugin
when explicitly configured, adding the necessary build dependencies
including bpftool-native, clang-native, and libbpf.
The recipe also configures the LIBC_PATH for compilation environments
to ensure to point to the correct target system's C library when the
eBPF plugin is enabled.

Signed-off-by: Timotheus Giuliani <timotheus.giuliani@philips.com>
---
 ...root-include-path-for-system-headers.patch | 31 ++++++++
 ...coded-target-architecture-definition.patch | 54 ++++++++++++++
 ...tting-LIBC_PATH-from-external-config.patch | 73 +++++++++++++++++++
 .../fluentbit/fluentbit_4.0.1.bb              |  7 ++
 4 files changed, 165 insertions(+)
 create mode 100644 meta-oe/recipes-extended/fluentbit/fluentbit/0006-cmake-add-recipe-sysroot-include-path-for-system-headers.patch
 create mode 100644 meta-oe/recipes-extended/fluentbit/fluentbit/0007-bpf-remove-hardcoded-target-architecture-definition.patch
 create mode 100644 meta-oe/recipes-extended/fluentbit/fluentbit/0008-cmake-allow-setting-LIBC_PATH-from-external-config.patch

Comments

Gyorgy Sarvari Nov. 4, 2025, 11:31 a.m. UTC | #1
Please make sure to add Upstream-Status tag to the patches, otherwise
they will fail a fatal QA check:
https://docs.yoctoproject.org/contributor-guide/recipe-style-guide.html#patch-upstream-status


On 11/4/25 10:30, Timotheus Giuliani via lists.openembedded.org wrote:
> Introduce support for the in-ebpf plugin in the Fluent Bit recipe,
> which was added as an experimental feature in Fluent Bit version 4.0.
> The new PACKAGECONFIG option enables building the eBPF input plugin
> when explicitly configured, adding the necessary build dependencies
> including bpftool-native, clang-native, and libbpf.
> The recipe also configures the LIBC_PATH for compilation environments
> to ensure to point to the correct target system's C library when the
> eBPF plugin is enabled.
>
> Signed-off-by: Timotheus Giuliani <timotheus.giuliani@philips.com>
> ---
>  ...root-include-path-for-system-headers.patch | 31 ++++++++
>  ...coded-target-architecture-definition.patch | 54 ++++++++++++++
>  ...tting-LIBC_PATH-from-external-config.patch | 73 +++++++++++++++++++
>  .../fluentbit/fluentbit_4.0.1.bb              |  7 ++
>  4 files changed, 165 insertions(+)
>  create mode 100644 meta-oe/recipes-extended/fluentbit/fluentbit/0006-cmake-add-recipe-sysroot-include-path-for-system-headers.patch
>  create mode 100644 meta-oe/recipes-extended/fluentbit/fluentbit/0007-bpf-remove-hardcoded-target-architecture-definition.patch
>  create mode 100644 meta-oe/recipes-extended/fluentbit/fluentbit/0008-cmake-allow-setting-LIBC_PATH-from-external-config.patch
>
> diff --git a/meta-oe/recipes-extended/fluentbit/fluentbit/0006-cmake-add-recipe-sysroot-include-path-for-system-headers.patch b/meta-oe/recipes-extended/fluentbit/fluentbit/0006-cmake-add-recipe-sysroot-include-path-for-system-headers.patch
> new file mode 100644
> index 0000000000..2b73f48334
> --- /dev/null
> +++ b/meta-oe/recipes-extended/fluentbit/fluentbit/0006-cmake-add-recipe-sysroot-include-path-for-system-headers.patch
> @@ -0,0 +1,31 @@
> +From 9f47cc69683a842efdf6c31ea25b7b423ba3fc7e Mon Sep 17 00:00:00 2001
> +From: Timotheus Giuliani <timotheus.giuliani@philips.com>
> +Date: Tue, 7 Oct 2025 17:33:14 +0200
> +Subject: [PATCH 1/3] cmake: add recipe sysroot include path for system headers
> +
> +The CMakeLists.txt was missing the recipe sysroot include path, which
> +prevented the build system from finding required system headers during
> +compilation. This commit adds the recipe sysroot directory to the
> +include path so that headers provided by the sysroot, such as
> +BPF headers and other system dependencies, can be properly located and
> +included during the build process.
> +Without this change, the build would fail to find essential headers
> +when building in compilation environment.
> +
> +Signed-off-by: Timotheus Giuliani <timotheus.giuliani@philips.com>
> +---
> + plugins/in_ebpf/CMakeLists.txt | 1 +
> + 1 file changed, 1 insertion(+)
> +
> +diff --git a/plugins/in_ebpf/CMakeLists.txt b/plugins/in_ebpf/CMakeLists.txt
> +index 476c07774..216b2ffce 100644
> +--- a/plugins/in_ebpf/CMakeLists.txt
> ++++ b/plugins/in_ebpf/CMakeLists.txt
> +@@ -91,6 +91,7 @@ foreach(TRACE_C_FILE ${TRACE_C_FILES})
> +             -I${CMAKE_SOURCE_DIR}/plugins/in_ebpf/traces/includes/external
> +             -I${CMAKE_SOURCE_DIR}/plugins/in_ebpf/traces/includes
> +             -I${VMLINUX_PATH}         # Include the correct vmlinux.h based on architecture
> ++            --sysroot=${CMAKE_SYSROOT}  # Add yocto recipe sysroot to find "system headers"
> +             -c ${TRACE_C_FILE}
> +             -o ${TRACE_OBJ_FILE}
> +     DEPENDS ${TRACE_C_FILE} ebpf-generated-directory
> diff --git a/meta-oe/recipes-extended/fluentbit/fluentbit/0007-bpf-remove-hardcoded-target-architecture-definition.patch b/meta-oe/recipes-extended/fluentbit/fluentbit/0007-bpf-remove-hardcoded-target-architecture-definition.patch
> new file mode 100644
> index 0000000000..f30005e986
> --- /dev/null
> +++ b/meta-oe/recipes-extended/fluentbit/fluentbit/0007-bpf-remove-hardcoded-target-architecture-definition.patch
> @@ -0,0 +1,54 @@
> +From df05870068f0d1fe092650bb1ba0a518fb540550 Mon Sep 17 00:00:00 2001
> +From: Timotheus Giuliani <timotheus.giuliani@philips.com>
> +Date: Tue, 7 Oct 2025 17:34:28 +0200
> +Subject: [PATCH 2/3] bpf: remove hardcoded target architecture definition
> +
> +The BPF programs was hardcoding the TARGET_ARCH_x86 definition, which
> +prevented successful builds on other architectures such as ARM64.
> +This commit removes the hardcoded architecture definition from the bpf
> +source files, allowing the CMake build system to properly set the
> +target architecture based on the actual build environment.
> +
> +Signed-off-by: Timotheus Giuliani <timotheus.giuliani@philips.com>
> +---
> + plugins/in_ebpf/traces/bind/bpf.c      | 2 --
> + plugins/in_ebpf/traces/malloc/bpf.c.in | 3 ---
> + plugins/in_ebpf/traces/signal/bpf.c    | 2 --
> + 3 files changed, 7 deletions(-)
> +
> +diff --git a/plugins/in_ebpf/traces/bind/bpf.c b/plugins/in_ebpf/traces/bind/bpf.c
> +index 1712bf67e..da9d7c3f1 100644
> +--- a/plugins/in_ebpf/traces/bind/bpf.c
> ++++ b/plugins/in_ebpf/traces/bind/bpf.c
> +@@ -2,8 +2,6 @@
> + /* Copyright (c) 2021 Hengqi Chen */
> + /* Copyright (c) 2024 The Inspektor Gadget authors */
> + 
> +-#define __TARGET_ARCH_x86
> +-
> + #include <vmlinux.h>
> + 
> + #define _LINUX_TYPES_H        // Prevent redefinition of linux/types.h
> +diff --git a/plugins/in_ebpf/traces/malloc/bpf.c.in b/plugins/in_ebpf/traces/malloc/bpf.c.in
> +index c37d3952a..ace4acdbe 100644
> +--- a/plugins/in_ebpf/traces/malloc/bpf.c.in
> ++++ b/plugins/in_ebpf/traces/malloc/bpf.c.in
> +@@ -1,6 +1,3 @@
> +-#define __TARGET_ARCH_x86
> +-
> +-
> + #include <vmlinux.h>
> + 
> + #define _LINUX_TYPES_H        // Prevent redefinition of linux/types.h
> +diff --git a/plugins/in_ebpf/traces/signal/bpf.c b/plugins/in_ebpf/traces/signal/bpf.c
> +index 7d4503c22..3f017b325 100644
> +--- a/plugins/in_ebpf/traces/signal/bpf.c
> ++++ b/plugins/in_ebpf/traces/signal/bpf.c
> +@@ -1,7 +1,5 @@
> + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
> + /* Copyright (c) 2021~2022 Hengqi Chen */
> +-#define __TARGET_ARCH_x86_64
> +-
> + #include <vmlinux.h>
> + 
> + #define _LINUX_TYPES_H        // Prevent redefinition of linux/types.h
> diff --git a/meta-oe/recipes-extended/fluentbit/fluentbit/0008-cmake-allow-setting-LIBC_PATH-from-external-config.patch b/meta-oe/recipes-extended/fluentbit/fluentbit/0008-cmake-allow-setting-LIBC_PATH-from-external-config.patch
> new file mode 100644
> index 0000000000..57f4d899cd
> --- /dev/null
> +++ b/meta-oe/recipes-extended/fluentbit/fluentbit/0008-cmake-allow-setting-LIBC_PATH-from-external-config.patch
> @@ -0,0 +1,73 @@
> +From ab01dffe9bf2f1208ec4cea0a1582196cfbc0f87 Mon Sep 17 00:00:00 2001
> +From: Timotheus Giuliani <timotheus.giuliani@philips.com>
> +Date: Wed, 8 Oct 2025 14:24:36 +0200
> +Subject: [PATCH 3/3] cmake: allow setting LIBC_PATH from external
> + configuration
> +
> +The CMakeLists.txt file was automatically detecting the libc library
> +path based on the system distribution. This change allows the LIBC_PATH
> +to be set externally through build configuration, which is useful for
> +compilation environments where the library path is known in advance.
> +The auto-detection logic is kept as a fallback when LIBC_PATH is not
> +provided from external configuration.
> +
> +Signed-off-by: Timotheus Giuliani <timotheus.giuliani@philips.com>
> +---
> + plugins/in_ebpf/CMakeLists.txt | 43 ++++++++++++++++++----------------
> + 1 file changed, 23 insertions(+), 20 deletions(-)
> +
> +diff --git a/plugins/in_ebpf/CMakeLists.txt b/plugins/in_ebpf/CMakeLists.txt
> +index 216b2ffce..1c5e55785 100644
> +--- a/plugins/in_ebpf/CMakeLists.txt
> ++++ b/plugins/in_ebpf/CMakeLists.txt
> +@@ -25,27 +25,30 @@ include_directories(
> + add_library(gadget INTERFACE)
> + target_include_directories(gadget INTERFACE ${CMAKE_SOURCE_DIR}/plugins/in_ebpf/traces/includes/external/gadget)
> + 
> +-set(LIBC_PATH "/lib64/libc.so.6")
> + 
> +-find_program(LSB_RELEASE_EXEC lsb_release)
> +-if (LSB_RELEASE_EXEC)
> +-  execute_process(COMMAND ${LSB_RELEASE_EXEC} -i
> +-      OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT
> +-      OUTPUT_STRIP_TRAILING_WHITESPACE
> +-  )
> +-
> +-  message(STATUS "##### lsb_release -i -- ${LSB_RELEASE_ID_SHORT}")
> +-
> +-  if (LSB_RELEASE_ID_SHORT MATCHES "Ubuntu" OR
> +-      LSB_RELEASE_ID_SHORT MATCHES "Debian" OR
> +-      LSB_RELEASE_ID_SHORT MATCHES "LinuxMint")
> +-    # Just added for the future enhancement
> +-    if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
> +-      set(LIBC_PATH "/usr/lib/aarch64-linux-gnu/libc.so.6")
> +-    elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
> +-      set(LIBC_PATH "/usr/lib/x86_64-linux-gnu/libc.so.6")
> +-    elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
> +-      set(LIBC_PATH "/usr/lib/i386-linux-gnu/libc.so.6")
> ++if(NOT DEFINED LIBC_PATH OR LIBC_PATH STREQUAL "")
> ++  set(LIBC_PATH "/lib64/libc.so.6")
> ++
> ++  find_program(LSB_RELEASE_EXEC lsb_release)
> ++  if (LSB_RELEASE_EXEC)
> ++    execute_process(COMMAND ${LSB_RELEASE_EXEC} -i
> ++        OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT
> ++        OUTPUT_STRIP_TRAILING_WHITESPACE
> ++    )
> ++
> ++    message(STATUS "##### lsb_release -i -- ${LSB_RELEASE_ID_SHORT}")
> ++
> ++    if (LSB_RELEASE_ID_SHORT MATCHES "Ubuntu" OR
> ++        LSB_RELEASE_ID_SHORT MATCHES "Debian" OR
> ++        LSB_RELEASE_ID_SHORT MATCHES "LinuxMint")
> ++      # Just added for the future enhancement
> ++      if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
> ++        set(LIBC_PATH "/usr/lib/aarch64-linux-gnu/libc.so.6")
> ++      elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
> ++        set(LIBC_PATH "/usr/lib/x86_64-linux-gnu/libc.so.6")
> ++      elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
> ++        set(LIBC_PATH "/usr/lib/i386-linux-gnu/libc.so.6")
> ++      endif()
> +     endif()
> +   endif()
> + endif()
> diff --git a/meta-oe/recipes-extended/fluentbit/fluentbit_4.0.1.bb b/meta-oe/recipes-extended/fluentbit/fluentbit_4.0.1.bb
> index 4d82abc783..05dcd2cca7 100644
> --- a/meta-oe/recipes-extended/fluentbit/fluentbit_4.0.1.bb
> +++ b/meta-oe/recipes-extended/fluentbit/fluentbit_4.0.1.bb
> @@ -23,6 +23,9 @@ SRC_URI = "\
>      file://0001-lib-Do-not-use-private-makefile-targets-in-CMakelist.patch \
>      file://0002-flb_info.h.in-Do-not-hardcode-compilation-directorie.patch \
>      file://0003-CMakeLists.txt-Revise-init-manager-deduction.patch \
> +    file://0006-cmake-add-recipe-sysroot-include-path-for-system-headers.patch \
> +    file://0007-bpf-remove-hardcoded-target-architecture-definition.patch \
> +    file://0008-cmake-allow-setting-LIBC_PATH-from-external-config.patch \
>  "
>  SRC_URI:append:libc-musl = "\
>      file://0004-chunkio-Link-with-fts-library-with-musl.patch \
> @@ -112,6 +115,10 @@ PACKAGECONFIG[minimal] = "-DFLB_MINIMAL=Yes,-DFLB_MINIMAL=No"
>  PACKAGECONFIG[in-kafka] = "-DFLB_KAFKA=ON -DFLB_IN_KAFKA=ON,-DFLB_KAFKA=OFF -DFLB_IN_KAFKA=OFF,librdkafka curl"
>  PACKAGECONFIG[out-kafka] = "-DFLB_KAFKA=ON -DFLB_OUT_KAFKA=ON,-DFLB_KAFKA=OFF -DFLB_OUT_KAFKA=OFF,librdkafka curl"
>  
> +# Add ebpf input
> +PACKAGECONFIG[in-ebpf] = "-DFLB_IN_EBPF=Yes,-DFLB_IN_EBPF=No, bpftool-native clang-native libbpf"
> +EXTRA_OECMAKE:append = " ${@bb.utils.contains('PACKAGECONFIG', 'in-ebpf', '-DLIBC_PATH=${libdir}/libc.so.6', '', d)}"
> +
>  SYSTEMD_SERVICE:${PN} = "fluent-bit.service"
>  
>  inherit cmake systemd pkgconfig
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#121292): https://lists.openembedded.org/g/openembedded-devel/message/121292
> Mute This Topic: https://lists.openembedded.org/mt/116115058/6084445
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [skandigraun@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Khem Raj Nov. 4, 2025, 4 p.m. UTC | #2
On Tue, Nov 4, 2025 at 3:32 AM Gyorgy Sarvari via
lists.openembedded.org <skandigraun=gmail.com@lists.openembedded.org>
wrote:
>
> Please make sure to add Upstream-Status tag to the patches, otherwise
> they will fail a fatal QA check:
> https://docs.yoctoproject.org/contributor-guide/recipe-style-guide.html#patch-upstream-status
>
>
> On 11/4/25 10:30, Timotheus Giuliani via lists.openembedded.org wrote:
> > Introduce support for the in-ebpf plugin in the Fluent Bit recipe,
> > which was added as an experimental feature in Fluent Bit version 4.0.
> > The new PACKAGECONFIG option enables building the eBPF input plugin
> > when explicitly configured, adding the necessary build dependencies
> > including bpftool-native, clang-native, and libbpf.
> > The recipe also configures the LIBC_PATH for compilation environments
> > to ensure to point to the correct target system's C library when the
> > eBPF plugin is enabled.
> >
> > Signed-off-by: Timotheus Giuliani <timotheus.giuliani@philips.com>
> > ---
> >  ...root-include-path-for-system-headers.patch | 31 ++++++++
> >  ...coded-target-architecture-definition.patch | 54 ++++++++++++++
> >  ...tting-LIBC_PATH-from-external-config.patch | 73 +++++++++++++++++++
> >  .../fluentbit/fluentbit_4.0.1.bb              |  7 ++
> >  4 files changed, 165 insertions(+)
> >  create mode 100644 meta-oe/recipes-extended/fluentbit/fluentbit/0006-cmake-add-recipe-sysroot-include-path-for-system-headers.patch
> >  create mode 100644 meta-oe/recipes-extended/fluentbit/fluentbit/0007-bpf-remove-hardcoded-target-architecture-definition.patch
> >  create mode 100644 meta-oe/recipes-extended/fluentbit/fluentbit/0008-cmake-allow-setting-LIBC_PATH-from-external-config.patch
> >
> > diff --git a/meta-oe/recipes-extended/fluentbit/fluentbit/0006-cmake-add-recipe-sysroot-include-path-for-system-headers.patch b/meta-oe/recipes-extended/fluentbit/fluentbit/0006-cmake-add-recipe-sysroot-include-path-for-system-headers.patch
> > new file mode 100644
> > index 0000000000..2b73f48334
> > --- /dev/null
> > +++ b/meta-oe/recipes-extended/fluentbit/fluentbit/0006-cmake-add-recipe-sysroot-include-path-for-system-headers.patch
> > @@ -0,0 +1,31 @@
> > +From 9f47cc69683a842efdf6c31ea25b7b423ba3fc7e Mon Sep 17 00:00:00 2001
> > +From: Timotheus Giuliani <timotheus.giuliani@philips.com>
> > +Date: Tue, 7 Oct 2025 17:33:14 +0200
> > +Subject: [PATCH 1/3] cmake: add recipe sysroot include path for system headers
> > +
> > +The CMakeLists.txt was missing the recipe sysroot include path, which
> > +prevented the build system from finding required system headers during
> > +compilation. This commit adds the recipe sysroot directory to the
> > +include path so that headers provided by the sysroot, such as
> > +BPF headers and other system dependencies, can be properly located and
> > +included during the build process.
> > +Without this change, the build would fail to find essential headers
> > +when building in compilation environment.
> > +
> > +Signed-off-by: Timotheus Giuliani <timotheus.giuliani@philips.com>
> > +---
> > + plugins/in_ebpf/CMakeLists.txt | 1 +
> > + 1 file changed, 1 insertion(+)
> > +
> > +diff --git a/plugins/in_ebpf/CMakeLists.txt b/plugins/in_ebpf/CMakeLists.txt
> > +index 476c07774..216b2ffce 100644
> > +--- a/plugins/in_ebpf/CMakeLists.txt
> > ++++ b/plugins/in_ebpf/CMakeLists.txt
> > +@@ -91,6 +91,7 @@ foreach(TRACE_C_FILE ${TRACE_C_FILES})
> > +             -I${CMAKE_SOURCE_DIR}/plugins/in_ebpf/traces/includes/external
> > +             -I${CMAKE_SOURCE_DIR}/plugins/in_ebpf/traces/includes
> > +             -I${VMLINUX_PATH}         # Include the correct vmlinux.h based on architecture
> > ++            --sysroot=${CMAKE_SYSROOT}  # Add yocto recipe sysroot to find "system headers"
> > +             -c ${TRACE_C_FILE}
> > +             -o ${TRACE_OBJ_FILE}
> > +     DEPENDS ${TRACE_C_FILE} ebpf-generated-directory
> > diff --git a/meta-oe/recipes-extended/fluentbit/fluentbit/0007-bpf-remove-hardcoded-target-architecture-definition.patch b/meta-oe/recipes-extended/fluentbit/fluentbit/0007-bpf-remove-hardcoded-target-architecture-definition.patch
> > new file mode 100644
> > index 0000000000..f30005e986
> > --- /dev/null
> > +++ b/meta-oe/recipes-extended/fluentbit/fluentbit/0007-bpf-remove-hardcoded-target-architecture-definition.patch
> > @@ -0,0 +1,54 @@
> > +From df05870068f0d1fe092650bb1ba0a518fb540550 Mon Sep 17 00:00:00 2001
> > +From: Timotheus Giuliani <timotheus.giuliani@philips.com>
> > +Date: Tue, 7 Oct 2025 17:34:28 +0200
> > +Subject: [PATCH 2/3] bpf: remove hardcoded target architecture definition
> > +
> > +The BPF programs was hardcoding the TARGET_ARCH_x86 definition, which
> > +prevented successful builds on other architectures such as ARM64.
> > +This commit removes the hardcoded architecture definition from the bpf
> > +source files, allowing the CMake build system to properly set the
> > +target architecture based on the actual build environment.
> > +
> > +Signed-off-by: Timotheus Giuliani <timotheus.giuliani@philips.com>
> > +---
> > + plugins/in_ebpf/traces/bind/bpf.c      | 2 --
> > + plugins/in_ebpf/traces/malloc/bpf.c.in | 3 ---
> > + plugins/in_ebpf/traces/signal/bpf.c    | 2 --
> > + 3 files changed, 7 deletions(-)
> > +
> > +diff --git a/plugins/in_ebpf/traces/bind/bpf.c b/plugins/in_ebpf/traces/bind/bpf.c
> > +index 1712bf67e..da9d7c3f1 100644
> > +--- a/plugins/in_ebpf/traces/bind/bpf.c
> > ++++ b/plugins/in_ebpf/traces/bind/bpf.c
> > +@@ -2,8 +2,6 @@
> > + /* Copyright (c) 2021 Hengqi Chen */
> > + /* Copyright (c) 2024 The Inspektor Gadget authors */
> > +
> > +-#define __TARGET_ARCH_x86
> > +-
> > + #include <vmlinux.h>
> > +
> > + #define _LINUX_TYPES_H        // Prevent redefinition of linux/types.h
> > +diff --git a/plugins/in_ebpf/traces/malloc/bpf.c.in b/plugins/in_ebpf/traces/malloc/bpf.c.in
> > +index c37d3952a..ace4acdbe 100644
> > +--- a/plugins/in_ebpf/traces/malloc/bpf.c.in
> > ++++ b/plugins/in_ebpf/traces/malloc/bpf.c.in
> > +@@ -1,6 +1,3 @@
> > +-#define __TARGET_ARCH_x86
> > +-
> > +-
> > + #include <vmlinux.h>
> > +
> > + #define _LINUX_TYPES_H        // Prevent redefinition of linux/types.h
> > +diff --git a/plugins/in_ebpf/traces/signal/bpf.c b/plugins/in_ebpf/traces/signal/bpf.c
> > +index 7d4503c22..3f017b325 100644
> > +--- a/plugins/in_ebpf/traces/signal/bpf.c
> > ++++ b/plugins/in_ebpf/traces/signal/bpf.c
> > +@@ -1,7 +1,5 @@
> > + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
> > + /* Copyright (c) 2021~2022 Hengqi Chen */
> > +-#define __TARGET_ARCH_x86_64
> > +-
> > + #include <vmlinux.h>
> > +
> > + #define _LINUX_TYPES_H        // Prevent redefinition of linux/types.h
> > diff --git a/meta-oe/recipes-extended/fluentbit/fluentbit/0008-cmake-allow-setting-LIBC_PATH-from-external-config.patch b/meta-oe/recipes-extended/fluentbit/fluentbit/0008-cmake-allow-setting-LIBC_PATH-from-external-config.patch
> > new file mode 100644
> > index 0000000000..57f4d899cd
> > --- /dev/null
> > +++ b/meta-oe/recipes-extended/fluentbit/fluentbit/0008-cmake-allow-setting-LIBC_PATH-from-external-config.patch
> > @@ -0,0 +1,73 @@
> > +From ab01dffe9bf2f1208ec4cea0a1582196cfbc0f87 Mon Sep 17 00:00:00 2001
> > +From: Timotheus Giuliani <timotheus.giuliani@philips.com>
> > +Date: Wed, 8 Oct 2025 14:24:36 +0200
> > +Subject: [PATCH 3/3] cmake: allow setting LIBC_PATH from external
> > + configuration
> > +
> > +The CMakeLists.txt file was automatically detecting the libc library
> > +path based on the system distribution. This change allows the LIBC_PATH
> > +to be set externally through build configuration, which is useful for
> > +compilation environments where the library path is known in advance.
> > +The auto-detection logic is kept as a fallback when LIBC_PATH is not
> > +provided from external configuration.
> > +
> > +Signed-off-by: Timotheus Giuliani <timotheus.giuliani@philips.com>
> > +---
> > + plugins/in_ebpf/CMakeLists.txt | 43 ++++++++++++++++++----------------
> > + 1 file changed, 23 insertions(+), 20 deletions(-)
> > +
> > +diff --git a/plugins/in_ebpf/CMakeLists.txt b/plugins/in_ebpf/CMakeLists.txt
> > +index 216b2ffce..1c5e55785 100644
> > +--- a/plugins/in_ebpf/CMakeLists.txt
> > ++++ b/plugins/in_ebpf/CMakeLists.txt
> > +@@ -25,27 +25,30 @@ include_directories(
> > + add_library(gadget INTERFACE)
> > + target_include_directories(gadget INTERFACE ${CMAKE_SOURCE_DIR}/plugins/in_ebpf/traces/includes/external/gadget)
> > +
> > +-set(LIBC_PATH "/lib64/libc.so.6")
> > +
> > +-find_program(LSB_RELEASE_EXEC lsb_release)
> > +-if (LSB_RELEASE_EXEC)
> > +-  execute_process(COMMAND ${LSB_RELEASE_EXEC} -i
> > +-      OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT
> > +-      OUTPUT_STRIP_TRAILING_WHITESPACE
> > +-  )
> > +-
> > +-  message(STATUS "##### lsb_release -i -- ${LSB_RELEASE_ID_SHORT}")
> > +-
> > +-  if (LSB_RELEASE_ID_SHORT MATCHES "Ubuntu" OR
> > +-      LSB_RELEASE_ID_SHORT MATCHES "Debian" OR
> > +-      LSB_RELEASE_ID_SHORT MATCHES "LinuxMint")
> > +-    # Just added for the future enhancement
> > +-    if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
> > +-      set(LIBC_PATH "/usr/lib/aarch64-linux-gnu/libc.so.6")
> > +-    elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
> > +-      set(LIBC_PATH "/usr/lib/x86_64-linux-gnu/libc.so.6")
> > +-    elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
> > +-      set(LIBC_PATH "/usr/lib/i386-linux-gnu/libc.so.6")
> > ++if(NOT DEFINED LIBC_PATH OR LIBC_PATH STREQUAL "")
> > ++  set(LIBC_PATH "/lib64/libc.so.6")
> > ++
> > ++  find_program(LSB_RELEASE_EXEC lsb_release)
> > ++  if (LSB_RELEASE_EXEC)
> > ++    execute_process(COMMAND ${LSB_RELEASE_EXEC} -i
> > ++        OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT
> > ++        OUTPUT_STRIP_TRAILING_WHITESPACE
> > ++    )
> > ++
> > ++    message(STATUS "##### lsb_release -i -- ${LSB_RELEASE_ID_SHORT}")
> > ++
> > ++    if (LSB_RELEASE_ID_SHORT MATCHES "Ubuntu" OR
> > ++        LSB_RELEASE_ID_SHORT MATCHES "Debian" OR
> > ++        LSB_RELEASE_ID_SHORT MATCHES "LinuxMint")
> > ++      # Just added for the future enhancement
> > ++      if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
> > ++        set(LIBC_PATH "/usr/lib/aarch64-linux-gnu/libc.so.6")
> > ++      elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
> > ++        set(LIBC_PATH "/usr/lib/x86_64-linux-gnu/libc.so.6")
> > ++      elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
> > ++        set(LIBC_PATH "/usr/lib/i386-linux-gnu/libc.so.6")
> > ++      endif()
> > +     endif()
> > +   endif()
> > + endif()
> > diff --git a/meta-oe/recipes-extended/fluentbit/fluentbit_4.0.1.bb b/meta-oe/recipes-extended/fluentbit/fluentbit_4.0.1.bb
> > index 4d82abc783..05dcd2cca7 100644
> > --- a/meta-oe/recipes-extended/fluentbit/fluentbit_4.0.1.bb
> > +++ b/meta-oe/recipes-extended/fluentbit/fluentbit_4.0.1.bb
> > @@ -23,6 +23,9 @@ SRC_URI = "\
> >      file://0001-lib-Do-not-use-private-makefile-targets-in-CMakelist.patch \
> >      file://0002-flb_info.h.in-Do-not-hardcode-compilation-directorie.patch \
> >      file://0003-CMakeLists.txt-Revise-init-manager-deduction.patch \
> > +    file://0006-cmake-add-recipe-sysroot-include-path-for-system-headers.patch \
> > +    file://0007-bpf-remove-hardcoded-target-architecture-definition.patch \
> > +    file://0008-cmake-allow-setting-LIBC_PATH-from-external-config.patch \
> >  "
> >  SRC_URI:append:libc-musl = "\
> >      file://0004-chunkio-Link-with-fts-library-with-musl.patch \
> > @@ -112,6 +115,10 @@ PACKAGECONFIG[minimal] = "-DFLB_MINIMAL=Yes,-DFLB_MINIMAL=No"
> >  PACKAGECONFIG[in-kafka] = "-DFLB_KAFKA=ON -DFLB_IN_KAFKA=ON,-DFLB_KAFKA=OFF -DFLB_IN_KAFKA=OFF,librdkafka curl"
> >  PACKAGECONFIG[out-kafka] = "-DFLB_KAFKA=ON -DFLB_OUT_KAFKA=ON,-DFLB_KAFKA=OFF -DFLB_OUT_KAFKA=OFF,librdkafka curl"
> >
> > +# Add ebpf input
> > +PACKAGECONFIG[in-ebpf] = "-DFLB_IN_EBPF=Yes,-DFLB_IN_EBPF=No, bpftool-native clang-native libbpf"
> > +EXTRA_OECMAKE:append = " ${@bb.utils.contains('PACKAGECONFIG', 'in-ebpf', '-DLIBC_PATH=${libdir}/libc.so.6', '', d)}"

libc.so.6 is glibc, what happens on musl ? maybe it should depend on
gcompat package but it will need some testing.
secondly, can it use += instead of append?

> > +
> >  SYSTEMD_SERVICE:${PN} = "fluent-bit.service"
> >
> >  inherit cmake systemd pkgconfig
> >
> >
> >
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#121296): https://lists.openembedded.org/g/openembedded-devel/message/121296
> Mute This Topic: https://lists.openembedded.org/mt/116115058/1997914
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Khem Raj Nov. 4, 2025, 4:08 p.m. UTC | #3
On Tue, Nov 4, 2025 at 3:24 AM Timotheus Giuliani via
lists.openembedded.org
<timotheus.giuliani=philips.com@lists.openembedded.org> wrote:
>
> Introduce support for the in-ebpf plugin in the Fluent Bit recipe,
> which was added as an experimental feature in Fluent Bit version 4.0.
> The new PACKAGECONFIG option enables building the eBPF input plugin
> when explicitly configured, adding the necessary build dependencies
> including bpftool-native, clang-native, and libbpf.
> The recipe also configures the LIBC_PATH for compilation environments
> to ensure to point to the correct target system's C library when the
> eBPF plugin is enabled.
>
> Signed-off-by: Timotheus Giuliani <timotheus.giuliani@philips.com>
> ---
>  ...root-include-path-for-system-headers.patch | 31 ++++++++
>  ...coded-target-architecture-definition.patch | 54 ++++++++++++++
>  ...tting-LIBC_PATH-from-external-config.patch | 73 +++++++++++++++++++
>  .../fluentbit/fluentbit_4.0.1.bb              |  7 ++
>  4 files changed, 165 insertions(+)
>  create mode 100644 meta-oe/recipes-extended/fluentbit/fluentbit/0006-cmake-add-recipe-sysroot-include-path-for-system-headers.patch
>  create mode 100644 meta-oe/recipes-extended/fluentbit/fluentbit/0007-bpf-remove-hardcoded-target-architecture-definition.patch
>  create mode 100644 meta-oe/recipes-extended/fluentbit/fluentbit/0008-cmake-allow-setting-LIBC_PATH-from-external-config.patch
>
> diff --git a/meta-oe/recipes-extended/fluentbit/fluentbit/0006-cmake-add-recipe-sysroot-include-path-for-system-headers.patch b/meta-oe/recipes-extended/fluentbit/fluentbit/0006-cmake-add-recipe-sysroot-include-path-for-system-headers.patch
> new file mode 100644
> index 0000000000..2b73f48334
> --- /dev/null
> +++ b/meta-oe/recipes-extended/fluentbit/fluentbit/0006-cmake-add-recipe-sysroot-include-path-for-system-headers.patch
> @@ -0,0 +1,31 @@
> +From 9f47cc69683a842efdf6c31ea25b7b423ba3fc7e Mon Sep 17 00:00:00 2001
> +From: Timotheus Giuliani <timotheus.giuliani@philips.com>
> +Date: Tue, 7 Oct 2025 17:33:14 +0200
> +Subject: [PATCH 1/3] cmake: add recipe sysroot include path for system headers
> +
> +The CMakeLists.txt was missing the recipe sysroot include path, which
> +prevented the build system from finding required system headers during
> +compilation. This commit adds the recipe sysroot directory to the
> +include path so that headers provided by the sysroot, such as
> +BPF headers and other system dependencies, can be properly located and
> +included during the build process.
> +Without this change, the build would fail to find essential headers
> +when building in compilation environment.
> +
> +Signed-off-by: Timotheus Giuliani <timotheus.giuliani@philips.com>

These patches should have Upstream-Status: tag and it will be good to
also submit them to upstream
fluentbit as well.

> +---
> + plugins/in_ebpf/CMakeLists.txt | 1 +
> + 1 file changed, 1 insertion(+)
> +
> +diff --git a/plugins/in_ebpf/CMakeLists.txt b/plugins/in_ebpf/CMakeLists.txt
> +index 476c07774..216b2ffce 100644
> +--- a/plugins/in_ebpf/CMakeLists.txt
> ++++ b/plugins/in_ebpf/CMakeLists.txt
> +@@ -91,6 +91,7 @@ foreach(TRACE_C_FILE ${TRACE_C_FILES})
> +             -I${CMAKE_SOURCE_DIR}/plugins/in_ebpf/traces/includes/external
> +             -I${CMAKE_SOURCE_DIR}/plugins/in_ebpf/traces/includes
> +             -I${VMLINUX_PATH}         # Include the correct vmlinux.h based on architecture
> ++            --sysroot=${CMAKE_SYSROOT}  # Add yocto recipe sysroot to find "system headers"
> +             -c ${TRACE_C_FILE}
> +             -o ${TRACE_OBJ_FILE}
> +     DEPENDS ${TRACE_C_FILE} ebpf-generated-directory
> diff --git a/meta-oe/recipes-extended/fluentbit/fluentbit/0007-bpf-remove-hardcoded-target-architecture-definition.patch b/meta-oe/recipes-extended/fluentbit/fluentbit/0007-bpf-remove-hardcoded-target-architecture-definition.patch
> new file mode 100644
> index 0000000000..f30005e986
> --- /dev/null
> +++ b/meta-oe/recipes-extended/fluentbit/fluentbit/0007-bpf-remove-hardcoded-target-architecture-definition.patch
> @@ -0,0 +1,54 @@
> +From df05870068f0d1fe092650bb1ba0a518fb540550 Mon Sep 17 00:00:00 2001
> +From: Timotheus Giuliani <timotheus.giuliani@philips.com>
> +Date: Tue, 7 Oct 2025 17:34:28 +0200
> +Subject: [PATCH 2/3] bpf: remove hardcoded target architecture definition
> +
> +The BPF programs was hardcoding the TARGET_ARCH_x86 definition, which
> +prevented successful builds on other architectures such as ARM64.
> +This commit removes the hardcoded architecture definition from the bpf
> +source files, allowing the CMake build system to properly set the
> +target architecture based on the actual build environment.
> +
> +Signed-off-by: Timotheus Giuliani <timotheus.giuliani@philips.com>
> +---
> + plugins/in_ebpf/traces/bind/bpf.c      | 2 --
> + plugins/in_ebpf/traces/malloc/bpf.c.in | 3 ---
> + plugins/in_ebpf/traces/signal/bpf.c    | 2 --
> + 3 files changed, 7 deletions(-)
> +
> +diff --git a/plugins/in_ebpf/traces/bind/bpf.c b/plugins/in_ebpf/traces/bind/bpf.c
> +index 1712bf67e..da9d7c3f1 100644
> +--- a/plugins/in_ebpf/traces/bind/bpf.c
> ++++ b/plugins/in_ebpf/traces/bind/bpf.c
> +@@ -2,8 +2,6 @@
> + /* Copyright (c) 2021 Hengqi Chen */
> + /* Copyright (c) 2024 The Inspektor Gadget authors */
> +
> +-#define __TARGET_ARCH_x86
> +-
> + #include <vmlinux.h>
> +
> + #define _LINUX_TYPES_H        // Prevent redefinition of linux/types.h
> +diff --git a/plugins/in_ebpf/traces/malloc/bpf.c.in b/plugins/in_ebpf/traces/malloc/bpf.c.in
> +index c37d3952a..ace4acdbe 100644
> +--- a/plugins/in_ebpf/traces/malloc/bpf.c.in
> ++++ b/plugins/in_ebpf/traces/malloc/bpf.c.in
> +@@ -1,6 +1,3 @@
> +-#define __TARGET_ARCH_x86
> +-
> +-
> + #include <vmlinux.h>
> +
> + #define _LINUX_TYPES_H        // Prevent redefinition of linux/types.h
> +diff --git a/plugins/in_ebpf/traces/signal/bpf.c b/plugins/in_ebpf/traces/signal/bpf.c
> +index 7d4503c22..3f017b325 100644
> +--- a/plugins/in_ebpf/traces/signal/bpf.c
> ++++ b/plugins/in_ebpf/traces/signal/bpf.c
> +@@ -1,7 +1,5 @@
> + // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
> + /* Copyright (c) 2021~2022 Hengqi Chen */
> +-#define __TARGET_ARCH_x86_64
> +-
> + #include <vmlinux.h>
> +
> + #define _LINUX_TYPES_H        // Prevent redefinition of linux/types.h
> diff --git a/meta-oe/recipes-extended/fluentbit/fluentbit/0008-cmake-allow-setting-LIBC_PATH-from-external-config.patch b/meta-oe/recipes-extended/fluentbit/fluentbit/0008-cmake-allow-setting-LIBC_PATH-from-external-config.patch
> new file mode 100644
> index 0000000000..57f4d899cd
> --- /dev/null
> +++ b/meta-oe/recipes-extended/fluentbit/fluentbit/0008-cmake-allow-setting-LIBC_PATH-from-external-config.patch
> @@ -0,0 +1,73 @@
> +From ab01dffe9bf2f1208ec4cea0a1582196cfbc0f87 Mon Sep 17 00:00:00 2001
> +From: Timotheus Giuliani <timotheus.giuliani@philips.com>
> +Date: Wed, 8 Oct 2025 14:24:36 +0200
> +Subject: [PATCH 3/3] cmake: allow setting LIBC_PATH from external
> + configuration
> +
> +The CMakeLists.txt file was automatically detecting the libc library
> +path based on the system distribution. This change allows the LIBC_PATH
> +to be set externally through build configuration, which is useful for
> +compilation environments where the library path is known in advance.
> +The auto-detection logic is kept as a fallback when LIBC_PATH is not
> +provided from external configuration.
> +
> +Signed-off-by: Timotheus Giuliani <timotheus.giuliani@philips.com>
> +---
> + plugins/in_ebpf/CMakeLists.txt | 43 ++++++++++++++++++----------------
> + 1 file changed, 23 insertions(+), 20 deletions(-)
> +
> +diff --git a/plugins/in_ebpf/CMakeLists.txt b/plugins/in_ebpf/CMakeLists.txt
> +index 216b2ffce..1c5e55785 100644
> +--- a/plugins/in_ebpf/CMakeLists.txt
> ++++ b/plugins/in_ebpf/CMakeLists.txt
> +@@ -25,27 +25,30 @@ include_directories(
> + add_library(gadget INTERFACE)
> + target_include_directories(gadget INTERFACE ${CMAKE_SOURCE_DIR}/plugins/in_ebpf/traces/includes/external/gadget)
> +
> +-set(LIBC_PATH "/lib64/libc.so.6")
> +
> +-find_program(LSB_RELEASE_EXEC lsb_release)
> +-if (LSB_RELEASE_EXEC)
> +-  execute_process(COMMAND ${LSB_RELEASE_EXEC} -i
> +-      OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT
> +-      OUTPUT_STRIP_TRAILING_WHITESPACE
> +-  )
> +-
> +-  message(STATUS "##### lsb_release -i -- ${LSB_RELEASE_ID_SHORT}")
> +-
> +-  if (LSB_RELEASE_ID_SHORT MATCHES "Ubuntu" OR
> +-      LSB_RELEASE_ID_SHORT MATCHES "Debian" OR
> +-      LSB_RELEASE_ID_SHORT MATCHES "LinuxMint")
> +-    # Just added for the future enhancement
> +-    if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
> +-      set(LIBC_PATH "/usr/lib/aarch64-linux-gnu/libc.so.6")
> +-    elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
> +-      set(LIBC_PATH "/usr/lib/x86_64-linux-gnu/libc.so.6")
> +-    elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
> +-      set(LIBC_PATH "/usr/lib/i386-linux-gnu/libc.so.6")
> ++if(NOT DEFINED LIBC_PATH OR LIBC_PATH STREQUAL "")
> ++  set(LIBC_PATH "/lib64/libc.so.6")
> ++
> ++  find_program(LSB_RELEASE_EXEC lsb_release)
> ++  if (LSB_RELEASE_EXEC)
> ++    execute_process(COMMAND ${LSB_RELEASE_EXEC} -i
> ++        OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT
> ++        OUTPUT_STRIP_TRAILING_WHITESPACE
> ++    )
> ++
> ++    message(STATUS "##### lsb_release -i -- ${LSB_RELEASE_ID_SHORT}")
> ++
> ++    if (LSB_RELEASE_ID_SHORT MATCHES "Ubuntu" OR
> ++        LSB_RELEASE_ID_SHORT MATCHES "Debian" OR
> ++        LSB_RELEASE_ID_SHORT MATCHES "LinuxMint")
> ++      # Just added for the future enhancement
> ++      if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
> ++        set(LIBC_PATH "/usr/lib/aarch64-linux-gnu/libc.so.6")
> ++      elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
> ++        set(LIBC_PATH "/usr/lib/x86_64-linux-gnu/libc.so.6")
> ++      elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
> ++        set(LIBC_PATH "/usr/lib/i386-linux-gnu/libc.so.6")
> ++      endif()
> +     endif()
> +   endif()
> + endif()
> diff --git a/meta-oe/recipes-extended/fluentbit/fluentbit_4.0.1.bb b/meta-oe/recipes-extended/fluentbit/fluentbit_4.0.1.bb
> index 4d82abc783..05dcd2cca7 100644
> --- a/meta-oe/recipes-extended/fluentbit/fluentbit_4.0.1.bb
> +++ b/meta-oe/recipes-extended/fluentbit/fluentbit_4.0.1.bb
> @@ -23,6 +23,9 @@ SRC_URI = "\
>      file://0001-lib-Do-not-use-private-makefile-targets-in-CMakelist.patch \
>      file://0002-flb_info.h.in-Do-not-hardcode-compilation-directorie.patch \
>      file://0003-CMakeLists.txt-Revise-init-manager-deduction.patch \
> +    file://0006-cmake-add-recipe-sysroot-include-path-for-system-headers.patch \
> +    file://0007-bpf-remove-hardcoded-target-architecture-definition.patch \
> +    file://0008-cmake-allow-setting-LIBC_PATH-from-external-config.patch \
>  "
>  SRC_URI:append:libc-musl = "\
>      file://0004-chunkio-Link-with-fts-library-with-musl.patch \
> @@ -112,6 +115,10 @@ PACKAGECONFIG[minimal] = "-DFLB_MINIMAL=Yes,-DFLB_MINIMAL=No"
>  PACKAGECONFIG[in-kafka] = "-DFLB_KAFKA=ON -DFLB_IN_KAFKA=ON,-DFLB_KAFKA=OFF -DFLB_IN_KAFKA=OFF,librdkafka curl"
>  PACKAGECONFIG[out-kafka] = "-DFLB_KAFKA=ON -DFLB_OUT_KAFKA=ON,-DFLB_KAFKA=OFF -DFLB_OUT_KAFKA=OFF,librdkafka curl"
>
> +# Add ebpf input
> +PACKAGECONFIG[in-ebpf] = "-DFLB_IN_EBPF=Yes,-DFLB_IN_EBPF=No, bpftool-native clang-native libbpf"
> +EXTRA_OECMAKE:append = " ${@bb.utils.contains('PACKAGECONFIG', 'in-ebpf', '-DLIBC_PATH=${libdir}/libc.so.6', '', d)}"
> +
>  SYSTEMD_SERVICE:${PN} = "fluent-bit.service"
>
>  inherit cmake systemd pkgconfig
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#121292): https://lists.openembedded.org/g/openembedded-devel/message/121292
> Mute This Topic: https://lists.openembedded.org/mt/116115058/1997914
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta-oe/recipes-extended/fluentbit/fluentbit/0006-cmake-add-recipe-sysroot-include-path-for-system-headers.patch b/meta-oe/recipes-extended/fluentbit/fluentbit/0006-cmake-add-recipe-sysroot-include-path-for-system-headers.patch
new file mode 100644
index 0000000000..2b73f48334
--- /dev/null
+++ b/meta-oe/recipes-extended/fluentbit/fluentbit/0006-cmake-add-recipe-sysroot-include-path-for-system-headers.patch
@@ -0,0 +1,31 @@ 
+From 9f47cc69683a842efdf6c31ea25b7b423ba3fc7e Mon Sep 17 00:00:00 2001
+From: Timotheus Giuliani <timotheus.giuliani@philips.com>
+Date: Tue, 7 Oct 2025 17:33:14 +0200
+Subject: [PATCH 1/3] cmake: add recipe sysroot include path for system headers
+
+The CMakeLists.txt was missing the recipe sysroot include path, which
+prevented the build system from finding required system headers during
+compilation. This commit adds the recipe sysroot directory to the
+include path so that headers provided by the sysroot, such as
+BPF headers and other system dependencies, can be properly located and
+included during the build process.
+Without this change, the build would fail to find essential headers
+when building in compilation environment.
+
+Signed-off-by: Timotheus Giuliani <timotheus.giuliani@philips.com>
+---
+ plugins/in_ebpf/CMakeLists.txt | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/plugins/in_ebpf/CMakeLists.txt b/plugins/in_ebpf/CMakeLists.txt
+index 476c07774..216b2ffce 100644
+--- a/plugins/in_ebpf/CMakeLists.txt
++++ b/plugins/in_ebpf/CMakeLists.txt
+@@ -91,6 +91,7 @@ foreach(TRACE_C_FILE ${TRACE_C_FILES})
+             -I${CMAKE_SOURCE_DIR}/plugins/in_ebpf/traces/includes/external
+             -I${CMAKE_SOURCE_DIR}/plugins/in_ebpf/traces/includes
+             -I${VMLINUX_PATH}         # Include the correct vmlinux.h based on architecture
++            --sysroot=${CMAKE_SYSROOT}  # Add yocto recipe sysroot to find "system headers"
+             -c ${TRACE_C_FILE}
+             -o ${TRACE_OBJ_FILE}
+     DEPENDS ${TRACE_C_FILE} ebpf-generated-directory
diff --git a/meta-oe/recipes-extended/fluentbit/fluentbit/0007-bpf-remove-hardcoded-target-architecture-definition.patch b/meta-oe/recipes-extended/fluentbit/fluentbit/0007-bpf-remove-hardcoded-target-architecture-definition.patch
new file mode 100644
index 0000000000..f30005e986
--- /dev/null
+++ b/meta-oe/recipes-extended/fluentbit/fluentbit/0007-bpf-remove-hardcoded-target-architecture-definition.patch
@@ -0,0 +1,54 @@ 
+From df05870068f0d1fe092650bb1ba0a518fb540550 Mon Sep 17 00:00:00 2001
+From: Timotheus Giuliani <timotheus.giuliani@philips.com>
+Date: Tue, 7 Oct 2025 17:34:28 +0200
+Subject: [PATCH 2/3] bpf: remove hardcoded target architecture definition
+
+The BPF programs was hardcoding the TARGET_ARCH_x86 definition, which
+prevented successful builds on other architectures such as ARM64.
+This commit removes the hardcoded architecture definition from the bpf
+source files, allowing the CMake build system to properly set the
+target architecture based on the actual build environment.
+
+Signed-off-by: Timotheus Giuliani <timotheus.giuliani@philips.com>
+---
+ plugins/in_ebpf/traces/bind/bpf.c      | 2 --
+ plugins/in_ebpf/traces/malloc/bpf.c.in | 3 ---
+ plugins/in_ebpf/traces/signal/bpf.c    | 2 --
+ 3 files changed, 7 deletions(-)
+
+diff --git a/plugins/in_ebpf/traces/bind/bpf.c b/plugins/in_ebpf/traces/bind/bpf.c
+index 1712bf67e..da9d7c3f1 100644
+--- a/plugins/in_ebpf/traces/bind/bpf.c
++++ b/plugins/in_ebpf/traces/bind/bpf.c
+@@ -2,8 +2,6 @@
+ /* Copyright (c) 2021 Hengqi Chen */
+ /* Copyright (c) 2024 The Inspektor Gadget authors */
+ 
+-#define __TARGET_ARCH_x86
+-
+ #include <vmlinux.h>
+ 
+ #define _LINUX_TYPES_H        // Prevent redefinition of linux/types.h
+diff --git a/plugins/in_ebpf/traces/malloc/bpf.c.in b/plugins/in_ebpf/traces/malloc/bpf.c.in
+index c37d3952a..ace4acdbe 100644
+--- a/plugins/in_ebpf/traces/malloc/bpf.c.in
++++ b/plugins/in_ebpf/traces/malloc/bpf.c.in
+@@ -1,6 +1,3 @@
+-#define __TARGET_ARCH_x86
+-
+-
+ #include <vmlinux.h>
+ 
+ #define _LINUX_TYPES_H        // Prevent redefinition of linux/types.h
+diff --git a/plugins/in_ebpf/traces/signal/bpf.c b/plugins/in_ebpf/traces/signal/bpf.c
+index 7d4503c22..3f017b325 100644
+--- a/plugins/in_ebpf/traces/signal/bpf.c
++++ b/plugins/in_ebpf/traces/signal/bpf.c
+@@ -1,7 +1,5 @@
+ // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
+ /* Copyright (c) 2021~2022 Hengqi Chen */
+-#define __TARGET_ARCH_x86_64
+-
+ #include <vmlinux.h>
+ 
+ #define _LINUX_TYPES_H        // Prevent redefinition of linux/types.h
diff --git a/meta-oe/recipes-extended/fluentbit/fluentbit/0008-cmake-allow-setting-LIBC_PATH-from-external-config.patch b/meta-oe/recipes-extended/fluentbit/fluentbit/0008-cmake-allow-setting-LIBC_PATH-from-external-config.patch
new file mode 100644
index 0000000000..57f4d899cd
--- /dev/null
+++ b/meta-oe/recipes-extended/fluentbit/fluentbit/0008-cmake-allow-setting-LIBC_PATH-from-external-config.patch
@@ -0,0 +1,73 @@ 
+From ab01dffe9bf2f1208ec4cea0a1582196cfbc0f87 Mon Sep 17 00:00:00 2001
+From: Timotheus Giuliani <timotheus.giuliani@philips.com>
+Date: Wed, 8 Oct 2025 14:24:36 +0200
+Subject: [PATCH 3/3] cmake: allow setting LIBC_PATH from external
+ configuration
+
+The CMakeLists.txt file was automatically detecting the libc library
+path based on the system distribution. This change allows the LIBC_PATH
+to be set externally through build configuration, which is useful for
+compilation environments where the library path is known in advance.
+The auto-detection logic is kept as a fallback when LIBC_PATH is not
+provided from external configuration.
+
+Signed-off-by: Timotheus Giuliani <timotheus.giuliani@philips.com>
+---
+ plugins/in_ebpf/CMakeLists.txt | 43 ++++++++++++++++++----------------
+ 1 file changed, 23 insertions(+), 20 deletions(-)
+
+diff --git a/plugins/in_ebpf/CMakeLists.txt b/plugins/in_ebpf/CMakeLists.txt
+index 216b2ffce..1c5e55785 100644
+--- a/plugins/in_ebpf/CMakeLists.txt
++++ b/plugins/in_ebpf/CMakeLists.txt
+@@ -25,27 +25,30 @@ include_directories(
+ add_library(gadget INTERFACE)
+ target_include_directories(gadget INTERFACE ${CMAKE_SOURCE_DIR}/plugins/in_ebpf/traces/includes/external/gadget)
+ 
+-set(LIBC_PATH "/lib64/libc.so.6")
+ 
+-find_program(LSB_RELEASE_EXEC lsb_release)
+-if (LSB_RELEASE_EXEC)
+-  execute_process(COMMAND ${LSB_RELEASE_EXEC} -i
+-      OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT
+-      OUTPUT_STRIP_TRAILING_WHITESPACE
+-  )
+-
+-  message(STATUS "##### lsb_release -i -- ${LSB_RELEASE_ID_SHORT}")
+-
+-  if (LSB_RELEASE_ID_SHORT MATCHES "Ubuntu" OR
+-      LSB_RELEASE_ID_SHORT MATCHES "Debian" OR
+-      LSB_RELEASE_ID_SHORT MATCHES "LinuxMint")
+-    # Just added for the future enhancement
+-    if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
+-      set(LIBC_PATH "/usr/lib/aarch64-linux-gnu/libc.so.6")
+-    elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
+-      set(LIBC_PATH "/usr/lib/x86_64-linux-gnu/libc.so.6")
+-    elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
+-      set(LIBC_PATH "/usr/lib/i386-linux-gnu/libc.so.6")
++if(NOT DEFINED LIBC_PATH OR LIBC_PATH STREQUAL "")
++  set(LIBC_PATH "/lib64/libc.so.6")
++
++  find_program(LSB_RELEASE_EXEC lsb_release)
++  if (LSB_RELEASE_EXEC)
++    execute_process(COMMAND ${LSB_RELEASE_EXEC} -i
++        OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT
++        OUTPUT_STRIP_TRAILING_WHITESPACE
++    )
++
++    message(STATUS "##### lsb_release -i -- ${LSB_RELEASE_ID_SHORT}")
++
++    if (LSB_RELEASE_ID_SHORT MATCHES "Ubuntu" OR
++        LSB_RELEASE_ID_SHORT MATCHES "Debian" OR
++        LSB_RELEASE_ID_SHORT MATCHES "LinuxMint")
++      # Just added for the future enhancement
++      if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
++        set(LIBC_PATH "/usr/lib/aarch64-linux-gnu/libc.so.6")
++      elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
++        set(LIBC_PATH "/usr/lib/x86_64-linux-gnu/libc.so.6")
++      elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
++        set(LIBC_PATH "/usr/lib/i386-linux-gnu/libc.so.6")
++      endif()
+     endif()
+   endif()
+ endif()
diff --git a/meta-oe/recipes-extended/fluentbit/fluentbit_4.0.1.bb b/meta-oe/recipes-extended/fluentbit/fluentbit_4.0.1.bb
index 4d82abc783..05dcd2cca7 100644
--- a/meta-oe/recipes-extended/fluentbit/fluentbit_4.0.1.bb
+++ b/meta-oe/recipes-extended/fluentbit/fluentbit_4.0.1.bb
@@ -23,6 +23,9 @@  SRC_URI = "\
     file://0001-lib-Do-not-use-private-makefile-targets-in-CMakelist.patch \
     file://0002-flb_info.h.in-Do-not-hardcode-compilation-directorie.patch \
     file://0003-CMakeLists.txt-Revise-init-manager-deduction.patch \
+    file://0006-cmake-add-recipe-sysroot-include-path-for-system-headers.patch \
+    file://0007-bpf-remove-hardcoded-target-architecture-definition.patch \
+    file://0008-cmake-allow-setting-LIBC_PATH-from-external-config.patch \
 "
 SRC_URI:append:libc-musl = "\
     file://0004-chunkio-Link-with-fts-library-with-musl.patch \
@@ -112,6 +115,10 @@  PACKAGECONFIG[minimal] = "-DFLB_MINIMAL=Yes,-DFLB_MINIMAL=No"
 PACKAGECONFIG[in-kafka] = "-DFLB_KAFKA=ON -DFLB_IN_KAFKA=ON,-DFLB_KAFKA=OFF -DFLB_IN_KAFKA=OFF,librdkafka curl"
 PACKAGECONFIG[out-kafka] = "-DFLB_KAFKA=ON -DFLB_OUT_KAFKA=ON,-DFLB_KAFKA=OFF -DFLB_OUT_KAFKA=OFF,librdkafka curl"
 
+# Add ebpf input
+PACKAGECONFIG[in-ebpf] = "-DFLB_IN_EBPF=Yes,-DFLB_IN_EBPF=No, bpftool-native clang-native libbpf"
+EXTRA_OECMAKE:append = " ${@bb.utils.contains('PACKAGECONFIG', 'in-ebpf', '-DLIBC_PATH=${libdir}/libc.so.6', '', d)}"
+
 SYSTEMD_SERVICE:${PN} = "fluent-bit.service"
 
 inherit cmake systemd pkgconfig