From 259c1347e318fcc950165b21c978ac9c6d081ab1 Mon Sep 17 00:00:00 2001 From: Robert Smith Date: Fri, 3 Jul 2026 12:47:09 +1000 Subject: [PATCH] Replace sccache with ccache across CI workflows and build system The project's CI previously used Mozilla's sccache for compiler caching. All workflows and the CMake compiler-cache module have been migrated to ccache instead, using the hendrikmuhs/ccache-action on Linux and macOS, and a manual actions/cache restore on Windows where ccache is installed via the MSYS2 package manager. Corresponding environment variables were updated from SCCACHE_* to CCACHE_* equivalents. The CMake helper was also fixed to search only the explicitly requested tool rather than the full list of candidates, preventing a stray sccache binary on a runner from silently taking precedence over ccache. The README was updated to drop the sccache recommendation. Generated-by: Claude Opus 4.8 --- .github/workflows/checks.yml | 73 ++++++++++++++++--------- .github/workflows/weekly_sanitizers.yml | 15 +++-- README.md | 2 +- cmake/CompilerCache.cmake | 4 +- 4 files changed, 63 insertions(+), 31 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 3abb31567a..7ef14fa36b 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -18,8 +18,11 @@ jobs: env: QT_SELECT: qt6 - SCCACHE_GHA_ENABLED: "true" - SCCACHE_CACHE_SIZE: "2G" + CCACHE_SLOPPINESS: pch_defines,time_macros + CCACHE_DEPEND: "true" + CCACHE_BASEDIR: ${{ github.workspace }} + CCACHE_COMPILERCHECK: content + CCACHE_MAXSIZE: 2G steps: - uses: actions/checkout@v1 @@ -31,8 +34,12 @@ jobs: sudo apt-get update sudo apt-get install clang qt6-base-dev libglvnd-dev zlib1g-dev libfftw3-dev ninja-build python3-numpy libpng-dev mesa-vulkan-drivers - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.9 + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.workflow }}-${{ github.job }} + max-size: 2G + verbose: 1 - name: Get CMake uses: lukka/get-cmake@latest @@ -85,8 +92,11 @@ jobs: env: QT_SELECT: qt6 - SCCACHE_GHA_ENABLED: "true" - SCCACHE_CACHE_SIZE: "2G" + CCACHE_SLOPPINESS: pch_defines,time_macros + CCACHE_DEPEND: "true" + CCACHE_BASEDIR: ${{ github.workspace }} + CCACHE_COMPILERCHECK: content + CCACHE_MAXSIZE: 2G steps: - uses: actions/checkout@v1 @@ -98,8 +108,12 @@ jobs: sudo apt-get update sudo apt-get install g++-9 qt6-base-dev libglvnd-dev zlib1g-dev libfftw3-dev ninja-build python3-numpy libpng-dev mesa-vulkan-drivers - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.9 + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.workflow }}-${{ github.job }} + max-size: 2G + verbose: 1 - name: Get CMake uses: lukka/get-cmake@latest @@ -142,8 +156,11 @@ jobs: runs-on: macos-latest env: - SCCACHE_GHA_ENABLED: "true" - SCCACHE_CACHE_SIZE: "2G" + CCACHE_SLOPPINESS: pch_defines,time_macros + CCACHE_DEPEND: "true" + CCACHE_BASEDIR: ${{ github.workspace }} + CCACHE_COMPILERCHECK: content + CCACHE_MAXSIZE: 2G steps: - uses: actions/checkout@v1 @@ -156,8 +173,12 @@ jobs: brew link --force qt brew install numpy - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.9 + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.workflow }}-${{ github.job }} + max-size: 2G + verbose: 1 - name: Get CMake uses: lukka/get-cmake@latest @@ -177,7 +198,6 @@ jobs: -D CMAKE_FIND_FRAMEWORK=LAST -D MRTRIX_BUILD_TESTS=ON -D MRTRIX_STL_DEBUGGING=ON - -D MRTRIX_USE_PCH=OFF -D MRTRIX_WARNINGS_AS_ERRORS=ON - name: build @@ -212,9 +232,12 @@ jobs: env: CHERE_INVOKING: enabled_from_arguments MINGW_PACKAGE_PREFIX: mingw-w64-ucrt-x86_64 - SCCACHE_GHA_ENABLED: "true" - SCCACHE_CACHE_SIZE: "2G" - SCCACHE_DIR: ${{ github.workspace }}/.sccache + CCACHE_SLOPPINESS: pch_defines,time_macros + CCACHE_DEPEND: "true" + CCACHE_BASEDIR: ${{ github.workspace }} + CCACHE_COMPILERCHECK: content + CCACHE_MAXSIZE: 2G + CCACHE_DIR: ${{ github.workspace }}/.ccache steps: - uses: actions/checkout@v1 @@ -229,6 +252,7 @@ jobs: git python ${{env.MINGW_PACKAGE_PREFIX}}-bc + ${{env.MINGW_PACKAGE_PREFIX}}-ccache ${{env.MINGW_PACKAGE_PREFIX}}-cmake ${{env.MINGW_PACKAGE_PREFIX}}-diffutils ${{env.MINGW_PACKAGE_PREFIX}}-fftw @@ -241,13 +265,13 @@ jobs: ${{env.MINGW_PACKAGE_PREFIX}}-qt6-svg ${{env.MINGW_PACKAGE_PREFIX}}-zlib - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.9 - - - name: export sccache to msys2 shell - run: | - export SCCACHE_UNIX_PATH=$(cygpath -u "$SCCACHE_PATH") - echo "SCCACHE_UNIX_PATH=$SCCACHE_UNIX_PATH" >> $GITHUB_ENV + - name: Restore ccache + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/.ccache + key: ${{ github.workflow }}-windows-ccache-${{ github.run_id }} + restore-keys: | + ${{ github.workflow }}-windows-ccache- - name: configure run: > @@ -258,8 +282,7 @@ jobs: -D MRTRIX_BUILD_TESTS=ON -D MRTRIX_STL_DEBUGGING=ON -D MRTRIX_WARNINGS_AS_ERRORS=ON - -D MRTRIX_ENABLE_GPU=OFF - -D CMAKE_CXX_COMPILER_LAUNCHER=${{env.SCCACHE_UNIX_PATH}} . + -D MRTRIX_ENABLE_GPU=OFF . - name: build run: cmake --build build -- -k 0 diff --git a/.github/workflows/weekly_sanitizers.yml b/.github/workflows/weekly_sanitizers.yml index 7f8a555cb8..8f3134cf54 100644 --- a/.github/workflows/weekly_sanitizers.yml +++ b/.github/workflows/weekly_sanitizers.yml @@ -11,8 +11,11 @@ jobs: runs-on: ubuntu-latest env: - SCCACHE_GHA_ENABLED: "true" - SCCACHE_CACHE_SIZE: "2G" + CCACHE_SLOPPINESS: pch_defines,time_macros + CCACHE_DEPEND: "true" + CCACHE_BASEDIR: ${{ github.workspace }} + CCACHE_COMPILERCHECK: content + CCACHE_MAXSIZE: 2G strategy: fail-fast: false @@ -30,8 +33,12 @@ jobs: sudo apt-get update sudo apt-get install clang llvm qt6-base-dev libglvnd-dev libeigen3-dev zlib1g-dev libfftw3-dev libpng-dev ninja-build python3-numpy - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.9 + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.sanitizer }} + max-size: 2G + verbose: 1 - name: Get CMake uses: lukka/get-cmake@latest diff --git a/README.md b/README.md index 37fb25350c..4b9984e01e 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ You can address all *MRtrix3*-related queries there, using your GitHub or Google $ cmake --build build $ cmake --install build - It's **highly** recommended, that you use [Ninja](https://ninja-build.org/) and a compiler caching tool like [ccache](https://ccache.dev/) or [sccache](https://github.com/mozilla/sccache) to speed up compilation time. You can install these tools using your package manager (e.g. `apt install ninja-build ccache` or `brew install ninja ccache`). Then, add `-GNinja` to the third step above or set the environment variable `CMAKE_GENERATOR` variable to `Ninja`. + It's **highly** recommended, that you use [Ninja](https://ninja-build.org/) and a compiler caching tool like [ccache](https://ccache.dev/) to speed up compilation time. You can install these tools using your package manager (e.g. `apt install ninja-build ccache` or `brew install ninja ccache`). Then, add `-GNinja` to the third step above or set the environment variable `CMAKE_GENERATOR` variable to `Ninja`. NOTE: by default MRtrix3 will build using Qt 6, but if you wish to use Qt 5 you can specify this by passing `-DMRTRIX_USE_QT5=ON` when configuring the build. diff --git a/cmake/CompilerCache.cmake b/cmake/CompilerCache.cmake index 1f7d60d252..dfaf99ea82 100644 --- a/cmake/CompilerCache.cmake +++ b/cmake/CompilerCache.cmake @@ -18,7 +18,9 @@ function(use_compiler_cache) ) endif() - find_program(CACHE_BINARY NAMES ${CACHE_OPTION_VALUES}) + # Honour the requested tool only, so selection is deterministic and a stray + # sccache on a runner image can never be picked in preference to ccache. + find_program(CACHE_BINARY NAMES ${CACHE_OPTION}) if(CACHE_BINARY) message(STATUS "${CACHE_BINARY} found and enabled") set(CMAKE_CXX_COMPILER_LAUNCHER