rules_cc icon indicating copy to clipboard operation
rules_cc copied to clipboard

local_config_cc is not invalidated by $PATH or compiler changes

Open pcc opened this issue 2 months ago • 4 comments

When I run PATH=/path/to/some/clang/bin:$PATH bazel build ... followed by PATH=/path/to/other/clang/bin:$PATH bazel build ... I would expect the second command to use the Clang binaries in /path/to/other/clang/bin. However, Bazel ends up using the Clang binaries under /path/to/some/clang/bin instead. These paths are cached in a directory named external/rules_cc++cc_configure_extension+local_config_cc.

A similar but related bug occurs when I update the compiler binaries in place to a newer version. Clang's builtin include paths are under a directory named lib/clang/$clangVersionNumber but these paths are cached in a file named external/rules_cc++cc_configure_extension+local_config_cc/builtin_include_directory_paths which leads to various build failures when the version number changes.

I ended up working around this bug by running bazel shutdown and deleting the rules_cc++cc_configure_extension+local_config_cc directory every time I change the compiler but Bazel should automatically invalidate the cache whenever anything to do with the compiler changes (or ideally not cache any of this at all).

pcc avatar Nov 03 '25 19:11 pcc