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

Nick Desaulniers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 21 19:14:58 PDT 2022


nickdesaulniers added a comment.
Herald added a subscriber: StephenFan.
Herald added a project: All.

This is patch is interesting to me because builds of llvm statically linked against musl have numerous memory allocation related functions in their top 20 functions sampled in builds of the Linux kernel.

If I apply the following diff on top of this diff, I can build rpmalloc into LLVM:

  diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
  index 96cd28afe80b..bd5b73361d2b 100644
  --- a/llvm/CMakeLists.txt
  +++ b/llvm/CMakeLists.txt
  @@ -600,7 +600,8 @@ if(LLVM_INTEGRATED_CRT_ALLOC)
     if(NOT (CMAKE_SYSTEM_NAME MATCHES "(Linux|Windows)"))
       message(FATAL_ERROR "LLVM_INTEGRATED_CRT_ALLOC is only supported on Windows and Linux.")
     elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  -    if(NOT (LLVM_INTEGRATED_CRT_ALLOC MATCHES "mimalloc$"))
  +    if(LLVM_INTEGRATED_CRT_ALLOC MATCHES "rpmalloc$")
  +    elseif(NOT (LLVM_INTEGRATED_CRT_ALLOC MATCHES "mimalloc$"))
         message(FATAL_ERROR "LLVM_INTEGRATED_CRT_ALLOC currently only supports mimalloc on Linux!")
       elseif(LLVM_BUILD_LLVM_DYLIB AND LLVM_LINK_LLVM_DYLIB)
         message(FATAL_ERROR "LLVM_INTEGRATED_CRT_ALLOC cannot be used with LLVM_LINK_LLVM_DYLIB on Linux!")
  diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
  index 37743a583860..5d84e3040c11 100644
  --- a/llvm/lib/Support/CMakeLists.txt
  +++ b/llvm/lib/Support/CMakeLists.txt
  @@ -88,6 +88,9 @@ if(LLVM_INTEGRATED_CRT_ALLOC)
   
     if(LLVM_INTEGRATED_CRT_ALLOC MATCHES "rpmalloc$")
       add_definitions(-DENABLE_OVERRIDE -DENABLE_PRELOAD)
  +    set_source_files_properties(
  +      "${LLVM_INTEGRATED_CRT_ALLOC}/rpmalloc/rpmalloc.c"
  +      PROPERTIES COMPILE_FLAGS -Wno-static-in-inline)
       set(ALLOCATOR_FILES "${LLVM_INTEGRATED_CRT_ALLOC}/rpmalloc/rpmalloc.c")
     elseif(LLVM_INTEGRATED_CRT_ALLOC MATCHES "snmalloc$")
       set(ALLOCATOR_FILES "${LLVM_INTEGRATED_CRT_ALLOC}/src/snmalloc/override/new.cc")

which is simply meant to be a quick hack to allow me to pass `-DLLVM_INTEGRATED_CRT_ALLOC=/path/to/rpmalloc` to my cmake invocation used to configure llvm.  Result segfaults pretty quickly though trying to run the llvm unit tests though. :(


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