Conversation
fmeum
force-pushed
the
bazel-tools-cleanup
branch
4 times, most recently
from
September 16, 2026 08:21
7df12ce to
0357592
Compare
Move aquery_differ and ctexplain to scripts/ and remove the unused Android instrumentation checker/platform, compliance experiment, defaults package, and test_rules.bzl. None is included in the embedded tools archive. Stop embedding the JDK BUILD templates, nosystemjdk README, C++ test data, Python wrapper template/test, and generated WORKSPACE stub. The embedded BUILD files do not expose the latter files as targets; exported BUILD metadata itself is not a supported consumer interface. Keep the JDK BUILD.java_tools* templates in the source repository for packaging. Remove the embedded import-deps-checker and jarhelper packages: the former requires the unavailable @android_tools repository, while the latter requires absent Bazel source packages. These targets cannot be analyzed from @bazel_tools. Keep their implementations in the source repository. Retain usable public labels and loadable Starlark files for the following commits, including the buildstamp example and build_rules utilities. Update source distributions, CI labels and moved Python imports together.
Global GitHub code searches on 2026-09-16 found no matches for either "@bazel_tools//:windows" or "@bazel_tools//:windows_msvc". Drop those root config_setting aliases. The references to tools/python:private/py_test_alias.bzl are test-rule loads in old copies of aquery_differ and src/test/starlark. Remove this unused py_test forwarder and its source-file exports/filegroup entries. Move the proguard allowlister test and its testonly support library from @bazel_tools to the Bazel source repository, retaining the binary and its sources in the archive. Global matches for proguard_allowlister_test are test definitions. Stop embedding its four test-only source/data files. Remove the Java integration test's blanket source-repo tools/jdk toolchain registration together with this move. Keep symbols with non-test references, including references in old Bazel copies, in the final cleanup commit rather than claiming zero usage.
Keep the remaining compatibility removals together, separate from the structurally unreachable and zero-reference/test-only cleanup. Global GitHub code search on 2026-09-16 found non-test references for these surfaces; this commit does not claim that all consumers have migrated. Stop embedding tools/build_rules (retain the sources for Bazel's own bootstrap) and move tools/buildstamp/get_workspace_status to scripts/. Remove tools/coverage, the old whitelist package groups, compiler_flag.bzl, java_toolchain_alias.bzl, tools/java:java_stub_template.txt and the objc coverage stubs. Update the associated Java test mocks and documentation. Concrete consumer references found during review: - buildfarm/buildfarm, persistentworkers/src/main/protobuf/BUILD, loads @bazel_tools//tools/build_rules:utilities.bzl for java_library_srcs: https://github.com/buildfarm/buildfarm/blob/29b23a551b391c03b9667b082744fc863ff0565a/persistentworkers/src/main/protobuf/BUILD - timothyklim/rules_scala3 defaults _java_stub_template to @bazel_tools//tools/java:java_stub_template.txt in rules/scala.bzl and scala3/private/worker_scala_{binary,library}.bzl: https://github.com/timothyklim/rules_scala3/blob/a29ef64416a6cfb66cdb2dffd13f06dcfe31d8fb/rules/scala.bzl - Old rules_apple copies still name the objc coverage stubs; old Bazel copies retain relative loads of compiler_flag.bzl and other shims. RELNOTES[INC]: Remove legacy @bazel_tools build_rules, buildstamp, coverage and whitelist targets, compiler_flag.bzl, java_toolchain_alias.bzl, the tools/java java_stub_template alias and the objc coverage stubs. Consumers must migrate to maintained rulesets or provide their own helpers.
fmeum
force-pushed
the
bazel-tools-cleanup
branch
from
September 16, 2026 08:36
0357592 to
431fcc6
Compare
This was referenced Sep 16, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Stacked on #31144.
Now that the native rules and their autoloads are gone, a lot of what is embedded into
@bazel_toolsis either dead or was never referenceable from outside. This pass removes what nothing references anymore, stops embedding files that only make sense inside the Bazel repo, and moves developer tooling that never belonged in@bazel_toolsintoscripts/. The embedded file count drops from 292 to 259.Removed from
@bazel_toolsand the repo:tools/whitelistsandtools/build_defs/cc/whitelists/starlark_hdrs_check: the old-name package groups. Bazel has rejected the whitelist label as a transition allowlist for years and nothing references the other two.parse_headers_and_layering_checkstays, rules_cc'scc_toolchainstill defaults to it.tools/coverage: superseded by thetools/testdefaults long ago; the remaining references are vendored Bazel copies.tools/defaults: an empty package left over from the synthesized//tools/defaultspackage.tools/build_rules/test_rules.bzl: loads a file that no longer exists.tools/cpp/compiler_flag.bzlandtools/jdk/java_toolchain_alias.bzl: forwarders to rules_cc and rules_java without external users. Java test mocks now load the alias macros from rules_java directly.tools/java:java_stub_template.txt: a deprecated alias that announced its own removal.tools/objc:gcovand:mcov, stubs of the native objc rules.//:windowsand//:windows_msvcaliases in the root package, kept for third_party code that no longer exists.tools/python: the py2/py3 wrapper templates and their test, andprivate/py_test_alias.bzl.tools/android: theinstrumentation_test_checktool and an unreferenced platform. The module extension stays, it still has external users.tools/compliance: Bazel's SBOM experiment, not used by CI or the release process.No longer embedded, but kept in the repo:
tools/jdk: theBUILD.java_tools*templates andnosystemjdk/README; only the sources of the (now C++) proguard allowlister binary are embedded, its test runs from the repoBUILDinstead of from inside@bazel_tools.tools/build_rules:java_rules_skylark.bzlandutilities.bzl, together with the jarhelper sources that were embedded for the native Android rules. The package no longer exists in@bazel_tools.src/java_tools/import_deps_checker: its embeddedBUILDreferenced@android_tools, which@bazel_toolscannot see, so the target could never be analyzed.tools/cpp/test_data: unreferenced.WORKSPACEstub in the embedded tools zip.Moved to
scripts/: ctexplain, aquery_differ and theget_workspace_statusexample that--workspace_status_commanddocuments.Kept on purpose despite being legacy, because they still have users:
tools/android's extension,tools/build_defs/pkgandhash, the python.bzlshims that rules_python's//:bzltarget lists, and the proguard allowlister, which both rules_java and rules_android default to. bazelbuild/rules_java#382 and bazel-contrib/rules_jvm_external#1628 drop those defaults on the consumer side.Motivation
@bazel_toolsships with every Bazel binary and is loaded by every build, so everything embedded in it is startup cost and, worse, an implicit API surface that has to be kept working. Most of the removed pieces only existed because the native Java, Python, Android and objc rules referenced them; those rules are gone, and each item was checked against Bazel's own code, the embedded files and a GitHub code search before removal.Build API Changes
Yes, in the sense that a few targets and
.bzlfiles disappear from@bazel_tools. All of them were either already unusable (the whitelist package groups, the import_deps_checker target), superseded for years (tools/coverage, the root//:windowsaliases, the objc stubs) or explicitly deprecated (tools/java:java_stub_template.txt). Code search found no live users; the few hits are vendored Bazel copies, samples and one test fixture. There is no migration beyond switching to the replacement each item already pointed at.Release Notes
RELNOTES[INC]: Leftovers of the removed native rules were deleted from
@bazel_tools: thetools/whitelistspackage groups,tools/coverage,tools/cpp:compiler_flag.bzl,tools/jdk:java_toolchain_alias.bzl,tools/java:java_stub_template.txt,tools/objc:gcovand:mcov, the root//:windowsaliases and thetools/build_rulespackage. Use the rules_cc, rules_java andtools/testtargets they forwarded to.