bazel: Builds invalidate cache from test runs and vice versa
Description of the problem / feature request:
Starting from an empty bazel cache, when we run
bazel build //... # empty cache
bazel test //... # build cache not reused?
bazel build //... # cache invaldiated by test run?
bazel test //...
...
on our project, every single command seems to be rebuilding the cache; we observe very slow builds (~1h).
The following works:
baze build //... # first build is slow
bazel build //... # almost instant
bazel build //... # almost instant
Similarly for testing:
baze test //... # first build is slow
bazel test //... # almost instant
bazel test //... # almost instant
We have tried --distinct_host_configuration=false but it doesn’t solve the issue.
What operating system are you running Bazel on?
Ubuntu 20.04
What’s the output of bazel info release?
release 4.0.0
What’s the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?
git@github.com:pins/pins-infra.git 80a739d0e2f15edbb185cc9061f66202a70fffd8 80a739d0e2f15edbb185cc9061f66202a70fffd8
Any other information, logs, or outputs that you want to share?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 17 (4 by maintainers)
Does
--noallow_analysis_cache_discardhelp in that regard?Yes, thanks, this works for us, though I think it is quite brittle and it would be nice to fix the underlying issue.
@smolkaj I think I found the issue:
test --cxxoptsincludesbuild --cxxoptsTechnically, this means that builds and tests are done with “different” options, so the cache is invalidated and a rebuild occurs. If we avoid specifying test and run opts, caching seems to work.