diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt index 9e599be681eeb8..37d996fa52fc9b 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 c863f22fc76924..a5dc8043651a8f 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 +# EXT_DEPS # ) # # 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 $) endforeach(dep) + + foreach(dep IN LISTS ENTRYPOINT_LIBRARY_EXT_DEPS) + list(APPEND objects $) + endforeach(dep) + add_library( ${target_name} STATIC diff --git a/libc/lib/CMakeLists.txt b/libc/lib/CMakeLists.txt index c5d48e8480f77b..3966658604d686 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)