mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-06 23:39:31 +03:00
Merge branch 'dev' into dev-slice
This commit is contained in:
commit
c9eafa8536
1 changed files with 25 additions and 20 deletions
|
@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD 17)
|
||||||
option(MI_SECURE "Use full security mitigations (like guard pages, allocation randomization, double-free mitigation, and free-list corruption detection)" OFF)
|
option(MI_SECURE "Use full security mitigations (like guard pages, allocation randomization, double-free mitigation, and free-list corruption detection)" OFF)
|
||||||
option(MI_DEBUG_FULL "Use full internal heap invariant checking in DEBUG mode (expensive)" OFF)
|
option(MI_DEBUG_FULL "Use full internal heap invariant checking in DEBUG mode (expensive)" OFF)
|
||||||
option(MI_PADDING "Enable padding to detect heap block overflow (always on in DEBUG or SECURE mode, or with Valgrind/ASAN)" OFF)
|
option(MI_PADDING "Enable padding to detect heap block overflow (always on in DEBUG or SECURE mode, or with Valgrind/ASAN)" OFF)
|
||||||
option(MI_OVERRIDE "Override the standard malloc interface (e.g. define entry points for malloc() etc)" ON)
|
option(MI_OVERRIDE "Override the standard malloc interface (i.e. define entry points for 'malloc', 'free', etc)" ON)
|
||||||
option(MI_XMALLOC "Enable abort() call on memory allocation failure by default" OFF)
|
option(MI_XMALLOC "Enable abort() call on memory allocation failure by default" OFF)
|
||||||
option(MI_SHOW_ERRORS "Show error and warning messages by default (only enabled by default in DEBUG mode)" OFF)
|
option(MI_SHOW_ERRORS "Show error and warning messages by default (only enabled by default in DEBUG mode)" OFF)
|
||||||
option(MI_TRACK_VALGRIND "Compile with Valgrind support (adds a small overhead)" OFF)
|
option(MI_TRACK_VALGRIND "Compile with Valgrind support (adds a small overhead)" OFF)
|
||||||
|
@ -19,7 +19,7 @@ option(MI_SEE_ASM "Generate assembly files" OFF)
|
||||||
option(MI_OSX_INTERPOSE "Use interpose to override standard malloc on macOS" ON)
|
option(MI_OSX_INTERPOSE "Use interpose to override standard malloc on macOS" ON)
|
||||||
option(MI_OSX_ZONE "Use malloc zone to override standard malloc on macOS" ON)
|
option(MI_OSX_ZONE "Use malloc zone to override standard malloc on macOS" ON)
|
||||||
option(MI_WIN_REDIRECT "Use redirection module ('mimalloc-redirect') on Windows if compiling mimalloc as a DLL" ON)
|
option(MI_WIN_REDIRECT "Use redirection module ('mimalloc-redirect') on Windows if compiling mimalloc as a DLL" ON)
|
||||||
option(MI_LOCAL_DYNAMIC_TLS "Use slightly slower, dlopen-compatible TLS mechanism (Unix)" OFF)
|
option(MI_LOCAL_DYNAMIC_TLS "Use local-dynamic-tls, a slightly slower but dlopen-compatible thread local storage mechanism (Unix)" OFF)
|
||||||
option(MI_LIBC_MUSL "Set this when linking with musl libc" OFF)
|
option(MI_LIBC_MUSL "Set this when linking with musl libc" OFF)
|
||||||
option(MI_BUILD_SHARED "Build shared library" ON)
|
option(MI_BUILD_SHARED "Build shared library" ON)
|
||||||
option(MI_BUILD_STATIC "Build static library" ON)
|
option(MI_BUILD_STATIC "Build static library" ON)
|
||||||
|
@ -162,8 +162,8 @@ if(MI_TRACK_VALGRIND)
|
||||||
CHECK_INCLUDE_FILES("valgrind/valgrind.h;valgrind/memcheck.h" MI_HAS_VALGRINDH)
|
CHECK_INCLUDE_FILES("valgrind/valgrind.h;valgrind/memcheck.h" MI_HAS_VALGRINDH)
|
||||||
if (NOT MI_HAS_VALGRINDH)
|
if (NOT MI_HAS_VALGRINDH)
|
||||||
set(MI_TRACK_VALGRIND OFF)
|
set(MI_TRACK_VALGRIND OFF)
|
||||||
message(WARNING "Cannot find the 'valgrind/valgrind.h' and 'valgrind/memcheck.h' -- install valgrind first")
|
message(WARNING "Cannot find the 'valgrind/valgrind.h' and 'valgrind/memcheck.h' -- install valgrind first?")
|
||||||
message(STATUS "Compile **without** Valgrind support (MI_TRACK_VALGRIND=OFF)")
|
message(STATUS "Disabling Valgrind support (MI_TRACK_VALGRIND=OFF)")
|
||||||
else()
|
else()
|
||||||
message(STATUS "Compile with Valgrind support (MI_TRACK_VALGRIND=ON)")
|
message(STATUS "Compile with Valgrind support (MI_TRACK_VALGRIND=ON)")
|
||||||
list(APPEND mi_defines MI_TRACK_VALGRIND=1)
|
list(APPEND mi_defines MI_TRACK_VALGRIND=1)
|
||||||
|
@ -317,26 +317,31 @@ if(MI_LIBC_MUSL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MI_WIN_USE_FLS)
|
if(MI_WIN_USE_FLS)
|
||||||
message(STATUS "Use the Fiber API to detect thread termination")
|
message(STATUS "Use the Fiber API to detect thread termination (MI_WIN_USE_FLS=ON)")
|
||||||
list(APPEND mi_defines MI_WIN_USE_FLS=1)
|
list(APPEND mi_defines MI_WIN_USE_FLS=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Determine architecture
|
# Determine architecture
|
||||||
set(MI_OPT_ARCH_FLAGS "")
|
set(MI_OPT_ARCH_FLAGS "")
|
||||||
set(MI_ARCH "unknown")
|
set(MI_ARCH "unknown")
|
||||||
if(APPLE)
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86|i[3456]86" OR CMAKE_GENERATOR_PLATFORM MATCHES "x86|Win32")
|
||||||
list(FIND CMAKE_OSX_ARCHITECTURES "x86_64" x64_index)
|
set(MI_ARCH "x86")
|
||||||
list(FIND CMAKE_OSX_ARCHITECTURES "arm64" arm64_index)
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|x64|amd64|AMD64" OR CMAKE_GENERATOR_PLATFORM STREQUAL "x64")
|
||||||
if(x64_index GREATER_EQUAL 0)
|
|
||||||
set(MI_ARCH "x64")
|
set(MI_ARCH "x64")
|
||||||
elseif(arm64_index GREATER_EQUAL 0)
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64|armv8.?" OR CMAKE_GENERATOR_PLATFORM MATCHES "ARM64")
|
||||||
set(MI_ARCH "arm64")
|
set(MI_ARCH "arm64")
|
||||||
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
|
||||||
|
set(MI_ARCH "arm32")
|
||||||
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "riscv")
|
||||||
|
if(CMAKE_SIZEOF_VOID_P==4)
|
||||||
|
set(MI_ARCH "riscv32")
|
||||||
|
else()
|
||||||
|
set(MI_ARCH "riscv64")
|
||||||
endif()
|
endif()
|
||||||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_GENERATOR_PLATFORM STREQUAL "x64")
|
else()
|
||||||
set(MI_ARCH "x64")
|
set(MI_ARCH ${CMAKE_SYSTEM_PROCESSOR})
|
||||||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64" OR CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64")
|
|
||||||
set(MI_ARCH "arm64")
|
|
||||||
endif()
|
endif()
|
||||||
|
message(STATUS "Architecture: ${MI_ARCH}")
|
||||||
|
|
||||||
# Check /proc/cpuinfo for an SV39 MMU and limit the virtual address bits.
|
# Check /proc/cpuinfo for an SV39 MMU and limit the virtual address bits.
|
||||||
# (this will skip the aligned hinting in that case. Issue #939, #949)
|
# (this will skip the aligned hinting in that case. Issue #939, #949)
|
||||||
|
@ -528,12 +533,12 @@ if(MI_BUILD_SHARED)
|
||||||
)
|
)
|
||||||
if(WIN32 AND MI_WIN_REDIRECT)
|
if(WIN32 AND MI_WIN_REDIRECT)
|
||||||
# On windows, link and copy the mimalloc redirection dll too.
|
# On windows, link and copy the mimalloc redirection dll too.
|
||||||
if(MI_ARCH STREQUAL "arm64")
|
if(MI_ARCH STREQUAL "x64")
|
||||||
set(MIMALLOC_REDIRECT_SUFFIX "-arm64")
|
set(MIMALLOC_REDIRECT_SUFFIX "")
|
||||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
elseif(MI_ARCH STREQUAL "x86")
|
||||||
set(MIMALLOC_REDIRECT_SUFFIX "32")
|
set(MIMALLOC_REDIRECT_SUFFIX "32")
|
||||||
else()
|
else()
|
||||||
set(MIMALLOC_REDIRECT_SUFFIX "")
|
set(MIMALLOC_REDIRECT_SUFFIX "-${MI_ARCH}") # -arm64 etc.
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(mimalloc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/bin/mimalloc-redirect${MIMALLOC_REDIRECT_SUFFIX}.lib)
|
target_link_libraries(mimalloc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/bin/mimalloc-redirect${MIMALLOC_REDIRECT_SUFFIX}.lib)
|
||||||
|
|
Loading…
Add table
Reference in a new issue