[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 17:20:55 PST 2022


michaeljclark added a comment.

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

> I am interested in having this for Linux, too :) What is blocking this?

IDK. I just posted the patch for review because I thought folks might find it useful.

I did not get to the bottom of why it was not working (for me at least) with `-DLLVM_LINK_LLVM_DYLIB=ON`. It is so long ago I can't remember what the issue was. It may have been a segfault in the glibc dynamic linker. Of course there is musl libc to think about and test too. It might be that we need to build mimalloc shared if `-DLLVM_BUILD_LLVM_DYLIB=ON` and link mimalloc shared if `-DLLVM_LINK_LLVM_DYLIB=ON`

I needed to add the following to build latest LLVM with latest mimalloc as the `CMakeLists.txt` might not have been building `mimalloc-static` by default.

  diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
  index dc7c205a6904..87cb029f97c1 100644
  --- a/llvm/lib/Support/CMakeLists.txt
  +++ b/llvm/lib/Support/CMakeLists.txt
  @@ -95,6 +95,9 @@ if(LLVM_INTEGRATED_CRT_ALLOC)
     elseif(LLVM_INTEGRATED_CRT_ALLOC MATCHES "mimalloc$")
       if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
         set(MI_OVERRIDE ON CACHE BOOL "Override the standard malloc")
  +      set(MI_BUILD_STATIC ON CACHE BOOL "Build static library")
  +      set(MI_BUILD_SHARED OFF CACHE BOOL "Build shared library")
  +      set(MI_BUILD_TESTS OFF CACHE BOOL "Build tests")
         add_subdirectory(${LLVM_INTEGRATED_CRT_ALLOC} mimalloc)
         export(EXPORT mimalloc)
         set(system_libs ${system_libs} "mimalloc-static")


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