@cryptotaxi247 / netdata-1 / commits / 2294cc9c2

Use parallelization for LTO processing to reduce build times. (#20809)

When using LTO with GCC 10 or newer, this enables the `-flto=auto` flag to parallelize processing of ltotrans units during the link process, significantly speeding up compile times. This translates to a a roughly 7-10% improvement in build times on my own test systems using GCC 15, though will probably not be as dramatic of an improvement on CI. This should have no impact on runtime performance of the agent, as the individual ltotrans units are already processed in isolation from each other even without this switch being enabled, and thus parallelizing that process has no impact on the generated code.

Austin S. Hemmelgarn committed Oct 16, 2025 at 08:59 UTC 2294cc9c23eb704456adc2fb00c695340a343b26
1 file changed +10
packaging/cmake/Modules/NetdataCompilerFlags.cmake
+10
@@ -123,6 +123,16 @@ if(USE_LTO)
123 if(HAVE_LTO)
124 message(CHECK_PASS "supported")
125 set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
126 +
127 + if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
128 + if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)
129 + list(APPEND CMAKE_C_COMPILE_OPTIONS_IPO "-flto=auto")
130 + list(APPEND CMAKE_CXX_COMPILE_OPTIONS_IPO "-flto=auto")
131 + endif()
132 + #elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
133 + #list(APPEND CMAKE_C_COMPILE_OPTIONS_IPO "-flto=thin")
134 + #list(APPEND CMAKE_CXX_COMPILE_OPTIONS_IPO "-flto=thin")
135 + endif()
136 else()
137 message(CHECK_FAIL "not supported")
138 endif()