-
Notifications
You must be signed in to change notification settings - Fork 1.9k
build: introduce FLB_SIMD with 'Auto' value option (default) #11603
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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) | ||
|
|
@@ -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) | ||
|
|
@@ -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)$") | ||
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On riscv64, 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This new fatal-error branch turns every non-x86_64/aarch64/riscv64 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() | ||
|
|
||
|
|
||
| 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 () |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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:According to CMAKE_SYSTEM_PROCESSOR documentation:
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_SIMDmacro.Maybe it can be fixed this way:
There was a problem hiding this comment.
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