Skip to contentSkip to conversation

package/fluent-bit: use the system provided LuaJIT

PATCH New Thomas Devoogdt 1 participant 4 messages May 17, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 package/fluent-bit: use the system provided LuaJIT

Luajit was not used at all when it was selected, instead fluent-bit recompiled it without taking care of the complexities that were handled in the luajit package. Fix this by linking dynamically to the buildroot provided version.

---
 ...-the-system-provided-LuaJIT-if-found.patch | 62 +++++++++++++++++++
 package/fluent-bit/fluent-bit.mk              |  1 +
 2 files changed, 63 insertions(+)
 create mode 100644 package/fluent-bit/0001-build-use-the-system-provided-LuaJIT-if-found.patch
package/fluent-bit/0001-build-use-the-system-provided-LuaJIT-if-found.patch new file +62 -0
new file mode 100644
index 0000000000..9f6f4d0ebb
@@ -0,0 +1,62 @@
+From 4f8eb7bb5a39d83374806928b7a5b622136ef055 Mon Sep 17 00:00:00 2001
+From: Thomas Devoogdt <[email protected]>
+Date: Fri, 28 Apr 2023 10:25:16 +0200
+Subject: [PATCH] build: use the system provided LuaJIT if found
+
+e.g. buildroot has logic to build luajit,
+so if pkg_check_modules can find a suitable version,
+then use that one if -DFLB_PREFER_SYSTEM_LIBS=Yes.
+
+Upstream: https://github.com/fluent/fluent-bit/pull/7286
+Signed-off-by: Thomas Devoogdt <[email protected]>
+---
+ CMakeLists.txt     | 12 +++++++++++-
+ src/CMakeLists.txt |  2 +-
+ 2 files changed, 12 insertions(+), 2 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 9af783c79..0601b7c18 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -123,6 +123,7 @@ option(FLB_TESTS_INTERNAL_FUZZ "Enable internal fuzz tests"    No)
+ option(FLB_TESTS_OSSFUZZ       "Enable OSS-Fuzz build"         No)
+ option(FLB_MTRACE              "Enable mtrace support"         No)
+ option(FLB_POSIX_TLS           "Force POSIX thread storage"    No)
++option(FLB_PREFER_SYSTEM_LIBS  "Prefer system installed libraries" No)
+ option(FLB_INOTIFY             "Enable inotify support"       Yes)
+ option(FLB_SQLDB               "Enable SQL embedded DB"       Yes)
+ option(FLB_HTTP_SERVER         "Enable HTTP Server"           Yes)
+@@ -1003,7 +1004,16 @@ endif()
+ # LuaJIT (Scripting Support)
+ # ==========================
+ if(FLB_LUAJIT)
+-  include(cmake/luajit.cmake)
++  if(FLB_PREFER_SYSTEM_LIBS)
++    find_package(PkgConfig)
++    pkg_check_modules(LUAJIT luajit>=2.1.0)
++  endif()
++  if(LUAJIT_FOUND)
++    include_directories(${LUAJIT_INCLUDE_DIRS})
++  else()
++    include(cmake/luajit.cmake)
++    set(LUAJIT_LIBRARIES "libluajit")
++  endif()
+   FLB_DEFINITION(FLB_HAVE_LUAJIT)
+ endif()
+ 
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index 06a206dd4..8b66ddd22 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -220,7 +220,7 @@ endif()
+ if(FLB_LUAJIT)
+   set(extra_libs
+     ${extra_libs}
+-    "libluajit")
++    ${LUAJIT_LIBRARIES})
+ endif()
+ 
+ if(FLB_SQLDB)
+-- 
+2.34.1
+
package/fluent-bit/fluent-bit.mk +1 -0
index 319815f056..60a1d06dbf 100644
@@ -20,6 +20,7 @@ FLUENT_BIT_CONF_OPTS += \
 	-DFLB_RELEASE=Yes \
 	-DFLB_EXAMPLES=No \
 	-DFLB_CHUNK_TRACE=No \
+	-DFLB_PREFER_SYSTEM_LIBS=Yes \
 	-DFLB_BACKTRACE=No
 
 ifeq ($(BR2_PACKAGE_FLUENT_BIT_WASM),y)
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH 2/4 package/fluent-bit: drop cxx handling

Fluent-bit is written in pure c, so drop any cxx handling. Only the wasm part needs c++, but that one doesn't need the fixes which are now dropped.

