[PATCH] D101427: Linux support for mimalloc as a custom allocator

Michael via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 25 22:17:28 PST 2022


michaeljclark added a comment.

In D101427#3271200 <https://reviews.llvm.org/D101427#3271200>, @MaskRay wrote:

> For Linux, linking libmimalloc appears a completely orthogonal feature to me.
> llvm-project has hundreds of CMake variables and most people don't know most options.
> Having this option may just add yet another option which people don't know.

The case here is not so much adding a new option, rather it is about unmasking an option that already exists but doesn't yet support Linux. Take a look at the existing `LLVM_INTEGRATED_CRT_ALLOC `in `llvm/lib/support/CMakeLists.txt`. The other allocators are compiled from source. I think having a choice of source or built archive is reasonable but it probably should be a consistent option for all of the allocators, assuming testing is done and they are unmasked after verification. I don't see mimalloc going into the monorepo like clang, so in that respect it is different, so `ExternalProject_Add` might be an interesting option, as it is useful if the dependency is not in the repo but one wants it to be automatically fetched and built. I like that option because it can be made to "just work" by default assuming there is network connectivity. Also having an `ExternalProject_Add` git URL option allows the project url to be overridden and point to a local path, which is how I would use it. I believe the CMake build targets for `ExternalProject_Add` end up in the project namespace so you don't need to hardcode paths or at least the paths are platform-independent. The current Windows mimalloc support appears to hardcode architecture-specific paths.

Based on your link command, then perhaps I need to use something like this on Linux:

`-Wl,--push-state,${PROJECT_BINARY_DIR}/lib/libmimalloc.a,--pop-state`

I'll do some testing when I get time to look at this again. I could look at testing a patch that links mimalloc consistently between Linux and Windows perhaps using `ExternalProject_Add`. `ExternalProject_Add` would suit me and perhaps other users wanting to try mimalloc, and it seems to be used elsewhere in the LLVM build so there is precedence for using it. It would be better than the hardcoded paths which is what is there at present for the Windows mimalloc support.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101427/new/

https://reviews.llvm.org/D101427



More information about the llvm-commits mailing list