Skip to content

Commit

Permalink
bug-fix : Check for clang build dependency when building ebpf
Browse files Browse the repository at this point in the history
Signed-off-by: Abhishek Jha <[email protected]>
  • Loading branch information
abhi-jha authored and niedbalski committed Feb 21, 2025
1 parent 03fe519 commit 4851c4b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,32 @@ endif()
if (FLB_IN_EBPF)
find_package(PkgConfig)

# Check for Clang compiler
find_program(CLANG_EXECUTABLE clang)

if (CLANG_EXECUTABLE)
message(STATUS "Clang found: ${CLANG_EXECUTABLE}")
# Get Clang version
execute_process(
COMMAND ${CLANG_EXECUTABLE} --version
OUTPUT_VARIABLE CLANG_VERSION_OUTPUT
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (CLANG_VERSION_OUTPUT MATCHES "clang version ([0-9]+)\\.([0-9]+)\\.([0-9]+)")
set(CLANG_VERSION_MAJOR "${CMAKE_MATCH_1}")
set(CLANG_VERSION_MINOR "${CMAKE_MATCH_2}")
set(CLANG_VERSION_PATCH "${CMAKE_MATCH_3}")

message(STATUS "Detected Clang version: ${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCH}")
# Check if Clang version is at least 3.7.0
if (CLANG_VERSION_MAJOR LESS 3 AND CLANG_VERSION_MINOR LESS 7)
message(FATAL_ERROR "Clang version must be at least 3.7.0, but found ${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCH}")
endif()
endif()
else()
message(FATAL_ERROR "Clang not found! Please install Clang version >= 3.7.0!")
endif()

# Check for libbpf with pkg-config
pkg_check_modules(LIBBPF libbpf>=0.5.0)

Expand Down

0 comments on commit 4851c4b

Please sign in to comment.