-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
53 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
include(ExternalProject) | ||
|
||
set(MIMALLOC_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/mimalloc/install) | ||
|
||
ExternalProject_Add( | ||
mimalloc | ||
PREFIX mimalloc | ||
GIT_REPOSITORY https://github.com/microsoft/mimalloc.git | ||
GIT_TAG 81bd1b70b086d872bda515f99cfcf0d78f8ac86c # dev branch v1.6.3 + #240 | ||
INSTALL_DIR ${MIMALLOC_INSTALL_DIR} | ||
# We need to patch mimalloc's default mmap ranges as they interfere with | ||
# sanitizers | ||
# https://github.com/llvm/llvm-project/blob/master/compiler-rt/lib/tsan/rtl/tsan_platform.h#L67-L72 | ||
PATCH_COMMAND | ||
patch -p1 < | ||
${CMAKE_CURRENT_SOURCE_DIR}/mimalloc-sanitizer-compatibility.patch | ||
CMAKE_ARGS | ||
"-DCMAKE_INSTALL_PREFIX=${MIMALLOC_INSTALL_DIR};-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE};-DMI_LOCAL_DYNAMIC_TLS=ON;" | ||
) | ||
|
||
set(IS_DEBUG "") | ||
string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LC) | ||
if(CMAKE_BUILD_TYPE_LC STREQUAL "debug") | ||
set(IS_DEBUG "-debug") | ||
endif() | ||
|
||
set(MIMALLOC_STATIC_LIB | ||
${MIMALLOC_INSTALL_DIR}/lib/mimalloc-1.6/libmimalloc${IS_DEBUG}.a pthread) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
diff --git a/src/os.c b/src/os.c | ||
index f33cfbc..536269e 100644 | ||
--- a/src/os.c | ||
+++ b/src/os.c | ||
@@ -405,7 +405,8 @@ static void* mi_unix_mmap(void* addr, size_t size, size_t try_alignment, int pro | ||
|
||
// On 64-bit systems, we can do efficient aligned allocation by using | ||
// the 4TiB to 30TiB area to allocate them. | ||
-#if (MI_INTPTR_SIZE >= 8) && (defined(_WIN32) || (defined(MI_OS_USE_MMAP) && !defined(MAP_ALIGNED))) | ||
+// #if (MI_INTPTR_SIZE >= 8) && (defined(_WIN32) || (defined(MI_OS_USE_MMAP) && !defined(MAP_ALIGNED))) | ||
+#if 0 | ||
static volatile mi_decl_cache_align _Atomic(uintptr_t) aligned_base; | ||
|
||
// Return a 4MiB aligned address that is probably available |