---
 package/fluent-bit/fluent-bit.mk | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
package/fluent-bit/fluent-bit.mk +1 -5
index 60a1d06dbf..d470e26b5e 100644
@@ -13,7 +13,6 @@ FLUENT_BIT_CPE_ID_PRODUCT = fluent_bit
 FLUENT_BIT_DEPENDENCIES = host-bison host-flex libyaml openssl
 
 FLUENT_BIT_CFLAGS = $(TARGET_CFLAGS)
-FLUENT_BIT_CXXFLAGS = $(TARGET_CXXFLAGS)
 
 FLUENT_BIT_CONF_OPTS += \
 	-DFLB_DEBUG=No \
@@ -49,13 +48,11 @@ FLUENT_BIT_CONF_OPTS += \
 # Fix multiple definition of `mk_tls_*'.
 # https://github.com/fluent/fluent-bit/issues/5537
 FLUENT_BIT_CFLAGS += -fcommon
-FLUENT_BIT_CXXFLAGS += -fcommon
 
 # Undefining _FILE_OFFSET_BITS here because of a "bug" with glibc fts.h
 # large file support.
 # https://bugzilla.redhat.com/show_bug.cgi?id=574992
 FLUENT_BIT_CFLAGS += -U_FILE_OFFSET_BITS
-FLUENT_BIT_CXXFLAGS += -U_FILE_OFFSET_BITS
 
 ifeq ($(BR2_PACKAGE_LIBEXECINFO),y)
 FLUENT_BIT_DEPENDENCIES += libexecinfo
@@ -74,8 +71,7 @@ endif
 
 FLUENT_BIT_CONF_OPTS += \
 	-DCMAKE_EXE_LINKER_FLAGS="$(FLUENT_BIT_LDFLAGS)" \
-	-DCMAKE_C_FLAGS="$(FLUENT_BIT_CFLAGS)" \
-	-DCMAKE_CXX_FLAGS="$(FLUENT_BIT_CXXFLAGS)"
+	-DCMAKE_C_FLAGS="$(FLUENT_BIT_CFLAGS)"
 
 define FLUENT_BIT_INSTALL_INIT_SYSV
 	$(INSTALL) -D -m 0755 package/fluent-bit/S99fluent-bit \
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

PATCH 3/4 package/fluent-bit: rework wasm handling

In reply to Thomas Devoogdt

Fluent-bit isn't very great at supporting the various architectures, so help a little bit by defining the WAMR_BUILD_TARGET ourselves.

./utils/test-pkg -c fluent-bit.config -p fluent-bit -a

                             arm-aarch64 [ 1/45]: OK
                   bootlin-aarch64-glibc [ 2/45]: OK
               bootlin-arcle-hs38-uclibc [ 3/45]: OK
                    bootlin-armv5-uclibc [ 4/45]: OK
                     bootlin-armv7-glibc [ 5/45]: OK
                   bootlin-armv7m-uclibc [ 6/45]: SKIPPED
                      bootlin-armv7-musl [ 7/45]: OK
                bootlin-m68k-5208-uclibc [ 8/45]: SKIPPED
               bootlin-m68k-68040-uclibc [ 9/45]: OK
             bootlin-microblazeel-uclibc [10/45]: OK
                bootlin-mipsel32r6-glibc [11/45]: OK
                   bootlin-mipsel-uclibc [12/45]: OK
                     bootlin-nios2-glibc [13/45]: OK
                 bootlin-openrisc-uclibc [14/45]: OK
        bootlin-powerpc64le-power8-glibc [15/45]: OK
           bootlin-powerpc-e500mc-uclibc [16/45]: OK
                   bootlin-riscv32-glibc [17/45]: OK
                   bootlin-riscv64-glibc [18/45]: OK
                    bootlin-riscv64-musl [19/45]: OK
                 bootlin-s390x-z13-glibc [20/45]: OK
                      bootlin-sh4-uclibc [21/45]: OK
                   bootlin-sparc64-glibc [22/45]: OK
                    bootlin-sparc-uclibc [23/45]: SKIPPED
                    bootlin-x86-64-glibc [24/45]: OK
                     bootlin-x86-64-musl [25/45]: OK
                   bootlin-x86-64-uclibc [26/45]: OK
                   bootlin-xtensa-uclibc [27/45]: OK
                            br-arm-basic [28/45]: OK
                    br-arm-full-nothread [29/45]: SKIPPED
                      br-arm-full-static [30/45]: SKIPPED
                   br-i386-pentium4-full [31/45]: OK
                br-i386-pentium-mmx-musl [32/45]: OK
                      br-mips64-n64-full [33/45]: OK
                 br-mips64r6-el-hf-glibc [34/45]: OK
               br-powerpc-603e-basic-cpp [35/45]: OK
               br-powerpc64-power7-glibc [36/45]: OK
                       linaro-aarch64-be [37/45]: OK
                          linaro-aarch64 [38/45]: OK
                              linaro-arm [39/45]: OK
                     sourcery-arm-armv4t [40/45]: OK
                            sourcery-arm [41/45]: OK
                     sourcery-arm-thumb2 [42/45]: OK
                         sourcery-mips64 [43/45]: FAILED
                           sourcery-mips [44/45]: FAILED
                          sourcery-nios2 [45/45]: OK

