hendrikmuhs / ccache-action

github action to speedup building using ccache
MIT License
114 stars 52 forks source link

Not caching anything on Windows-2022 #100

Closed kotori2 closed 1 year ago

kotori2 commented 1 year ago

key steps:

    - name: ccache
      uses: hendrikmuhs/ccache-action@v1.2

    - name: Show data
      shell: bash
      run: |
        ccache -s
        ccache -p
    - name: Configure CMake
      shell: bash
      working-directory: ${{runner.workspace}}/build
      run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
    - name: Build
      working-directory: ${{runner.workspace}}/build
      shell: bash
      run: cmake --build . --config $BUILD_TYPE

Paths seems set correctly before build.

image

But actually nothing was even passed through ccache:

"C:\Program Files\Git\bin\bash.exe" -xc "ccache -s"
+ ccache -s
cache directory                     D:\a\CFSPP\CFSPP\.ccache
primary config                      C:\Users\runneradmin/ccache/ccache.conf
secondary config (readonly)         R:/winlibs64_stage/inst_ccache-4.3/etc/ccache.conf
stats updated                       09/22/22 05:44:00
stats zeroed                        09/22/22 05:44:00
cache hit (direct)                     0
cache hit (preprocessed)               0
cache miss                             0
cache hit rate                      0.00 %
cleanups performed                     0
files in cache                         0
cache size                           0.0 kB
max cache size                     500.0 MB

The configuration works perfectly on Linux and macOS build, I'm pretty confused what step I'm missing.

kotori2 commented 1 year ago

Same thing happens even if I am using scache

image
jonashaag commented 1 year ago

Could be that we're seeing something similar here: https://github.com/mamba-org/mamba/actions/runs/3098337422/jobs/5016125123

kotori2 commented 1 year ago

I'm also using vcpkg in CMake, not sure if it affects the result. Gonna test tmrw.

hendrikmuhs commented 1 year ago

The stats show that sccache isn't even called.

There is an upstream issue: https://github.com/mozilla/sccache/issues/1097

I do not see what we can do here as part of the ccache action.

kotori2 commented 1 year ago

In my case it is because CMake is using MSBuild by default, which is not supported by ccache. Simply switching to Ninja makes everything works. I think for micromambda it's the same error since they are using msbuild.

Stackoverflow save lives https://stackoverflow.com/questions/72829476/how-to-use-ccache-4-6-1-on-windows-msvc-with-cmake