Skip to content

build: introduce FLB_SIMD with 'Auto' value option (default)#11603

Merged
edsiper merged 1 commit intomasterfrom
simd_on
Mar 22, 2026
Merged

build: introduce FLB_SIMD with 'Auto' value option (default)#11603
edsiper merged 1 commit intomasterfrom
simd_on

Conversation

@edsiper
Copy link
Member

@edsiper edsiper commented Mar 22, 2026

  • x86_64, aarch64: Auto enables SIMD.
  • riscv64: Auto disables SIMD, On requires RVV compiler support.
  • arm32 and other unsupported targets: Auto disables SIMD, On keeps the scalar fallback instead of breaking
    configure.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Summary by CodeRabbit

Release Notes

  • Build & Configuration
    • SIMD support option now features automatic detection (On/Off/Auto) for improved flexibility across architectures
    • Enhanced RISC-V 64 architecture support with compiler-aware SIMD feature selection
    • Build-time validation provides clear errors when requested SIMD features are unavailable

Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
@coderabbitai
Copy link

coderabbitai bot commented Mar 22, 2026

📝 Walkthrough

Walkthrough

The FLB_SIMD option transforms from a boolean to a tri-state cached string (On/Off/Auto) with input validation. Configuration logic now includes architecture-specific SIMD enablement: unconditionally enabled for x86_64 and aarch64/arm64, conditionally enabled for riscv64 with compiler capability detection, and configure-time failures when FLB_SIMD=On cannot be satisfied. Compiler flags are conditionally applied based on SIMD enablement status.

Changes

Cohort / File(s) Summary
SIMD Configuration Logic
CMakeLists.txt
Refactored FLB_SIMD from boolean option to tri-state cached string with validation. Added architecture-aware SIMD enablement detection (x86_64 and aarch64/arm64 always enabled, riscv64 conditional on compiler support). Implements configuration-time error handling and conditional FLB_HAVE_SIMD definition.
RISC-V SIMD Flags
cmake/riscv64.cmake
Updated SIMD flag handling to use FLB_SIMD_RISCV_C_FLAGS variable instead of hardcoded -march=rv64gcv_zba, with conditional application based on FLB_SIMD_ENABLED status.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

docs-required

Poem

🐰 A tri-state option now takes the stage,
SIMD features dance across each page,
x86 and ARM embrace the call,
While RISC-V checks compiler support for all,
Configuration wise, we march forward true! 🚀

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: converting FLB_SIMD from a boolean to a tri-state option with 'Auto' as the default value, which aligns with the primary objective of the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch simd_on

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 27b82dec27

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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

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 👍 / 👎.

Comment on lines +309 to +312
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")

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 👍 / 👎.

@edsiper
Copy link
Member Author

edsiper commented Mar 22, 2026

CI errors are associated to TCP ports

@edsiper edsiper merged commit 1982583 into master Mar 22, 2026
43 of 47 checks passed
@edsiper edsiper deleted the simd_on branch March 22, 2026 15:00
if(NOT FLB_SIMD_MODE STREQUAL "OFF")
set(FLB_SIMD_SUPPORTED_ARCH No)

if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64|amd64)$")
Copy link
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
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants