commit | 20e0f1ce93e5c82cf1681e57fe670bd778beb113 | [log] [tgz] |
---|---|---|
author | Benjamin Peterson <benjamin@python.org> | Mon Nov 16 08:13:26 2020 -0800 |
committer | Copybara-Service <copybara-worker@google.com> | Mon Nov 16 08:14:48 2020 -0800 |
tree | 6ed945f8685db55149445153b2a6592fda578f18 | |
parent | e1c62299ad7fd36c7b0ff570b807558c4065ee8c [diff] |
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