diff --git a/llvm/docs/CMake.rst b/llvm/docs/CMake.rst --- a/llvm/docs/CMake.rst +++ b/llvm/docs/CMake.rst @@ -479,15 +479,22 @@ On Windows, allows embedding a different C runtime allocator into the LLVM tools and libraries. Using a lock-free allocator such as the ones listed below greatly decreases ThinLTO link time by about an order of magnitude. It also - midly improves Clang build times, by about 5-10%. At the moment, rpmalloc, - snmalloc and mimalloc are supported. Use the path to `git clone` to select - the respective allocator, for example: + mildly improves Clang build times, by about 5-10%. At the moment, rpmalloc, + snmalloc and mimalloc from outside llvm-project are supported. Use the path + to `git clone` to select the respective allocator, for example: .. code-block:: console $ D:\git> git clone https://github.com/mjansson/rpmalloc $ D:\llvm-project> cmake ... -DLLVM_INTEGRATED_CRT_ALLOC=D:\git\rpmalloc - + + Scudo from compiler-rt is also supported by specifying the path to the built + library, for example: + + .. code-block:: console + + $ D:\llvm-project> cmake ... -DLLVM_INTEGRATED_CRT_ALLOC=\lib\clang\\lib\windows\clang_rt.scudo-x86_64.lib + This flag needs to be used along with the static CRT, ie. if building the Release target, add -DLLVM_USE_CRT_RELEASE=MT. diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt --- a/llvm/lib/Support/CMakeLists.txt +++ b/llvm/lib/Support/CMakeLists.txt @@ -62,7 +62,7 @@ string(REGEX REPLACE "(/|\\\\)$" "" LLVM_INTEGRATED_CRT_ALLOC "${LLVM_INTEGRATED_CRT_ALLOC}") if(NOT EXISTS "${LLVM_INTEGRATED_CRT_ALLOC}") - message(FATAL_ERROR "Cannot find the path to `git clone` for the CRT allocator! (${LLVM_INTEGRATED_CRT_ALLOC}). Currently, rpmalloc, snmalloc and mimalloc are supported.") + message(FATAL_ERROR "Cannot find the path to `git clone` for the CRT allocator! (${LLVM_INTEGRATED_CRT_ALLOC}). Currently, rpmalloc, snmalloc, mimalloc and scudo are supported.") endif() if(LLVM_INTEGRATED_CRT_ALLOC MATCHES "rpmalloc$") @@ -77,6 +77,8 @@ message(FATAL_ERROR "Cannot find the mimalloc static library. To build it, first apply the patch from https://github.com/microsoft/mimalloc/issues/268 then build the Release x64 target through ${LLVM_INTEGRATED_CRT_ALLOC}\\ide\\vs2019\\mimalloc.sln") endif() set(system_libs ${system_libs} "${MIMALLOC_LIB}" "-INCLUDE:malloc") + elseif(LLVM_INTEGRATED_CRT_ALLOC MATCHES "scudo") + set(system_libs ${system_libs} "${LLVM_INTEGRATED_CRT_ALLOC}" "-INCLUDE:malloc") endif() endif()