-
-
Notifications
You must be signed in to change notification settings - Fork 16
mimalloc integration #2708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
mimalloc integration #2708
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| /vendor/** linguist-generated=true | ||
| vendor/*.mask text eol=lf |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,3 +12,6 @@ _deps | |
| Brewfile.lock.json | ||
| .DS_Store | ||
| .cache | ||
| out/ | ||
| CMakeSettings.json | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.24) | |||||
| project(core VERSION 0.0.0 LANGUAGES C CXX ASM_MASM DESCRIPTION "Sourcemeta Core") | ||||||
| list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") | ||||||
|
|
||||||
| # Options | ||||||
| #Options | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| option(SOURCEMETA_CORE_LANG_PREPROCESSOR "Build the Sourcemeta Core language preprocessor library" ON) | ||||||
| option(SOURCEMETA_CORE_LANG_IO "Build the Sourcemeta Core language I/O library" ON) | ||||||
| option(SOURCEMETA_CORE_LANG_PROCESS "Build the Sourcemeta Core language Process library" ON) | ||||||
|
|
@@ -55,19 +55,29 @@ option(SOURCEMETA_CORE_CONTRIB_GOOGLEBENCHMARK "Build the GoogleBenchmark librar | |||||
|
|
||||||
| include(Sourcemeta) | ||||||
|
|
||||||
| # Don't force downstream consumers on this | ||||||
| sourcemeta_option_enum( | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If |
||||||
| NAME SOURCEMETA_CORE_ALLOCATOR | ||||||
| DEFAULT "system" | ||||||
| CHOICES "system" "mimalloc" | ||||||
| DESCRIPTION "Memory allocator to use: system or mimalloc") | ||||||
|
|
||||||
| #Don't force downstream consumers on this | ||||||
| if(PROJECT_IS_TOP_LEVEL) | ||||||
| sourcemeta_enable_simd() | ||||||
| endif() | ||||||
|
|
||||||
| # Enable the sanitizers before defining any target | ||||||
| #Enable the sanitizers before defining any target | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like in general most comments lost the initial space for some reason?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes i apologise for the missing spaces, while i was manually reviewing changes i instinctually removed the space out of habit. Im gonna review once again and revert these in the next commit. |
||||||
| if(SOURCEMETA_CORE_ADDRESS_SANITIZER) | ||||||
| sourcemeta_sanitizer(TYPE address) | ||||||
| elseif(SOURCEMETA_CORE_UNDEFINED_SANITIZER) | ||||||
| sourcemeta_sanitizer(TYPE undefined) | ||||||
| endif() | ||||||
|
|
||||||
| # TODO: Turn this into a re-usable utility CMake function | ||||||
| if(SOURCEMETA_CORE_ALLOCATOR STREQUAL "mimalloc") | ||||||
| find_package(Mimalloc REQUIRED) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: The new SOURCEMETA_CORE_ALLOCATOR option is declared at the top-level and immediately drives Prompt for AI agents |
||||||
| endif() | ||||||
|
|
||||||
| #TODO : Turn this into a re - usable utility CMake function | ||||||
| if(SOURCEMETA_CORE_INSTALL) | ||||||
| include(GNUInstallDirs) | ||||||
| include(CMakePackageConfigHelpers) | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| if(NOT Mimalloc_FOUND) | ||
| set(MIMALLOC_DIR "${PROJECT_SOURCE_DIR}/vendor/mimalloc") | ||
|
|
||
| set(MI_BUILD_SHARED OFF CACHE BOOL "" FORCE) | ||
| set(MI_BUILD_OBJECT OFF CACHE BOOL "" FORCE) | ||
| set(MI_BUILD_TESTS OFF CACHE BOOL "" FORCE) | ||
| set(MI_OVERRIDE ON CACHE BOOL "" FORCE) | ||
|
|
||
| add_subdirectory( | ||
| "${MIMALLOC_DIR}" | ||
| "${CMAKE_CURRENT_BINARY_DIR}/mimalloc" EXCLUDE_FROM_ALL) | ||
|
|
||
| if(TARGET mimalloc-static) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would happen on shared builds? |
||
| set_target_properties(mimalloc-static | ||
| PROPERTIES COMPILE_WARNING_AS_ERROR OFF) | ||
| add_library(Mimalloc::Mimalloc ALIAS mimalloc-static) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: When a static mimalloc with MI_OVERRIDE is linked as an ordinary archive (not whole-archive), the linker may only pull in the objects that resolve currently-undefined symbols, so the malloc/free override can silently fail on some platforms or link orders. Consider propagating whole-archive linking (e.g. target_link_options with $<LINK_LIBRARY:WHOLE_ARCHIVE,mimalloc-static>, or linking the benchmark executable with --whole-archive) so the override that the benchmark gains depend on is guaranteed and reproducible. Prompt for AI agents |
||
| set(Mimalloc_FOUND ON) | ||
| endif() | ||
| endif() | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.