[Mlir-commits] [mlir] 0fad18c - [CMake] Remove custom ccache CMake logic

Tobias Hieta llvmlistbot at llvm.org
Sun Feb 12 23:42:46 PST 2023


Author: Tobias Hieta
Date: 2023-02-13T08:42:38+01:00
New Revision: 0fad18c44a14b909a1aa47165021273d4c10a665

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

LOG: [CMake] Remove custom ccache CMake logic

CMake supports CMAKE_CXX_COMPILER_LAUNCHER since CMake 3.4
so this custom CMake logic we had in LLVM can now be removed.

The only downside with this is that we can't set ccache
options from LLVM CMake, but it's arguable that this doesn't
belong in LLVM but should be done in a script calling the
build.

This was discussed in the forums here:

https://discourse.llvm.org/t/tips-for-incremental-building/67289/4?u=tobiashieta

Reviewed By: phosek

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

Added: 
    

Modified: 
    llvm/CMakeLists.txt
    llvm/docs/CMake.rst
    llvm/docs/ReleaseNotes.rst
    mlir/utils/clang-tidy/README.md

Removed: 
    


################################################################################
diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 8e6b738efd7e..5aedf28b0435 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -233,38 +233,8 @@ if (LLVM_ENABLE_PROJECTS_USED OR NOT LLVM_ENABLE_PROJECTS STREQUAL "")
 endif()
 unset(SHOULD_ENABLE_PROJECT)
 
-# Build llvm with ccache if the package is present
-set(LLVM_CCACHE_BUILD OFF CACHE BOOL "Set to ON for a ccache enabled build")
-if(LLVM_CCACHE_BUILD)
-  find_program(CCACHE_PROGRAM ccache)
-  if(CCACHE_PROGRAM)
-    set(LLVM_CCACHE_MAXSIZE "" CACHE STRING "Size of ccache")
-    set(LLVM_CCACHE_DIR "" CACHE STRING "Directory to keep ccached data")
-    set(LLVM_CCACHE_PARAMS "CCACHE_CPP2=yes CCACHE_HASHDIR=yes"
-        CACHE STRING "Parameters to pass through to ccache")
-
-    if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
-      set(CCACHE_PROGRAM "${LLVM_CCACHE_PARAMS} ${CCACHE_PROGRAM}")
-      if (LLVM_CCACHE_MAXSIZE)
-        set(CCACHE_PROGRAM "CCACHE_MAXSIZE=${LLVM_CCACHE_MAXSIZE} ${CCACHE_PROGRAM}")
-      endif()
-      if (LLVM_CCACHE_DIR)
-        set(CCACHE_PROGRAM "CCACHE_DIR=${LLVM_CCACHE_DIR} ${CCACHE_PROGRAM}")
-      endif()
-      set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PROGRAM})
-    else()
-      if(LLVM_CCACHE_MAXSIZE OR LLVM_CCACHE_DIR OR
-         NOT LLVM_CCACHE_PARAMS MATCHES "CCACHE_CPP2=yes CCACHE_HASHDIR=yes")
-        message(FATAL_ERROR "Ccache configuration through CMake is not supported on Windows. Please use environment variables.")
-      endif()
-      # RULE_LAUNCH_COMPILE should work with Ninja but currently has issues
-      # with cmd.exe and some MSVC tools other than cl.exe
-      set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
-      set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
-    endif()
-  else()
-    message(FATAL_ERROR "Unable to find the program ccache. Set LLVM_CCACHE_BUILD to OFF")
-  endif()
+if(DEFINED LLVM_CCACHE_BUILD)
+	message(FATAL_ERROR "-DLLVM_CACHE_BUILD=ON is deprecated! Use to the following options instead:\n-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache")
 endif()
 
 set(LLVM_EXTERNAL_PROJECT_BUILD_TOOL_ARGS "" CACHE STRING
@@ -280,8 +250,8 @@ 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(DEFINED CMAKE_CXX_COMPILER_LAUNCHER)
+    message(FATAL_ERROR "Cannot enable dependency debugging while using a compiler launcher like ccache.")
   endif()
 endif()
 

diff  --git a/llvm/docs/CMake.rst b/llvm/docs/CMake.rst
index 7926de258ec8..4284bd8b9f76 100644
--- a/llvm/docs/CMake.rst
+++ b/llvm/docs/CMake.rst
@@ -402,14 +402,6 @@ enabled sub-projects. Nearly all of these variable names begin with
   example, you can build *llvm-as* with a Makefile-based system by executing *make
   llvm-as* at the root of your build directory.
 
-**LLVM_CCACHE_BUILD**:BOOL
-  If enabled and the ``ccache`` program is available, then LLVM will be
-  built using ``ccache`` to speed up rebuilds of LLVM and its components.
-  Defaults to OFF.  The size and location of the cache maintained
-  by ``ccache`` can be adjusted via the LLVM_CCACHE_MAXSIZE and LLVM_CCACHE_DIR
-  options, which are passed to the CCACHE_MAXSIZE and CCACHE_DIR environment
-  variables, respectively.
-
 **LLVM_CREATE_XCODE_TOOLCHAIN**:BOOL
   macOS Only: If enabled CMake will generate a target named
   'install-xcode-toolchain'. This target will create a directory at

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 75aeee663127..0955bcb86501 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -56,6 +56,11 @@ Changes to the LLVM IR
 Changes to building LLVM
 ------------------------
 
+* Removed ``LLVM_CCACHE_BUILD``, ``LLVM_CCACHE_MAXSIZE``, ``LLVM_CCACHE_DIR``
+  and ``LLVM_CCACHE_PARAMS`` CMake options. Upstream CMake supports setting
+  ``CMAKE_CXX_COMPILER_LAUNCHER=ccache`` since CMake 3.4 and should be used
+  instead.
+
 Changes to TableGen
 -------------------
 

diff  --git a/mlir/utils/clang-tidy/README.md b/mlir/utils/clang-tidy/README.md
index ca43a77c4a0e..d886ac630387 100644
--- a/mlir/utils/clang-tidy/README.md
+++ b/mlir/utils/clang-tidy/README.md
@@ -35,7 +35,8 @@ $ cmake ../llvm \
   -DCMAKE_BUILD_TYPE=Release \
   -DLLVM_ENABLE_ASSERTIONS=ON \
   -DLLVM_TARGETS_TO_BUILD="Native;NVPTX;AMDGPU" \
-  -DLLVM_CCACHE_BUILD=ON \
+  -DCMAKE_C_COMPILER_LAUNCHER=ccache \
+  -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
   -DCMAKE_C_COMPILER=clang \
   -DCMAKE_CXX_COMPILER=clang++ \
   -DLLVM_ENABLE_LLD=ON \


        


More information about the Mlir-commits mailing list