[libc-commits] [libc] [libc] add snmalloc as an alternative allocator to libc (PR #122284)

Daniel Thornburgh via libc-commits libc-commits at lists.llvm.org
Wed Jan 29 14:01:17 PST 2025


================
@@ -324,7 +324,49 @@ add_entrypoint_object(
 )
 
 if(NOT LIBC_TARGET_OS_IS_BAREMETAL AND NOT LIBC_TARGET_OS_IS_GPU)
-  if(LLVM_LIBC_INCLUDE_SCUDO)
----------------
mysterymath wrote:

What happens if `LLVM_LIBC_INCLUDE_SCUDO` and `LLVM_LIBC_INCLUDE_SNMALLOC` are used at the same time?

We now have four allocator options usable with the LLVM-libc:
  - snmalloc and scudo, which are stubs that wrap external libraries
  - baremetal malloc, which is a full malloc implementation
  - gpu malloc, which is a set of wrappers using RPCs

I'm planning to lift baremetal malloc out of baremetal in the near future; it isn't all that baremetal specific, since it's based on dlmalloc, which is useable both on embedded and hosted OS systems.  With that there will be three allocator options for Linux and friends, so this seems like a good time to introduce a switch-like option (`LLVM_LIBC_ALLOCATOR`?) to at least make it impossible to simultaneously specify two different allocators.

@nickdesaulniers: if we do this, would we need to keep `LLVM_LIBC_INCLUDE_SCUDO` for backcompat?

https://github.com/llvm/llvm-project/pull/122284


More information about the libc-commits mailing list