-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add mimalloc allocator (#364)
* mimalloc depdence * reslove comment * check asan enabled or tsan enabled * comment * comment * add static and shared opt * comment * change add to target * reslove commit and put mimalloc link first * add necessary annotation * reslove comment * reslove comment
- Loading branch information
Showing
6 changed files
with
50 additions
and
1 deletion.
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
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,31 @@ | ||
include(FetchContent) | ||
FetchContent_Declare( | ||
mimalloc | ||
GIT_REPOSITORY https://github.com/microsoft/mimalloc.git | ||
GIT_TAG v2.1.7 | ||
GIT_SHALLOW TRUE | ||
) | ||
# If MI_OVERRIDE is ON then operator new and delete will be override not only malloc and free | ||
# ref: https://github.com/microsoft/mimalloc/issues/535 | ||
set(MI_OVERRIDE ON) | ||
set(MI_BUILD_TESTS OFF) | ||
if (BUILD_SHARED_LIBS) | ||
set(MI_BUILD_SHARED ON) | ||
else () | ||
set(MI_BUILD_SHARED OFF) | ||
endif() | ||
|
||
if(CRANE_ADDRESS_SANITIZER) | ||
set(MI_TRACK_ASAN ON) | ||
message(STATUS "Set ASAN enable in mimalloc") | ||
endif() | ||
|
||
FetchContent_MakeAvailable(mimalloc) | ||
|
||
if (BUILD_SHARED_LIBS) | ||
add_library(dev_mimalloc ALIAS mimalloc) | ||
else () | ||
# When building with static library, make sure that link it as the first object file. | ||
# ref: https://github.com/microsoft/mimalloc?tab=readme-ov-file#static-override | ||
add_library(dev_mimalloc ALIAS mimalloc-static) | ||
endif() |
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