Implement alternate genquery scope collection

The pre-existing GenQuery implementation relied on Skyframe's evaluation
of TransitiveTarget values, as deps of a given genquery rule's
ConfiguredTarget evaluation, to load the transitive closure of the
targets referred to by that genquery rule's `scope` attribute value.

TransitiveTarget nodes are one-to-one with build targets and the Skyframe
dependencies between them correspond with their target-space dependencies
(which may be either due to rules' attribute values, or due to those
rules' applicable aspects as determined by their providers).

Embedding genquery rules' scopes' target-space dependency graphs into
Skyframe as part of those rules' ConfiguredTarget Skyframe evaluations
causes problems when those dependency graphs have cycles. Skyframe
evaluations unconditionally fail when *they* have cycles. However,
`blaze query` semantics allow for a query expression to evaluate to a
non-failure value when the target-space dependency graph involved in
that evaluation contains cycles. Knowing nothing about genquery's
implementation, a Blaze user ought to expect genquery's semantics to be
similar to `blaze query`'s, modulo the constraint explicitly imposed by
genquery's `scope` mechanism. Because of genquery's reliance on
TransitiveTarget Skyframe evaluations, this expectation is not satisfied.

This CL introduces a flag, `--experimental_skip_ttvs_for_genquery`, which
causes genquery to use a different strategy when it is set to true. The
new strategy does not use TransitiveTarget values. Instead, genquery's
ConfiguredTarget Skyframe evaluation gathers necessary package data by
requesting a Skyframe node, GenQueryDirectPackageProviderFactory.Key,
which computes the transitive closure of the genquery rule's scope,
depending on Package values (and Package-related values like
ContainingPackageLookup, as necessary for incremental correctness).

The flag's default value is false, meaning, genquery's strategy remains
the same as before, vulnerable to cycles. Switching this default may come
in a future CL.

Comments in GenQueryDirectPackageProviderFactory.java document the new
strategy.

PiperOrigin-RevId: 474540264
Change-Id: I96092de4281f40d2f91aa4c152349dc6e16de30c
16 files changed
tree: 890545f232b84670fd6c7d11dcf8263b4c3033aa
  1. .bazelci/
  2. .github/
  3. examples/
  4. scripts/
  5. site/
  6. src/
  7. third_party/
  8. tools/
  9. .bazelrc
  10. .gitattributes
  11. .gitignore
  12. AUTHORS
  13. BUILD
  14. CHANGELOG.md
  15. CODE_OF_CONDUCT.md
  16. CODEBASE.md
  17. CODEOWNERS
  18. combine_distfiles.py
  19. combine_distfiles_to_tar.sh
  20. compile.sh
  21. CONTRIBUTING.md
  22. CONTRIBUTORS
  23. distdir.bzl
  24. distdir_deps.bzl
  25. LICENSE
  26. MODULE.bazel
  27. README.md
  28. SECURITY.md
  29. WORKSPACE
  30. WORKSPACE.bzlmod
README.md

Bazel

{Fast, Correct} - Choose two

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

  • Speed up your builds and tests: Bazel rebuilds only 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

Reporting a Vulnerability

To report a security issue, please email security@bazel.build with a description of the issue, the steps you took to create the issue, affected versions, and, if known, mitigations for the issue. Our vulnerability management team will respond within 3 working days of your email. If the issue is confirmed as a vulnerability, we will open a Security Advisory. This project follows a 90 day disclosure timeline.

Contributing to Bazel

See CONTRIBUTING.md

Build status