@@ -5,14 +5,11 @@ set(CMAKE_C_STANDARD 11)
55set (CMAKE_CXX_STANDARD 17)
66
77option (MI_SECURE "Use full security mitigations (like guard pages, allocation randomization, double-free mitigation, and free-list corruption detection)" OFF )
8- option (MI_DEBUG_FULL "Use full internal heap invariant checking in DEBUG mode (expensive)" OFF )
98option (MI_PADDING "Enable padding to detect heap block overflow (always on in DEBUG or SECURE mode, or with Valgrind/ASAN)" OFF )
109option (MI_OVERRIDE "Override the standard malloc interface (i.e. define entry points for 'malloc', 'free', etc)" ON )
1110option (MI_XMALLOC "Enable abort() call on memory allocation failure by default" OFF )
1211option (MI_SHOW_ERRORS "Show error and warning messages by default (only enabled by default in DEBUG mode)" OFF )
13- option (MI_TRACK_VALGRIND "Compile with Valgrind support (adds a small overhead)" OFF )
14- option (MI_TRACK_ASAN "Compile with address sanitizer support (adds a small overhead)" OFF )
15- option (MI_TRACK_ETW "Compile with Windows event tracing (ETW) support (adds a small overhead)" OFF )
12+ option (MI_GUARDED "Build with guard pages behind certain object allocations (implies MI_NO_PADDING=ON)" OFF )
1613option (MI_USE_CXX "Use the C++ compiler to compile the library (instead of the C compiler)" OFF )
1714option (MI_OPT_ARCH "Only for optimized builds: turn on architecture specific optimizations (for arm64: '-march=armv8.1-a' (2016))" OFF )
1815option (MI_SEE_ASM "Generate assembly files" OFF )
@@ -21,14 +18,23 @@ option(MI_OSX_ZONE "Use malloc zone to override standard malloc on macO
2118option (MI_WIN_REDIRECT "Use redirection module ('mimalloc-redirect') on Windows if compiling mimalloc as a DLL" ON )
2219option (MI_WIN_USE_FIXED_TLS "Use a fixed TLS slot on Windows to avoid extra tests in the malloc fast path" OFF )
2320option (MI_LOCAL_DYNAMIC_TLS "Use local-dynamic-tls, a slightly slower but dlopen-compatible thread local storage mechanism (Unix)" OFF )
24- option (MI_LIBC_MUSL "Set this when linking with musl libc" OFF )
21+ option (MI_LIBC_MUSL "Enable this when linking with musl libc" OFF )
22+
23+ option (MI_DEBUG "Enable assertion checks (enabled by default in a debug build)" OFF )
24+ option (MI_DEBUG_INTERNAL "Enable assertion and internal invariant checks (enabled by default in a debug build)" OFF )
25+ option (MI_DEBUG_FULL "Enable assertion checks and expensive internal heap invariant checking" OFF )
26+
27+ option (MI_DEBUG_TSAN "Build with thread sanitizer (needs clang)" OFF )
28+ option (MI_DEBUG_UBSAN "Build with undefined-behavior sanitizer (needs clang++)" OFF )
29+ option (MI_TRACK_VALGRIND "Compile with Valgrind support (adds a small overhead)" OFF )
30+ option (MI_TRACK_ASAN "Compile with address sanitizer support (adds a small overhead)" OFF )
31+ option (MI_TRACK_ETW "Compile with Windows event tracing (ETW) support (adds a small overhead)" OFF )
32+
2533option (MI_BUILD_SHARED "Build shared library" ON )
2634option (MI_BUILD_STATIC "Build static library" ON )
2735option (MI_BUILD_OBJECT "Build object library" ON )
2836option (MI_BUILD_TESTS "Build test executables" ON )
29- option (MI_DEBUG_TSAN "Build with thread sanitizer (needs clang)" OFF )
30- option (MI_DEBUG_UBSAN "Build with undefined-behavior sanitizer (needs clang++)" OFF )
31- option (MI_GUARDED "Build with guard pages behind certain object allocations (implies MI_NO_PADDING=ON)" OFF )
37+
3238option (MI_SKIP_COLLECT_ON_EXIT "Skip collecting memory on program exit" OFF )
3339option (MI_NO_PADDING "Force no use of padding even in DEBUG mode etc." OFF )
3440option (MI_INSTALL_TOPLEVEL "Install directly into $CMAKE_INSTALL_PREFIX instead of PREFIX/lib/mimalloc-version" OFF )
@@ -97,7 +103,7 @@ endif()
97103
98104message (STATUS "" )
99105if (NOT CMAKE_BUILD_TYPE )
100- if ("${CMAKE_BINARY_DIR} " MATCHES ".*((D|d)ebug|asan|tsan|ubsan|valgrind)$" OR MI_DEBUG_FULL )
106+ if ("${CMAKE_BINARY_DIR} " MATCHES ".*((D|d)ebug|asan|tsan|ubsan|valgrind)$" )
101107 message (STATUS "No build type selected, default to 'Debug'" )
102108 set (CMAKE_BUILD_TYPE "Debug" )
103109 else ()
@@ -296,8 +302,18 @@ if (MI_SKIP_COLLECT_ON_EXIT)
296302endif ()
297303
298304if (MI_DEBUG_FULL)
299- message (STATUS "Set debug level to full internal invariant checking (MI_DEBUG_FULL=ON)" )
300- list (APPEND mi_defines MI_DEBUG=3) # full invariant checking
305+ message (STATUS "Set debug level to full assertion and internal invariant checking (MI_DEBUG_FULL=ON, expensive)" )
306+ list (APPEND mi_defines MI_DEBUG=3) # full invariant checking (mi_assert, mi_assert_internal, and mi_assert_expensive)
307+ elseif (MI_DEBUG_INTERNAL)
308+ message (STATUS "Set debug level to internal assertion and invariant checking (MI_DEBUG_INTERNAL=ON)" )
309+ list (APPEND mi_defines MI_DEBUG=2) # invariant checking (mi_assert and mi_assert_internal)
310+ elseif (MI_DEBUG)
311+ message (STATUS "Set debug level to assertion checking (MI_DEBUG=ON)" )
312+ list (APPEND mi_defines MI_DEBUG=1) # assertion checking (mi_assert)
313+ elseif (CMAKE_BUILD_TYPE MATCHES "Debug" )
314+ message (STATUS "Set debug level to internal assertion and invariant checking (CMAKE_BUILD_TYPE=Debug)" )
315+ set (MI_DEBUG_INTERNAL ON )
316+ list (APPEND mi_defines MI_DEBUG=2) # invariant checking (mi_assert and mi_assert_internal)
301317endif ()
302318
303319if (MI_NO_PADDING)
0 commit comments