cmake: incorrectly reporting MSVC as using ccache #31771

issue fanquake openend this issue on January 31, 2025
  1. fanquake commented at 2:35 pm on January 31, 2025: member

    Mentioned by @stickies-v. The CMake configure currently outputs that MSVC builds are using ccache, i.e (https://github.com/bitcoin/bitcoin/actions/runs/13063954360/job/36452895056#step:8:2374):

    0Treat compiler warnings as errors ..... ON
    1Use ccache for compiling .............. ON
    

    However that’s a bug, as MSVC is currently excluded entirely from using ccache: https://github.com/bitcoin/bitcoin/blob/8fa10edcd1706a1f0dc9d8c3adbc8efa3c7755bf/cmake/ccache.cmake#L4-L6

  2. fanquake added this to the milestone 29.0 on Jan 31, 2025
  3. vijayabhaskar78 commented at 10:40 am on February 2, 2025: none
    Hey, can I contribute to this issue
  4. hebasto commented at 10:44 am on February 2, 2025: member

    @vijayabhaskar78

    Hey, can I contribute to this issue

    Sure! No need to ask :)

  5. hebasto added the label Build system on Feb 2, 2025
  6. vijayabhaskar78 commented at 10:59 am on February 2, 2025: none

    @hebasto sir Proposing a fix for #31771:

    Set USE_CCACHE=OFF for MSVC in cmake/ccache.cmake.
    Update status reporting in CMakeLists.txt.
    

    Questions:

    Does this align with project conventions?
    Any edge cases (MinGW/cross-compile) to test?
  7. purpleKarrot commented at 6:36 pm on February 2, 2025: contributor

    I don’t understand the motivation for setting CMAKE_<lang>_COMPILER_LAUNCHER from inside the project. Ideally, the project should not interfere with compiler launchers at all.

    This gives individual users as well as CI instances the highest flexibility.

    Assuming I have ENV{CMAKE_CXX_COMPILER_LAUNCHER} set locally to use sccache. What is the expected behavior when cmake/ccache.cmake invokes list(APPEND CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE})? Will it use sccache, ccache, or both?

  8. vijayabhaskar78 commented at 6:53 pm on February 2, 2025: none

    @purpleKarrot Should we remove the CMAKE_*_COMPILER_LAUNCHER assignments from ccache.cmake to prioritize user/CI flexibility? This would:

    Avoid conflicts with external launchers like sccache set via ENV{CMAKE_CXX_COMPILER_LAUNCHER}.
    Follow CMake best practices by letting users control launchers externally.
    Prevent invalid command chains (e.g., sccache;ccache;cl.exe) when multiple launchers are set.
    

    If agreed, I can update the PR to delete these lines and add documentation instead

  9. vijayabhaskar78 commented at 6:58 pm on February 2, 2025: none
    I’m a newbie to this repository. Can you help me to understand it?
  10. purpleKarrot commented at 7:08 pm on February 2, 2025: contributor
    @vijayabhaskar78, I am a newbe in this repository too, but I am not a newbie with CMake ;-) My recommendation would be to remove cmake/ccache.cmake for the reason you wrote. But let the original authors of that file chime in.
  11. vijayabhaskar78 commented at 7:28 pm on February 2, 2025: none
    OK let us see
  12. vijayabhaskar78 commented at 12:03 pm on February 3, 2025: none

    @fanquake @hebasto @purpleKarrot

    Problem Summary

    • False Reporting: CMake incorrectly reports ccache as “ON” for MSVC builds despite excluding it in cmake/ccache.cmake.
    • Launcher Conflicts: Forced CMAKE_*_COMPILER_LAUNCHER assignments override user/CI settings (e.g., sccache).

    Proposed Fix

    1. Delete cmake/ccache.cmake

    0rm cmake/ccache.cmake
    
    • Why? Removes forced ccache logic conflicting with external launchers.
    • Impact: Users/CI regain full control via CMAKE_CXX_COMPILER_LAUNCHER.

    2. Update Status Message

    0if(DEFINED ENV{CMAKE_CXX_COMPILER_LAUNCHER})  
    1  message(STATUS "Compiler launcher .............. $ENV{CMAKE_CXX_COMPILER_LAUNCHER}")  
    2else()  
    3  message(STATUS "Use ccache for compiling .............. NO")  
    4endif()
    
    • Result: Accurately reflects whether a launcher (e.g., ccache) is active.

    3. Document MSVC + ccache Workflow

    Add to doc/build-windows.md:

    Caching MSVC Builds

    • Step 1: Use Ninja:
      0-G "Ninja"
      
    • Step 2: Configure launcher:
      0cmake -B build -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
      
    • Step 3: Use /Z7 (not /Zi) for debug flags.

    Why This Approach?

    • Flexibility: No forced ccache/generator logic. Users/CI control launchers via CMake/env vars.
    • CMake Compliance: Follows CMake best practices.
    • Simplification: Deletes 50+ lines of error-prone code.

    Feedback Requested

    • @purpleKarrot: Does this address your concerns about launcher flexibility?
    • Maintainers (@fanquake, @hebasto): Any objections to deleting ccache.cmake?
  13. vijayabhaskar78 referenced this in commit 26a927fd80 on Feb 6, 2025
  14. s373nZ commented at 8:51 pm on February 18, 2025: none

    I don’t understand the motivation for setting CMAKE_<lang>_COMPILER_LAUNCHER from inside the project.

    I’m also ignorantly curious about this. Is it primarily a requirement from the feature parity list with the prior autotools?

    https://gist.github.com/hebasto/2ef97d3a726bfce08ded9df07f7dab5e

  15. maflcko commented at 3:01 pm on February 25, 2025: member
    Is the msvc configure summary a blocker for the release? I’ve removed the milestone from #30861 because it looks more like an involved feature than a bugfix, so maybe it can be removed here as well?
  16. fanquake referenced this in commit e682fc335d on Mar 4, 2025
  17. fanquake commented at 11:48 am on March 4, 2025: member
    I’ve opened #31983 to deal with this for now.
  18. fanquake referenced this in commit c718bffc36 on Mar 4, 2025
  19. fanquake closed this on Mar 5, 2025

  20. fanquake referenced this in commit c2341ebb5b on Mar 5, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-03-31 09:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me