bazelbuild / bazelbuild/rules_cc

local_config_cc is not invalidated by $PATH or compiler changes

Open
#515 4 comments 0 reactions 0 assignees View on GitHub
category: toolchains untriaged
Dominant language
Starlark
Stars
247
Forks
196
PR merge metrics
No merged PRs in 30d

Description

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).

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with two Bazel builds using different PATH entries, then inspect external/rules_cc++cc_configure_extension+local_config_cc and its builtin_include_directory_paths file. Done means changing the compiler path or compiler version causes Bazel to stop using the old Clang binaries and builtin include paths without requiring bazel shutdown or manual cache deletion.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.