mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-08 04:18:42 +03:00
add tracing on linux and freebsd
This commit is contained in:
parent
e125c04081
commit
ea75c745e1
4 changed files with 63 additions and 7 deletions
|
@ -21,10 +21,14 @@ option(MI_BUILD_OBJECT "Build object library" ON)
|
|||
option(MI_BUILD_TESTS "Build test executables" ON)
|
||||
option(MI_DEBUG_TSAN "Build with thread sanitizer (needs clang)" OFF)
|
||||
option(MI_DEBUG_UBSAN "Build with undefined-behavior sanitizer (needs clang++)" OFF)
|
||||
option(MI_DEBUG_TRACE "Store allocation stack trace in each heap block to debug heap block overflows or corruption" OFF)
|
||||
option(MI_CHECK_FULL "Use full internal invariant checking in DEBUG mode (deprecated, use MI_DEBUG_FULL instead)" OFF)
|
||||
option(MI_INSTALL_TOPLEVEL "Install directly into $CMAKE_INSTALL_PREFIX instead of PREFIX/lib/mimalloc-version" OFF)
|
||||
option(MI_USE_LIBATOMIC "Explicitly link with -latomic (on older systems)" OFF)
|
||||
|
||||
set(MI_PADDING_EXTRA 0 CACHE STRING "Specify extra bytes for padding in each heap block (to debug heap block overflows)")
|
||||
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include("cmake/mimalloc-config-version.cmake")
|
||||
|
||||
|
@ -120,6 +124,21 @@ if(MI_DEBUG_FULL)
|
|||
list(APPEND mi_defines MI_DEBUG=3) # full invariant checking
|
||||
endif()
|
||||
|
||||
if(MI_DEBUG_TRACE)
|
||||
if (APPLE)
|
||||
message(WARNING "Cannot enable MI_DEBUG_TRACE on Apple")
|
||||
set(MI_DEBUG_TRACE OFF)
|
||||
else()
|
||||
message(STATUS "Enable allocation trace in each heap block (MI_DEBUG_TRACE=ON)")
|
||||
list(APPEND mi_defines MI_DEBUG_TRACE=1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MI_PADDING_EXTRA)
|
||||
message(STATUS "Add extra debug padding to each heap block (MI_PADDING_EXTRA=${MI_PADDING_EXTRA})")
|
||||
list(APPEND mi_defines MI_PADDING_EXTRA=${MI_PADDING_EXTRA})
|
||||
endif()
|
||||
|
||||
if(NOT MI_PADDING)
|
||||
message(STATUS "Disable padding of heap blocks in debug mode (MI_PADDING=OFF)")
|
||||
list(APPEND mi_defines MI_PADDING=0)
|
||||
|
@ -212,9 +231,15 @@ if(WIN32)
|
|||
else()
|
||||
if(NOT ${CMAKE_C_COMPILER} MATCHES "android")
|
||||
list(APPEND mi_libraries pthread)
|
||||
find_library(LIBRT rt)
|
||||
if(LIBRT)
|
||||
list(APPEND mi_libraries ${LIBRT})
|
||||
find_library(MI_LIBRT rt)
|
||||
if(MI_LIBRT)
|
||||
list(APPEND mi_libraries ${MI_LIBRT})
|
||||
endif()
|
||||
if(MI_DEBUG_TRACE)
|
||||
find_library(MI_LIBEXECINFO NAMES execinfo)
|
||||
if (MI_LIBEXECINFO) # on freeBSD
|
||||
list(APPEND mi_libraries ${MI_LIBEXECINFO})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
@ -270,6 +295,7 @@ else()
|
|||
message(STATUS "C Compiler : ${CMAKE_C_COMPILER}")
|
||||
endif()
|
||||
message(STATUS "Compiler flags : ${mi_cflags}")
|
||||
message(STATUS "Compiler defines : ${mi_defines}")
|
||||
message(STATUS "Build targets : ${mi_build_targets}")
|
||||
message(STATUS "")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue