@cryptotaxi247 / netdata-1 / commits / 1cd3ca7ad

Disable mimalloc by default / enable explicitly if needed (#19118)

Stelios Fragkakis committed Dec 3, 2024 at 01:00 UTC 1cd3ca7ad89c896db0565abd2b4d6b743c6b39d8
1 file changed +21 -2
CMakeLists.txt
+21 -2
@@ -208,8 +208,27 @@ mark_as_advanced(BUILD_FOR_PACKAGING)
208 cmake_dependent_option(FORCE_LEGACY_LIBBPF "Force usage of libbpf 0.0.9 instead of the latest version." False "ENABLE_PLUGIN_EBPF" False)
209 mark_as_advanced(FORCE_LEGACY_LIBBPF)
210
211 -cmake_dependent_option(ENABLE_MIMALLOC "Enable mimalloc allocator" ON
212 - "CMAKE_MINOR_VERSION GREATER_EQUAL 18; CMAKE_SIZEOF_VOID_P EQUAL 8; NOT OS_FREEBSD; NOT OS_MACOS; NOT OS_WINDOWS; NOT ENABLE_ADDRESS_SANITIZER" OFF)
211 +option(ENABLE_MIMALLOC "Enable mimalloc allocator" OFF)
212 +
213 +if(ENABLE_MIMALLOC)
214 + if(CMAKE_MINOR_VERSION LESS 18)
215 + message(WARNING "Mimalloc disabled: Requires CMake version 3.18 or higher.")
216 + set(ENABLE_MIMALLOC OFF CACHE BOOL "Enable mimalloc allocator" FORCE)
217 + elseif(CMAKE_SIZEOF_VOID_P LESS 8)
218 + message(WARNING "Mimalloc disabled: Only supported on 64-bit platforms.")
219 + set(ENABLE_MIMALLOC OFF CACHE BOOL "Enable mimalloc allocator" FORCE)
220 + elseif(OS_FREEBSD OR OS_MACOS OR OS_WINDOWS)
221 + message(WARNING "Mimalloc disabled: Not supported on FreeBSD, macOS, or Windows.")
222 + set(ENABLE_MIMALLOC OFF CACHE BOOL "Enable mimalloc allocator" FORCE)
223 + elseif(ENABLE_ADDRESS_SANITIZER)
224 + message(WARNING "Mimalloc disabled: Cannot be used with Address Sanitizer.")
225 + set(ENABLE_MIMALLOC OFF CACHE BOOL "Enable mimalloc allocator" FORCE)
226 + else()
227 + message(STATUS "Mimalloc is enabled.")
228 + endif()
229 +else()
230 + message(STATUS "Mimalloc is disabled.")
231 +endif()
232
233 if(ENABLE_MIMALLOC)
234 function(netdata_add_mimalloc)