Two failures:

- sourcery-mips64:

core/iwasm/common/arch/invokeNative_mips.s: Assembler messages:
core/iwasm/common/arch/invokeNative_mips.s:58: Error: opcode not supported on this processor: mips64r2 (mips64r2) ldc1 $f12,0($sp)' core/iwasm/common/arch/invokeNative_mips.s:59: Error: opcode not supported on this processor: mips64r2 (mips64r2) ldc1 $f14,8($sp)'
make[4]: *** [src/wasm/CMakeFiles/vmlib-static.dir/build.make:495: src/wasm/CMakeFiles/vmlib-static.dir/__/__/lib/wasm-micro-runtime-WAMR-1.1.1/core/iwasm/common/arch/invokeNative_mips.s.o] Error 1 make[4]: *** Waiting for unfinished jobs....

- sourcery-mips:

core/iwasm/common/arch/invokeNative_mips.s: Assembler messages:
core/iwasm/common/arch/invokeNative_mips.s:58: Error: opcode not supported on this processor: mips32r2 (mips32r2) ldc1 $f12,0($sp)' core/iwasm/common/arch/invokeNative_mips.s:59: Error: opcode not supported on this processor: mips32r2 (mips32r2) ldc1 $f14,8($sp)'
make[4]: *** [src/wasm/CMakeFiles/vmlib-static.dir/build.make:495: src/wasm/CMakeFiles/vmlib-static.dir/__/__/lib/wasm-micro-runtime-WAMR-1.1.1/core/iwasm/common/arch/invokeNative_mips.s.o] Error 1 make[4]: *** Waiting for unfinished jobs....

Fix see: https://github.com/bytecodealliance/wasm-micro-runtime/issues/625

Quoted 2 lines
Quoted 2 lines

Hi, building the invokeNative_general.c explicitly is supported now, please pull the latest code and use "cmake -DWAMR_BUILD_INVOKE_NATIVE_GENERAL=1 ..." to build it.

---
 package/fluent-bit/Config.in     | 25 -------------------------
 package/fluent-bit/fluent-bit.mk | 32 ++++++++++++++++++++++++++++++--
 2 files changed, 30 insertions(+), 27 deletions(-)
package/fluent-bit/Config.in +0 -25
index bfdea895b0..dc477e9f39 100644
@@ -11,31 +11,6 @@ config BR2_PACKAGE_FLUENT_BIT
 
 	  https://github.com/fluent/fluent-bit
 
-if BR2_PACKAGE_FLUENT_BIT
-
-config BR2_PACKAGE_FLUENT_BIT_WASM_ARCH_SUPPORTS
-	bool
-	# see lib/wasm-micro-runtime-WAMR-1.1.1/README.md#supported-architectures-and-platforms
-	default y if BR2_arc
-	default y if BR2_arm || BR2_armeb
-	default y if BR2_aarch64 || BR2_aarch64_be
-	default y if BR2_i386 || BR2_x86_64
-	default y if BR2_RISCV_64
-	default y if BR2_xtensa
-
-config BR2_PACKAGE_FLUENT_BIT_WASM
-	bool "wasm runtime support"
-	depends on BR2_INSTALL_LIBSTDCPP
-	depends on BR2_PACKAGE_FLUENT_BIT_WASM_ARCH_SUPPORTS
-	help
-	  Support for WASM-based plugins.
-
-comment "wasm runtime support needs a toolchain w/ C++"
-	depends on BR2_PACKAGE_FLUENT_BIT_WASM_ARCH_SUPPORTS
-	depends on !BR2_INSTALL_LIBSTDCPP
-
-endif
-
 comment "fluent-bit needs a toolchain w/ threads, dynamic library"
 	depends on BR2_TOOLCHAIN_HAS_SYNC_4
 	depends on !BR2_TOOLCHAIN_HAS_THREADS || BR2_STATIC_LIBS
