runfiles: support Bazel 9 compact _repo_mapping format#921
Open
gregmagolan wants to merge 1 commit intomainfrom
Open
runfiles: support Bazel 9 compact _repo_mapping format#921gregmagolan wants to merge 1 commit intomainfrom
gregmagolan wants to merge 1 commit intomainfrom
Conversation
Bazel 9 introduces --incompatible_compact_repo_mapping_manifest which writes prefix-wildcard entries (source repo ending with `*`) to _repo_mapping. Without this change, any repo whose canonical name matches a compact prefix would silently fail to resolve runfiles. The `*` suffix is unambiguous as a wildcard marker because it is otherwise illegal in canonical repository names. Exact entries retain priority over prefix entries; among prefix entries, the first match wins (file order). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
c2598c8 to
95f778e
Compare
|
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.

Problem
Bazel 9 introduces
--incompatible_compact_repo_mapping_manifestwhich rewrites_repo_mappingentries using a prefix-wildcard format to reduce file size from quadratic to linear in repo count. A source-repo field ending with*matches any canonical repo name that starts with that prefix.The existing CSV parser only handled the old 3-column exact-match format. Any user on Bazel 9 with compact manifests enabled would get silently wrong runfile lookups for repos whose names match a compact prefix.
Solution
RepoMappingis promoted from a plainHashMaptype alias to a struct holding separateexactandprefixedtables.parse_repo_mappingdetects compact entries via the trailing*(unambiguous:*is illegal in canonical repo names) and routes them to the prefix table.RepoMapping::gettries exact match first, then iterates prefix entries in file order (first match wins).test_parse_repo_mapping_compact_formatcovers mixed exact+prefix files, prefix matching, exact-over-prefix priority, and no-match cases.References
--incompatible_compact_repo_mapping_manifesttracking issue; contains the full format spec and the list of runfiles libraries that need updatingTest plan
bazel test //py/tools/runfiles/...passes on CItest_parse_repo_mappingandtest_parse_repo_mapping_invalid_filestill passtest_parse_repo_mapping_compact_formatpasses