hendrikmuhs / ccache-action

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

`Post Setup ccache` not displaying correctly when using bash on Windows #148

Closed juan-lunarg closed 1 year ago

juan-lunarg commented 1 year ago

The Post Setup ccache doesn't work correctly on our MinGW workflow. Led to minor confusion.

Post job cleanup.
ccache stats
  C:\ProgramData\Chocolatey\bin\ccache.exe -s
  cache directory                     C:\Users\runneradmin\AppData\Roaming/ccache
  primary config                      C:\Users\runneradmin\AppData\Roaming/ccache/ccache.conf
  secondary config (readonly)         R:/winlibs64_stage/inst_ccache-4.3/etc/ccache.conf
  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                       5.0 GB
Save cache using key "ccache-mingw-ccache-2023-05-24T20:10:55.447Z".
"C:\Program Files\Git\usr\bin\tar.exe" --posix -cf cache.tzst --exclude cache.tzst -P -C D:/a/Vulkan-ValidationLayers/Vulkan-ValidationLayers --files-from manifest.txt --force-local --use-compress-program "zstd -T0"
Cache Size: ~27 MB (27829669 B)
Cache saved successfully

However when I run ccache --show-stats directly after the build it shows the hits properly

Here is a github action that should show the behavior.

  mingw:
    runs-on: windows-latest
    defaults:
      run:
        shell: bash
    steps:
      - uses: actions/checkout@v3
      - name: Setup ccache
        uses: hendrikmuhs/ccache-action@v1.2
        with:
          key: mingw-ccache
      - uses: actions/setup-python@v4
        with:
          python-version: '3.8'
      - uses: lukka/get-cmake@latest
      - name: GCC Version
        run: gcc --version # If this fails MINGW is not setup correctly
      - name: Configure
        run: cmake -S. -B build-D CMAKE_BUILD_TYPE=Release
        env:
          LDFLAGS: -fuse-ld=lld # MINGW linking is very slow. Use llvm linker instead.
          CMAKE_C_COMPILER_LAUNCHER: ccache
          CMAKE_CXX_COMPILER_LAUNCHER: ccache
          CMAKE_GENERATOR: Ninja
      - name: Build
        run: cmake --build build -- --quiet
      - name: Install
        run: cmake --install build --prefix build/install
      - name: MinGW ccache stats
        run: ccache --show-stats  # <----------------- The Post Setup ccache doesn't work right on MinGW

Link to PR where I discovered this: https://github.com/KhronosGroup/Vulkan-ValidationLayers/pull/5904

juan-lunarg commented 1 year ago

Perhaps the issue is that during a mingw run we use the bash shell?

hendrikmuhs commented 1 year ago

Can you check the paths? Is it possible that you have 2 ccache binaries in your setup?

C:\ProgramData\Chocolatey\bin\ccache.exe looks suspicious to me.

juan-lunarg commented 1 year ago

Can you check the paths? Is it possible that you have 2 ccache binaries in your setup?

Hmm we aren't installing anything in this workflow.

We are just using the defaults provided by the Windows 2022 runner image: https://github.com/actions/runner-images/blob/main/images/win/Windows2022-Readme.md

Perhaps Mingw-w64 11.2.0 comes prepackaged with ccache?

I'll see if I can figure this out

hendrikmuhs commented 1 year ago

@juan-lunarg looks like you found the issue?

Maybe you can write about your findings, so others that run into the same issue and search the issue tracker can find it.

juan-lunarg commented 1 year ago

@juan-lunarg looks like you found the issue?

No I haven't found the issue. I decided to close the issue for now, since I'm unsure if the issue is in ccache-action or in our GHA code.