Add CCACHE_FOUND=OFF to default CMake flags#22902
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates Homebrew’s shared std_cmake_args (used by formulae that invoke CMake) to explicitly disable projects’ ad-hoc ccache detection via a commonly used find_program(CCACHE_FOUND ccache) pattern, avoiding build failures when ccache is discoverable at configure-time but not reliably invokable at build-time.
Changes:
- Add
-DCCACHE_FOUND=OFFto the default CMake arguments returned byFormula#std_cmake_args.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
carlocab
left a comment
There was a problem hiding this comment.
I'm not opposed to this, but I am slightly hesitant because it only affects local source builds.
Does doing brew unlink ccache not prevent cmake from finding your ccache installation when building from source?
|
Hi @carlocab, thanks for taking a look.
Yes, unlinking However, I don’t think that is an ideal solution from a user’s point of view: if It also only fixes the Homebrew-installed However, it succeeds because The proposed change makes the default behavior consistent: Homebrew CMake builds should not accidentally discover and use |
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Makes sense to me, thanks!
brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?As discussed with @SMillerDev in https://github.com/orgs/Homebrew/discussions/6920, some formulae fail to build if
ccacheis installed. Simple example:docker run --rm -it ghcr.io/homebrew/ubuntu24.04:main \ bash -lc 'brew install --yes ccache && brew install --yes --build-from-source ada-url'This is due to the fact that
ccacheintegration in several formulae is typically handled as e.g.:instead of e.g.:
So, if
ccacheis not on$PATH, the build will fail.This is certainly an upstream problem. However, as a matter of fact, it currently affects at least 20 Homebrew formulae (minimum, these are just the ones I could find): ada-url, apache-arrow, cppinsights, exiv2, kingfisher, libff, librealsense, libwbxml, lief, merve, musikcube, osrm-backend, ppsspp, rapidjson, rocksdb, rtags, taglib, tdlib, vectorscan, yalantinglibs.
As the CMake snippets above seem to be a fairly standard approach even for formulae not currently packaged by Homebrew, as it can be quickly verified by a code search, this PR proposes to add
-DCCACHE_FOUND=OFFto the standard CMake flags. For the same formula as before, this will now work if using the proposed additional flag:docker run --rm -it ghcr.io/homebrew/ubuntu24.04:main \ bash -lc 'set -euo pipefail; export HOMEBREW_NO_AUTO_UPDATE=1; curl -fsSL https://raw.githubusercontent.com/matteosecli/brew/344b6d838de7caf9457c4c58db879b8481d929b8/Library/Homebrew/formula.rb > "$(brew --repository)/Library/Homebrew/formula.rb"; brew install --yes ccache && brew install --yes --build-from-source ada-url'Adding this flag will also be beneficial if other formulae, in the future, decide to include the same CMake snippet or to enable ccache discovery by default in their CMake files, or if newer CI build images will happen to ship with ccache preinstalled.