Skip to content

Commit

Permalink
Disable mimalloc by default / enable explicitly if needed (#19118)
Browse files Browse the repository at this point in the history
  • Loading branch information
stelfrag authored Dec 2, 2024
1 parent bf8aa93 commit 1cd3ca7
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,27 @@ mark_as_advanced(BUILD_FOR_PACKAGING)
cmake_dependent_option(FORCE_LEGACY_LIBBPF "Force usage of libbpf 0.0.9 instead of the latest version." False "ENABLE_PLUGIN_EBPF" False)
mark_as_advanced(FORCE_LEGACY_LIBBPF)

cmake_dependent_option(ENABLE_MIMALLOC "Enable mimalloc allocator" ON
"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)
option(ENABLE_MIMALLOC "Enable mimalloc allocator" OFF)

if(ENABLE_MIMALLOC)
if(CMAKE_MINOR_VERSION LESS 18)
message(WARNING "Mimalloc disabled: Requires CMake version 3.18 or higher.")
set(ENABLE_MIMALLOC OFF CACHE BOOL "Enable mimalloc allocator" FORCE)
elseif(CMAKE_SIZEOF_VOID_P LESS 8)
message(WARNING "Mimalloc disabled: Only supported on 64-bit platforms.")
set(ENABLE_MIMALLOC OFF CACHE BOOL "Enable mimalloc allocator" FORCE)
elseif(OS_FREEBSD OR OS_MACOS OR OS_WINDOWS)
message(WARNING "Mimalloc disabled: Not supported on FreeBSD, macOS, or Windows.")
set(ENABLE_MIMALLOC OFF CACHE BOOL "Enable mimalloc allocator" FORCE)
elseif(ENABLE_ADDRESS_SANITIZER)
message(WARNING "Mimalloc disabled: Cannot be used with Address Sanitizer.")
set(ENABLE_MIMALLOC OFF CACHE BOOL "Enable mimalloc allocator" FORCE)
else()
message(STATUS "Mimalloc is enabled.")
endif()
else()
message(STATUS "Mimalloc is disabled.")
endif()

if(ENABLE_MIMALLOC)
function(netdata_add_mimalloc)
Expand Down

0 comments on commit 1cd3ca7

Please sign in to comment.