Skip to content

Conversation

giordano
Copy link
Member

No description provided.

@giordano giordano added the documentation Improvements or additions to documentation label Jun 12, 2025
Comment on lines +87 to +98
To speed up recompilation you can use [ccache](https://ccache.dev/).
You can use ccache on top of Bazel's own caching system, which is very inflexible: Bazel invalidates cache whenever you change any variable, leading to poor cache hit rate when recompiling code with different options, even if they don't actually affect compilation output.
Since [Bazel interacts badly with ccache](https://github.com/ccache/ccache/discussions/1279) when the latter [masquerades itself as the compiler via symlinks](https://ccache.dev/manual/4.11.3.html#_run_modes), the most reliable way to use ccache with Bazel is to create a small shell wrapper like

```bash
#!/bin/bash
/path/to/ccache /path/to/your/compiler "${@}"
```

replacing `/path/to/ccache` with the path where ccache was installed, and `/path/to/your/compiler` with the path of your compiler.
Then inform Bazel to use this script as the compiler (with the `build_local.jl` script add the flag `--cc /path/to/ccache/wrapper`, where `/path/to/ccache/wrapper` is the path where you saved the shell wrapper).
Finally, you may have to add the flag `--extraopt "--sandbox_writable_path=/path/to/ccache/directory"`, otherwise Bazel will not let `ccache` write the cache output to its own directory.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the most comprehensive piece of documentation about using ccache with bazel that you can find anywhere on the internet 😁

Copy link

codecov bot commented Jun 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.79%. Comparing base (b6ffc96) to head (2dcf6a3).
Report is 1195 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1396       +/-   ##
===========================================
+ Coverage   21.66%   37.79%   +16.12%     
===========================================
  Files          46      115       +69     
  Lines        8048    20866    +12818     
===========================================
+ Hits         1744     7886     +6142     
- Misses       6304    12980     +6676     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@giordano giordano merged commit dd0a68a into EnzymeAD:main Jun 12, 2025
10 checks passed
@giordano giordano deleted the mg/local-build-docs branch June 12, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants