mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-21 06:19:31 +03:00
Add option to disable redirect
This commit is contained in:
parent
f2712f4a8f
commit
49d919af78
2 changed files with 11 additions and 2 deletions
|
@ -22,6 +22,7 @@ option(MI_BUILD_TESTS "Build test executables" ON)
|
||||||
option(MI_DEBUG_TSAN "Build with thread sanitizer (needs clang)" OFF)
|
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_UBSAN "Build with undefined-behavior sanitizer (needs clang++)" OFF)
|
||||||
option(MI_SKIP_COLLECT_ON_EXIT, "Skip collecting memory on program exit" OFF)
|
option(MI_SKIP_COLLECT_ON_EXIT, "Skip collecting memory on program exit" OFF)
|
||||||
|
option(MI_DISABLE_REDIRECT "Do not use mimalloc-redirect on Windows (for shared libraries)" OFF)
|
||||||
|
|
||||||
# deprecated options
|
# deprecated options
|
||||||
option(MI_CHECK_FULL "Use full internal invariant checking in DEBUG mode (deprecated, use MI_DEBUG_FULL instead)" OFF)
|
option(MI_CHECK_FULL "Use full internal invariant checking in DEBUG mode (deprecated, use MI_DEBUG_FULL instead)" OFF)
|
||||||
|
@ -184,6 +185,14 @@ if(MI_USE_CXX)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (MI_DISABLE_REDIRECT)
|
||||||
|
if (NOT WIN32 OR NOT MI_SHARED_LIB)
|
||||||
|
message(WARNING "Disabling redirect only affects shared libraries on windows")
|
||||||
|
endif()
|
||||||
|
message(STATUS "Disabled mimalloc-redirect (MI_DISABLE_REDIRECT=ON)")
|
||||||
|
list(APPEND mi_defines MI_DISABLE_REDIRECT)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Compiler flags
|
# Compiler flags
|
||||||
if(CMAKE_C_COMPILER_ID MATCHES "AppleClang|Clang|GNU")
|
if(CMAKE_C_COMPILER_ID MATCHES "AppleClang|Clang|GNU")
|
||||||
list(APPEND mi_cflags -Wall -Wextra -Wno-unknown-pragmas -fvisibility=hidden)
|
list(APPEND mi_cflags -Wall -Wextra -Wno-unknown-pragmas -fvisibility=hidden)
|
||||||
|
@ -304,7 +313,7 @@ if(MI_BUILD_SHARED)
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:${mi_install_incdir}>
|
$<INSTALL_INTERFACE:${mi_install_incdir}>
|
||||||
)
|
)
|
||||||
if(WIN32)
|
if(WIN32 AND NOT MI_DISABLE_REDIRECT)
|
||||||
# On windows copy the mimalloc redirection dll too.
|
# On windows copy the mimalloc redirection dll too.
|
||||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||||
set(MIMALLOC_REDIRECT_SUFFIX "32")
|
set(MIMALLOC_REDIRECT_SUFFIX "32")
|
||||||
|
|
|
@ -490,7 +490,7 @@ mi_decl_nodiscard bool mi_is_redirected(void) mi_attr_noexcept {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Communicate with the redirection module on Windows
|
// Communicate with the redirection module on Windows
|
||||||
#if defined(_WIN32) && defined(MI_SHARED_LIB)
|
#if defined(_WIN32) && defined(MI_SHARED_LIB) && !defined(MI_DISABLE_REDIRECT)
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue