Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: use the system provided LuaJIT if found #7286

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/pr-compile-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 14 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
ThomasDevoogdt marked this conversation as resolved.
Show resolved Hide resolved
include_directories(${LUAJIT_INCLUDE_DIRS})
link_directories(${LUAJIT_LIBRARY_DIRS})
else()
include(cmake/luajit.cmake)
endif()
FLB_DEFINITION(FLB_HAVE_LUAJIT)
endif()

Expand Down
4 changes: 0 additions & 4 deletions cmake/headers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions cmake/luajit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ endif()
if(FLB_LUAJIT)
set(extra_libs
${extra_libs}
"libluajit")
${LUAJIT_LIBRARIES})
endif()

if(FLB_SQLDB)
Expand Down
Loading