package/fluent-bit/fluent-bit.mk +30 -2
index d470e26b5e..2a7097968d 100644
@@ -22,8 +22,36 @@ FLUENT_BIT_CONF_OPTS += \
 	-DFLB_PREFER_SYSTEM_LIBS=Yes \
 	-DFLB_BACKTRACE=No
 
-ifeq ($(BR2_PACKAGE_FLUENT_BIT_WASM),y)
-FLUENT_BIT_CONF_OPTS += -DFLB_WASM=Yes
+# WASM runtime support needs a toolchain w/ C++
+ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
+ifeq ($(BR2_aarch64)$(BR2_aarch64_be),y)
+FLUENT_BIT_WAMR_BUILD_TARGET = AARCH64
+else ifeq ($(BR2_arcle)$(BR2_arceb),y)
+FLUENT_BIT_WAMR_BUILD_TARGET = ARC
+else ifeq ($(BR2_arm)$(BR2_armeb),y)
+FLUENT_BIT_WAMR_BUILD_TARGET = ARM
+else ifeq ($(BR2_mips)$(BR2_mipsel)$(BR2_mips64)$(BR2_mips64el),y)
+FLUENT_BIT_WAMR_BUILD_TARGET = MIPS
+# https://github.com/bytecodealliance/wasm-micro-runtime/issues/625
+# Fix unknown opcode 'ldc1', seen on mips32r2 and mips64r2.
+FLUENT_BIT_CONF_OPTS += \
+	-DWAMR_BUILD_INVOKE_NATIVE_GENERAL=1
+else ifeq ($(BR2_riscv)$(BR2_RISCV_32),yy)
+FLUENT_BIT_WAMR_BUILD_TARGET = RISCV32
+else ifeq ($(BR2_riscv)$(BR2_RISCV_64),yy)
+FLUENT_BIT_WAMR_BUILD_TARGET = RISCV64
+else ifeq ($(BR2_i386),y)
+FLUENT_BIT_WAMR_BUILD_TARGET = X86_32
+else ifeq ($(BR2_x86_64),y)
+FLUENT_BIT_WAMR_BUILD_TARGET = X86_64
+else ifeq ($(BR2_xtensa),y)
+FLUENT_BIT_WAMR_BUILD_TARGET = XTENSA
+endif
+endif
+
+ifneq ($(FLUENT_BIT_WAMR_BUILD_TARGET),)
+FLUENT_BIT_CONF_OPTS += -DFLB_WASM=Yes \
+	-DWAMR_BUILD_TARGET=$(FLUENT_BIT_WAMR_BUILD_TARGET)
 else
 FLUENT_BIT_CONF_OPTS += -DFLB_WASM=No
 endif
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

PATCH 4/4 package/fluent-bit: bump to version 2.1.3

In reply to Thomas Devoogdt

Fluent Bit v2.1 is the start of the new stable series of the project.

- Release Notes:

    https://fluentbit.io/announcements/v2.1.0/
    https://fluentbit.io/announcements/v2.1.1/
    https://fluentbit.io/announcements/v2.1.2/

No release notes yet for 2.1.3, but contains this
list of upstreamed patches:

    https://github.com/fluent/fluent-bit/pull/7266
    https://github.com/fluent/fluent-bit/pull/7254
    https://github.com/fluent/fluent-bit/pull/7253/files

So the old patches can be dropped.

---
 .checkpackageignore                           |   3 -
 .../0001-lib-cfl-fixup-static_assert.patch    |  33 -----
 .../0002-lib-c-ares-fixup-static_assert.patch |  56 --------
 .../fluent-bit/0003-fix-build-without-C.patch | 131 ------------------
 package/fluent-bit/fluent-bit.hash            |   2 +-
 package/fluent-bit/fluent-bit.mk              |   2 +-
 6 files changed, 2 insertions(+), 225 deletions(-)
 delete mode 100644 package/fluent-bit/0001-lib-cfl-fixup-static_assert.patch
 delete mode 100644 package/fluent-bit/0002-lib-c-ares-fixup-static_assert.patch
 delete mode 100644 package/fluent-bit/0003-fix-build-without-C.patch
