[libc-commits] [libc] da06d17 - [libc] add option to use SCUDO as the allocator

Michael Jones via libc-commits libc-commits at lists.llvm.org
Fri Jul 23 10:36:15 PDT 2021


Author: Michael Jones
Date: 2021-07-23T17:36:09Z
New Revision: da06d1795ab0e004ec90d24b053a82a3db94df49

URL: https://github.com/llvm/llvm-project/commit/da06d1795ab0e004ec90d24b053a82a3db94df49
DIFF: https://github.com/llvm/llvm-project/commit/da06d1795ab0e004ec90d24b053a82a3db94df49.diff

LOG: [libc] add option to use SCUDO as the allocator

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.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D106502

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index 9e599be681eeb..37d996fa52fc9 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -71,6 +71,13 @@ elseif(LLVM_LIBC_FULL_BUILD)
     (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)

diff  --git a/libc/cmake/modules/LLVMLibCLibraryRules.cmake b/libc/cmake/modules/LLVMLibCLibraryRules.cmake
index c863f22fc7692..a5dc8043651a8 100644
--- a/libc/cmake/modules/LLVMLibCLibraryRules.cmake
+++ b/libc/cmake/modules/LLVMLibCLibraryRules.cmake
@@ -42,6 +42,7 @@ endfunction(collect_object_file_deps)
 # Usage:
 #     add_entrypoint_library(
 #       DEPENDS <list of add_entrypoint_object targets>
+#       EXT_DEPS <list of external object targets, no type checking is done>
 #     )
 #
 # NOTE: If one wants an entrypoint to be availabe in a library, then they will
@@ -52,7 +53,7 @@ function(add_entrypoint_library target_name)
     "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 +77,11 @@ function(add_entrypoint_library target_name)
   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

diff  --git a/libc/lib/CMakeLists.txt b/libc/lib/CMakeLists.txt
index c5d48e8480f77..3966658604d68 100644
--- a/libc/lib/CMakeLists.txt
+++ b/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)


        


More information about the libc-commits mailing list