Minimize the cost of Skyframe restarts during CC autoconfiguration.

Repository functions restart whenever they have to resolve a label due
to the way Skyframe currently works.  This is problematic because such
functions are often costly: they try to detect features of the host
system by building and running tools, and they touch the file system.

To minimize the cost of these restarts, which are unavoidable, resolve
the paths to all necessary labels upfront.  This way, while the restarts
still happen, they have no side-effects and thus are cheap.  As a
side-effect of this work, remove the strange and undocumented "tpl"
function, which only made things more cryptic and harder to refactor.

This cuts down Bazel's own analysis time on macOS on my Mac Pro 2013
from 14 seconds to 6 seconds by trimming about 15 unnecessary rebuilds
and executions of the xcode-locator-bin tool to just 1.  In other
words: one fewer awkward pause during analysis time.

Additionally, there is the hope that this will fix the problems users
observe where Bazel writes persistent garbage during autoconfiguration
(needing "clean --expunge" to recover) when Visual Studio Code is
running and Santa is enabled on macOS; see
https://github.com/bazelbuild/bazel/issues/4603.  This is most likely
a bug in Santa (see https://github.com/google/santa/issues/260) but
we were tickling it due to our apparently-abusive behavior of building,
executing, and then removing the same thing over and over again.

Fixes https://github.com/bazelbuild/bazel/issues/5196 and should also
fix https://github.com/bazelbuild/bazel/issues/4603.

RELNOTES: None.
PiperOrigin-RevId: 198434395
5 files changed
tree: b54caa748fcf4705a9c79f57f8719604a5ce48c8
  1. .bazelci/
  2. examples/
  3. scripts/
  4. site/
  5. src/
  6. third_party/
  7. tools/
  8. .gitattributes
  9. .gitignore
  10. AUTHORS
  11. BUILD
  12. CHANGELOG.md
  13. combine_distfiles.py
  14. combine_distfiles_to_tar.sh
  15. compile.sh
  16. CONTRIBUTING.md
  17. CONTRIBUTORS
  18. distdir.bzl
  19. ISSUE_TEMPLATE.md
  20. LICENSE
  21. README.md
  22. WORKSPACE
README.md

Bazel

{Fast, Correct} - Choose two

Build and test software of any size, quickly and reliably.

  • Speed up your builds and tests: Bazel only rebuilds what is necessary. With advanced local and distributed caching, optimized dependency analysis and parallel execution, you get fast and incremental builds.

  • One tool, multiple languages: Build and test Java, C++, Android, iOS, Go, and a wide variety of other language platforms. Bazel runs on Windows, macOS, and Linux.

  • Scalable: Bazel helps you scale your organization, codebase, and continuous integration solution. It handles codebases of any size, in multiple repositories or a huge monorepo.

  • Extensible to your needs: Easily add support for new languages and platforms with Bazel's familiar extension language. Share and re-use language rules written by the growing Bazel community.

Getting Started

Documentation

Contributing to Bazel

See CONTRIBUTING.md

Build status

Bazel is released in ‘Beta’. See the product roadmap to learn about the path toward a stable 1.0 release.