[PATCH] D94901: Add support for using BuildCache (CMake)
m via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 18 02:56:04 PST 2021
mbitsnbites created this revision.
mbitsnbites added a reviewer: bogner.
Herald added a subscriber: mgorny.
mbitsnbites requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
BuildCache [1] is a compilation cache similar to ccache (which is already supported by the LLVM CMake build system).
This change adds a CMake option, LLVM_BUILDCACHE_BUILD, that enables the use of BuildCache for accelerating LLVM builds.
[1] https://github.com/mbitsnbites/buildcache
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D94901
Files:
llvm/CMakeLists.txt
llvm/docs/CMake.rst
Index: llvm/docs/CMake.rst
===================================================================
--- llvm/docs/CMake.rst
+++ llvm/docs/CMake.rst
@@ -646,6 +646,11 @@
options, which are passed to the CCACHE_MAXSIZE and CCACHE_DIR environment
variables, respectively.
+**LLVM_BUILDCACHE_BUILD**:BOOL
+ If enabled and the ``buildcache`` program is available, then LLVM will be
+ built using ``buildcache`` to speed up rebuilds of LLVM and its components.
+ Defaults to OFF.
+
**LLVM_FORCE_USE_OLD_TOOLCHAIN**:BOOL
If enabled, the compiler and standard library versions won't be checked. LLVM
may not compile at all, or might fail at runtime due to known bugs in these
Index: llvm/CMakeLists.txt
===================================================================
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -162,17 +162,32 @@
endif()
endif()
+# Build llvm with BuildCache if the package is present
+set(LLVM_BUILDCACHE_BUILD OFF CACHE BOOL "Set to ON for a BuildCache enabled build")
+if(LLVM_BUILDCACHE_BUILD)
+ find_program(BUILDCACHE_PROGRAM buildcache)
+ if(BUILDCACHE_PROGRAM)
+ set(LLVM_BUILDCACHE_DIR "" CACHE STRING "Directory to keep BuildCached data")
+ if (LLVM_BUILDCACHE_DIR)
+ set(BUILDCACHE_PROGRAM "BUILDCACHE_DIR=${LLVM_BUILDCACHE_DIR} ${BUILDCACHE_PROGRAM}")
+ endif()
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${BUILDCACHE_PROGRAM})
+ else()
+ message(FATAL_ERROR "Unable to find the program BuildCache. Set LLVM_BUILDCACHE_BUILD to OFF")
+ endif()
+endif()
+
option(LLVM_DEPENDENCY_DEBUGGING "Dependency debugging mode to verify correctly expressed library dependencies (Darwin only)" OFF)
# Some features of the LLVM build may be disallowed when dependency debugging is
-# enabled. In particular you cannot use ccache because we want to force compile
-# operations to always happen.
+# enabled. In particular you cannot use ccache or BuildCache because we want to
+# force compile operations to always happen.
if(LLVM_DEPENDENCY_DEBUGGING)
if(NOT CMAKE_HOST_APPLE)
message(FATAL_ERROR "Dependency debugging is only currently supported on Darwin hosts.")
endif()
- if(LLVM_CCACHE_BUILD)
- message(FATAL_ERROR "Cannot enable dependency debugging while using ccache.")
+ if(LLVM_CCACHE_BUILD OR LLVM_BUILDCACHE_BUILD)
+ message(FATAL_ERROR "Cannot enable dependency debugging while using ccache or BuildCache.")
endif()
endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94901.317303.patch
Type: text/x-patch
Size: 2445 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210118/dd7d32bd/attachment.bin>
More information about the llvm-commits
mailing list