.checkpackageignore +0 -3
index 947f4606aa..1eb4e6b00a 100644
@@ -487,9 +487,6 @@ package/flex/0002-build-make-it-possible-to-disable-the-build-of-the-f.patch Ups
 package/flex/0003-build-make-it-possible-to-disable-the-build-of-the-d.patch Upstream
 package/flite/0001-fix-alsa-static.patch Upstream
 package/fltk/0001-disable-tests.patch Upstream
-package/fluent-bit/0001-lib-cfl-fixup-static_assert.patch Upstream
-package/fluent-bit/0002-lib-c-ares-fixup-static_assert.patch Upstream
-package/fluent-bit/0003-fix-build-without-C.patch Upstream
 package/fluxbox/0001-fixes-bug-1138.patch Upstream
 package/freeipmi/0001-add-disable-doc.patch Upstream
 package/freeradius-client/0001-fix-for-nettle.patch Upstream
package/fluent-bit/0001-lib-cfl-fixup-static_assert.patch deleted +0 -33
deleted file mode 100644
index 19dab7cac6..0000000000
@@ -1,33 +0,0 @@
-From e4f825dd9e952f4a056bf89342049e67102ae6bb Mon Sep 17 00:00:00 2001
-From: Thomas Devoogdt <[email protected]>
-Date: Wed, 1 Feb 2023 11:38:15 +0100
-Subject: [PATCH] lib: cfl: fixup static_assert
-
-"undefined reference to 'static_assert'"
-
-Not defined when using uClibc or if not C++ >= 11.
-
-upstream: https://github.com/Cyan4973/xxHash/commit/6189ecd3d44a693460f86280ccf49d33cb4b18e1
-
-Signed-off-by: Thomas Devoogdt <[email protected]>
----
- lib/cfl/lib/xxhash/xxhash.h | 3 +--
- 1 file changed, 1 insertion(+), 2 deletions(-)
-
-diff --git a/lib/cfl/lib/xxhash/xxhash.h b/lib/cfl/lib/xxhash/xxhash.h
-index 08ab79457..511c4d12b 100644
---- a/lib/cfl/lib/xxhash/xxhash.h
-+++ b/lib/cfl/lib/xxhash/xxhash.h
-@@ -1546,8 +1546,7 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size)
- /* note: use after variable declarations */
- #ifndef XXH_STATIC_ASSERT
- #  if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)    /* C11 */
--#    include <assert.h>
--#    define XXH_STATIC_ASSERT_WITH_MESSAGE(c,m) do { static_assert((c),m); } while(0)
-+#    define XXH_STATIC_ASSERT_WITH_MESSAGE(c,m) do { _Static_assert((c),m); } while(0)
- #  elif defined(__cplusplus) && (__cplusplus >= 201103L)            /* C++11 */
- #    define XXH_STATIC_ASSERT_WITH_MESSAGE(c,m) do { static_assert((c),m); } while(0)
- #  else
--- 
-2.34.1
-
package/fluent-bit/0002-lib-c-ares-fixup-static_assert.patch deleted +0 -56

56 lines not on this page · raw message

package/fluent-bit/0003-fix-build-without-C.patch deleted +0 -131

131 lines not on this page · raw message

package/fluent-bit/fluent-bit.hash +1 -1
index d60531438a..c58461ccc5 100644
@@ -1,3 +1,3 @@
 # Locally computed
-sha256  aad5176cb4dcadacacd379ca43160074c6690012d37c4749536ac3b977d50495  fluent-bit-2.0.10.tar.gz
+sha256  114133ab4ecd38e982807b53f5059103295fbd7a2715e75afaff3791a53a0e9d  fluent-bit-2.1.3.tar.gz
 sha256  0d542e0c8804e39aa7f37eb00da5a762149dc682d7829451287e11b938e94594  LICENSE
package/fluent-bit/fluent-bit.mk +1 -1
index 2a7097968d..18f502d0a0 100644
@@ -4,7 +4,7 @@
 #
 ################################################################################
 
-FLUENT_BIT_VERSION = 2.0.10
+FLUENT_BIT_VERSION = 2.1.3
 FLUENT_BIT_SITE = $(call github,fluent,fluent-bit,v$(FLUENT_BIT_VERSION))
 FLUENT_BIT_LICENSE = Apache-2.0
 FLUENT_BIT_LICENSE_FILES = LICENSE
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot