Restore target cycle errors to their former grandeur.
In recent years, a frustrating error for Bazel users is the one caused by putting a reverse dependency rather than a package group into a target's visibility attribute. Such a mistake generally resulted in an error like this:
```
BUILD:7:10: in filegroup rule //pkg1:actual_target: cycle in dependency graph:
//pkg1:actual_target
//pkg1:dep_with_visibility
.-> //pkg1:actual_target
| //pkg1:dep_with_visibility
`-- //pkg1:actual_target
This cycle occurred because of a configuration option
```
This was confusing primarily because users don't think of visibility as causing a dependency—see, for instance, https://github.com/bazelbuild/bazel/issues/11945. Additionally, the "This cycle occurred because of a configuration option" hint was not usually accurate or helpful.
That the visibility mistake will be reported as a cycle is a fundamental property of how analysis is mapped onto Skyframe today, but a better hint was certainly possible. In fact, deep within Bazel's bowels there was already code to produce a better message, but it became mostly dormant during the analysis-loading interleaving work of 2017.
This CL removes the "This cycle occurred because of a configuration option" hint completely and restores the old visibility hint when appropriate. The primary code change is to combine ConfiguredTargetCycleReporter and TransitiveTargetCycleReporter to form TargetCycleReporter.
Now, a visibility cycle looks like this:
```
BUILD:2:10: in filegroup rule //pkg1:actual_target: cycle in dependency graph:
//pkg1:actual_target
//pkg1:dep_with_visibility
.-> //pkg1:actual_target
| //pkg1:dep_with_visibility
`-- //pkg1:actual_target
The cycle is caused by a visibility edge from //pkg1:dep_with_visibility to the non-package_group target //pkg1:actual_target. Note that visibility labels are supposed to be package_group targets, which prevents cycles of this form.
```
I humbly include this change in the https://github.com/bazelbuild/bazel/issues/11984 program.
Closes #12272.
PiperOrigin-RevId: 342638902
{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.
Follow our tutorials:
See CONTRIBUTING.md