Skip to content
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
64 changes: 62 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.12)
project(fluent-bit C)

include(CheckCCompilerFlag)

# CMP0069 ensures that LTO is enabled for all compilers
cmake_policy(SET CMP0069 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
Expand Down Expand Up @@ -207,7 +209,8 @@ option(FLB_SIGNV4 "Enable AWS Signv4 support" Yes)
option(FLB_AWS "Enable AWS support" Yes)
option(FLB_STATIC_CONF "Build binary using static configuration")
option(FLB_STREAM_PROCESSOR "Enable Stream Processor" Yes)
option(FLB_SIMD "Enable SIMD support" No)
set(FLB_SIMD "Auto" CACHE STRING "Enable SIMD support (On, Off, Auto)")
set_property(CACHE FLB_SIMD PROPERTY STRINGS "On;Off;Auto")
option(FLB_CORO_STACK_SIZE "Set coroutine stack size")
option(FLB_AVRO_ENCODER "Build with Avro encoding support" No)
option(FLB_AWS_ERROR_REPORTER "Build with aws error reporting support" No)
Expand Down Expand Up @@ -258,7 +261,64 @@ option(FLB_EVENT_LOOP_SELECT "Enable select(2) event loop backend" No)
option(FLB_EVENT_LOOP_LIBEVENT "Enable libevent event loop backend" No)

# SIMD support
if(FLB_SIMD)
# ------------
# FLB_SIMD is a tri-state cache variable:
# Auto : enable SIMD only when the target architecture/toolchain is known-good
# On : require SIMD support and fail during configure otherwise
# Off : disable SIMD explicitly
string(TOUPPER "${FLB_SIMD}" FLB_SIMD_MODE)

if(FLB_SIMD_MODE MATCHES "^(ON|YES|TRUE|1)$")
set(FLB_SIMD_MODE "ON")
elseif(FLB_SIMD_MODE MATCHES "^(OFF|NO|FALSE|0)$")
set(FLB_SIMD_MODE "OFF")
elseif(NOT FLB_SIMD_MODE STREQUAL "AUTO")
message(FATAL_ERROR "FLB_SIMD must be one of: On, Off, Auto")
endif()

set(FLB_SIMD_ENABLED No)
set(FLB_SIMD_RISCV_C_FLAGS "")

if(NOT FLB_SIMD_MODE STREQUAL "OFF")
set(FLB_SIMD_SUPPORTED_ARCH No)

if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64|amd64)$")
Copy link
Copy Markdown
Contributor

@mabrarov mabrarov Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check seems to enable SIMD support (FLB_SIMD_ENABLED == Yes) for x86 32bit Windows build which breaks it. Refer to https://github.com/fluent/fluent-bit/actions/runs/23405338585/job/68083237733#logs:

flb_pack.c.obj : error LNK2019: unresolved external symbol _flb_vector8_eq referenced in function _is_float
..\bin\fluent-bit.dll : fatal error LNK1120: 1 unresolved externals

According to CMAKE_SYSTEM_PROCESSOR documentation:

When not cross-compiling, this variable has the same value as the CMAKE_HOST_SYSTEM_PROCESSOR variable.

It means that if CI uses x86 64bit hardware (which seems to be so), then x86 32bit Windows build gets SIMD enabled in all places which rely on FLB_HAVE_SIMD macro.

Maybe it can be fixed this way:

Suggested change
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64|amd64)$")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64|amd64)$" AND (CMAKE_SIZEOF_VOID_P GREATER 4))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Included this fix into #11604

set(FLB_SIMD_SUPPORTED_ARCH Yes)
set(FLB_SIMD_ENABLED Yes)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64|ARM64|AARCH64)$")
set(FLB_SIMD_SUPPORTED_ARCH Yes)
set(FLB_SIMD_ENABLED Yes)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(riscv64)")
set(FLB_SIMD_SUPPORTED_ARCH Yes)
check_c_compiler_flag("-march=rv64gcv_zba" FLB_SIMD_RISCV_COMPILER_FLAG)

if(FLB_SIMD_RISCV_COMPILER_FLAG)
set(FLB_SIMD_ENABLED Yes)
set(FLB_SIMD_RISCV_C_FLAGS "-march=rv64gcv_zba")
Comment on lines +295 to +297
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Don't auto-enable RVV from compiler support alone

On riscv64, Auto now flips on FLB_HAVE_SIMD whenever the compiler accepts -march=rv64gcv_zba. That only proves the toolchain can emit RVV instructions, not that the target CPU has RVV; include/fluent-bit/flb_simd.h:88-102 and the hot paths in src/flb_pack.c/src/flb_utils.c then compile unconditional RVV intrinsics. A generic riscv64 package built with a modern compiler will therefore SIGILL on the many riscv64 systems that lack the optional V extension, so Auto is no longer safe for that architecture.

Useful? React with 👍 / 👎.

elseif(FLB_SIMD_MODE STREQUAL "ON")
message(FATAL_ERROR
"FLB_SIMD=On requires compiler support for -march=rv64gcv_zba on riscv64")
else()
message(WARNING
"FLB_SIMD=Auto disabled SIMD on riscv64 because the compiler does not "
"support -march=rv64gcv_zba")
endif()
endif()

if(NOT FLB_SIMD_SUPPORTED_ARCH)
if(FLB_SIMD_MODE STREQUAL "ON")
message(FATAL_ERROR
"FLB_SIMD=On is only supported on x86_64, aarch64/arm64, and "
"riscv64 with RVV compiler support")
Comment on lines +309 to +312
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve arm32 FLB_SIMD=On package builds

This new fatal-error branch turns every non-x86_64/aarch64/riscv64 -DFLB_SIMD=On build into a configure failure. That breaks an existing repo build path: packaging/distros/raspbian/Dockerfile:66-81 still passes -DFLB_SIMD=On, packaging/README.md:49-51 documents those targets as arm32v7, and .github/workflows/call-build-linux-packages.yaml:105-130 still runs the raspbian/* package jobs. Before this change those builds fell back to the scalar FLB_SIMD_NONE path in include/fluent-bit/flb_simd.h, so the packaging workflow now stops at CMake configure time.

Useful? React with 👍 / 👎.

else()
message(STATUS
"FLB_SIMD=Auto disabled SIMD on unsupported architecture: "
"${CMAKE_SYSTEM_PROCESSOR}")
endif()
endif()
endif()

if(FLB_SIMD_ENABLED)
FLB_DEFINITION(FLB_HAVE_SIMD)
endif()

Expand Down
6 changes: 4 additions & 2 deletions cmake/riscv64.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(riscv64)")
message(STATUS "Forcing characters to be signed, as on x86_64.")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsigned-char")

if(FLB_LUAJIT)
message(WARNING "LuaJIT is disabled, this platform does not support built-in LuaJIT and system provided one neither.")
set(FLB_LUAJIT OFF)
endif()
if(FLB_SIMD)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=rv64gcv_zba")

if(FLB_SIMD_ENABLED AND NOT "${FLB_SIMD_RISCV_C_FLAGS}" STREQUAL "")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLB_SIMD_RISCV_C_FLAGS}")
endif()
endif ()
Loading