[libc-commits] [libc] [libc] add snmalloc as an alternative allocator to libc (PR #122284)
via libc-commits
libc-commits at lists.llvm.org
Tue Jan 28 07:47:35 PST 2025
================
@@ -0,0 +1,119 @@
+set(SNMALLOC_USE_SELF_VENDORED_STL ON CACHE BOOL "use freestanding snmalloc setup" FORCE)
+set(SNMALLOC_BUILD_TESTING OFF CACHE BOOL "disable snmalloc tests" FORCE)
+set(SNMALLOC_HEADER_ONLY_LIBRARY ON CACHE BOOL "use snmalloc as header only library" FORCE)
+
+# Disable installation
+macro (install)
+endmacro ()
+
+add_subdirectory(${LLVM_LIBC_INCLUDE_SNMALLOC} ${CMAKE_CURRENT_BINARY_DIR}/snmalloc EXCLUDE_FROM_ALL)
+
+target_compile_options(
+ snmalloc
+ INTERFACE
+ -ffreestanding
+ -nostdinc
+ -Wno-newline-eof
+ -Wno-extra-semi
+ -Wno-unused-command-line-argument
+ -Wno-ctad-maybe-unsupported
+ # TODO: define this
+ -DSTDERR_FILENO=2
+ -DSNMALLOC_USE_PTHREAD_DESTRUCTORS
+ # include_directories does not propagate, use options instead
+ -include ${CMAKE_CURRENT_SOURCE_DIR}/override.h
+ -isystem ${COMPILER_RESOURCE_DIR}/include
+ -isystem ${LIBC_INCLUDE_DIR}
+)
+
+add_dependencies(snmalloc libc-headers)
+
+set(SNMALLOC_DEPS
+ # includes
+ libc.include.errno
+ libc.include.fcntl
+ libc.include.limits
+ libc.include.pthread
+ libc.include.stdio
+ libc.include.stdint
+ libc.include.stdlib
+ libc.include.string
+ libc.include.strings
+ libc.include.sys_mman
+ libc.include.sys_prctl
+ libc.include.sys_random
+ libc.include.sys_syscall
+ libc.include.sys_uio
+ libc.include.unistd
+ # symbols
+ libc.src.errno.errno
----------------
lntue wrote:
Thanks for the explanation! I don't think it is a problem right now, but at some point we should break the circular dependency in our cmake targets, or at least among the subdirectories.
https://github.com/llvm/llvm-project/pull/122284
More information about the libc-commits
mailing list