diff --git a/.github/workflows/pr-compile-check.yaml b/.github/workflows/pr-compile-check.yaml index 329c57071b9..dd982fab26e 100644 --- a/.github/workflows/pr-compile-check.yaml +++ b/.github/workflows/pr-compile-check.yaml @@ -30,3 +30,46 @@ jobs: push: false load: false provenance: false + + # Sanity check for compilation using system libraries + pr-compile-system-libs: + runs-on: ubuntu-20.04 + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + flb_option: + - "-DFLB_PREFER_SYSTEM_LIBS=On" + compiler: + - gcc + - clang + steps: + - name: Setup environment + run: | + sudo apt-get update + sudo apt-get install -y gcc-7 g++-7 clang-6.0 libsystemd-dev gcovr libyaml-dev libluajit-5.1-dev + sudo ln -s /usr/bin/llvm-symbolizer-6.0 /usr/bin/llvm-symbolizer || true + + - name: Checkout Fluent Bit code + uses: actions/checkout@v4 + + - name: ${{ matrix.compiler }} - ${{ matrix.flb_option }} + run: | + export nparallel=$(( $(getconf _NPROCESSORS_ONLN) > 8 ? 8 : $(getconf _NPROCESSORS_ONLN) )) + echo "CC = $CC, CXX = $CXX, FLB_OPT = $FLB_OPT" + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 90 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 90 + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-6.0 90 + cmake $GLOBAL_OPTS $FLB_OPT ../ + make -j $nparallel + working-directory: build + env: + CC: ${{ matrix.compiler }} + CXX: ${{ matrix.compiler }} + FLB_OPT: ${{ matrix.flb_option }} + GLOBAL_OPTS: "-DFLB_BACKTRACE=Off -DFLB_SHARED_LIB=Off -DFLB_DEBUG=On -DFLB_ALL=On -DFLB_EXAMPLES=Off" + + - name: Display dependencies w/ ldd + run: | + ldd ./bin/fluent-bit + working-directory: build diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e2a880b277..b894968f109 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -176,6 +176,10 @@ option(FLB_HTTP_CLIENT_DEBUG "Enable HTTP Client debug callbacks" No) # Run ldconfig on package post-install option(FLB_RUN_LDCONFIG "Enable execution of ldconfig after installation" No) +# Prefer system libraries if available +option(FLB_PREFER_SYSTEM_LIBS "Prefer system libraries" No) +option(FLB_PREFER_SYSTEM_LIB_LUAJIT "Prefer the libluajit system library" ${FLB_PREFER_SYSTEM_LIBS}) + # Enable all features if(FLB_ALL) # Global @@ -923,7 +927,16 @@ endif() # LuaJIT (Scripting Support) # ========================== if(FLB_LUAJIT) - include(cmake/luajit.cmake) + if(FLB_PREFER_SYSTEM_LIB_LUAJIT) + find_package(PkgConfig) + pkg_check_modules(LUAJIT luajit>=2.1.0) + endif() + if(LUAJIT_FOUND) + include_directories(${LUAJIT_INCLUDE_DIRS}) + link_directories(${LUAJIT_LIBRARY_DIRS}) + else() + include(cmake/luajit.cmake) + endif() FLB_DEFINITION(FLB_HAVE_LUAJIT) endif() diff --git a/cmake/headers.cmake b/cmake/headers.cmake index 45a1394ca7f..500c4c3b947 100755 --- a/cmake/headers.cmake +++ b/cmake/headers.cmake @@ -22,10 +22,6 @@ include_directories( ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_CHUNKIO}/include ${CMAKE_CURRENT_BINARY_DIR}/lib/chunkio/include - # LuaJIT - ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_LUAJIT}/src - ${CMAKE_CURRENT_BINARY_DIR}/lib/luajit-cmake - ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_MONKEY}/include ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_MONKEY}/include/monkey ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_MBEDTLS}/include diff --git a/cmake/luajit.cmake b/cmake/luajit.cmake index 63a2d8492ab..b4dfca2b296 100644 --- a/cmake/luajit.cmake +++ b/cmake/luajit.cmake @@ -2,4 +2,9 @@ option(LUAJIT_DIR "Path of LuaJIT 2.1 source dir" ON) option(LUAJIT_SETUP_INCLUDE_DIR "Setup include dir if parent is present" OFF) set(LUAJIT_DIR ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_LUAJIT}) +include_directories( + ${LUAJIT_DIR}/src + ${CMAKE_CURRENT_BINARY_DIR}/lib/luajit-cmake +) add_subdirectory("lib/luajit-cmake") +set(LUAJIT_LIBRARIES "libluajit") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 593e9865bc4..084f2c57d52 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -223,7 +223,7 @@ endif() if(FLB_LUAJIT) set(extra_libs ${extra_libs} - "libluajit") + ${LUAJIT_LIBRARIES}) endif() if(FLB_SQLDB)