[libc-commits] [PATCH] D106502: [libc] add option to use SCUDO as the allocator

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Jul 21 15:22:04 PDT 2021


michaelrj created this revision.
michaelrj added reviewers: sivachandra, cryptoad.
Herald added subscribers: libc-commits, ecnelises, tschuett, mgorny.
Herald added a project: libc-project.
michaelrj requested review of this revision.

This patch adds LLVM_LIBC_INCLUDE_SCUDO as a flag. When enabled it
should link in the standalone version of SCUDO as the allocator for LLVM
libc.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106502

Files:
  libc/CMakeLists.txt
  libc/cmake/modules/LLVMLibCLibraryRules.cmake
  libc/lib/CMakeLists.txt


Index: libc/lib/CMakeLists.txt
===================================================================
--- libc/lib/CMakeLists.txt
+++ libc/lib/CMakeLists.txt
@@ -1,7 +1,15 @@
+set(SCUDO_DEP "")
+
+if(LLVM_LIBC_INCLUDE_SCUDO)
+  list(APPEND SCUDO_DEP RTScudoStandalone.${LIBC_TARGET_ARCHITECTURE})
+endif()
+
 add_entrypoint_library(
   llvmlibc
   DEPENDS
   ${TARGET_LLVMLIBC_ENTRYPOINTS}
+  EXT_DEPS
+  ${SCUDO_DEP}
 )
 
 if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
Index: libc/cmake/modules/LLVMLibCLibraryRules.cmake
===================================================================
--- libc/cmake/modules/LLVMLibCLibraryRules.cmake
+++ libc/cmake/modules/LLVMLibCLibraryRules.cmake
@@ -52,7 +52,7 @@
     "ENTRYPOINT_LIBRARY"
     "" # No optional arguments
     "" # No single value arguments
-    "DEPENDS" # Multi-value arguments
+    "DEPENDS;EXT_DEPS" # Multi-value arguments
     ${ARGN}
   )
   if(NOT ENTRYPOINT_LIBRARY_DEPENDS)
@@ -76,6 +76,11 @@
   foreach(dep IN LISTS all_deps)
     list(APPEND objects $<TARGET_OBJECTS:${dep}>)
   endforeach(dep)
+
+  foreach(dep IN LISTS ENTRYPOINT_LIBRARY_EXT_DEPS)
+    list(APPEND objects $<TARGET_OBJECTS:${dep}>)
+  endforeach(dep)
+
   add_library(
     ${target_name}
     STATIC
Index: libc/CMakeLists.txt
===================================================================
--- libc/CMakeLists.txt
+++ libc/CMakeLists.txt
@@ -73,6 +73,13 @@
     (pass -DLLVM_LIBC_ENABLE_LINTING=ON to cmake).")
 endif()
 
+option(LLVM_LIBC_INCLUDE_SCUDO "Include the SCUDO standalone as the allocator for LLVM libc" OFF)
+if(LLVM_LIBC_INCLUDE_SCUDO)
+  if (NOT "compiler-rt" IN_LIST LLVM_ENABLE_PROJECTS)
+    message(FATAL_ERROR "SCUDO cannot be included without adding compiler-rt to LLVM_ENABLE_PROJECTS")
+  endif()
+endif()
+
 include(CMakeParseArguments)
 include(LLVMLibCRules)
 include(LLVMLibCCheckCpuFeatures)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106502.360619.patch
Type: text/x-patch
Size: 1859 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20210721/d64556cf/attachment.bin>


More information about the libc-commits mailing list