buildozer: do not remove visibility from macros or loaded rules in fix - #1510
Open
kyledobitz wants to merge 1 commit into
Open
kyledobitz wants to merge 1 commit into
kyledobitz wants to merge 1 commit into
Conversation
Previously, buildozer's removeVisibility routine stripped visibility attributes (such as "//visibility:private" or matching package default_visibility) from any rule whose visibility matched defaultVisibility. However, Starlark macros and loaded rules frequently implement custom fallback visibility logic (e.g. falling back to a non-private default if visibility is omitted). Stripping visibility from such macros causes them to silently broaden their visibility. Skip visibility removal if a rule's kind contains a dot (indicating a dotted macro or module) or matches any symbol loaded via a load() statement in the BUILD file.
kyledobitz
force-pushed
the
fix-buildozer-macro-visibility
branch
from
September 11, 2026 13:01
ae5d5f8 to
30a239b
Compare
kyledobitz
marked this pull request as ready for review
September 11, 2026 13:04
fmeum
reviewed
Sep 11, 2026
fmeum
left a comment
Member
There was a problem hiding this comment.
Do you have an example of a macro that would benefit from this change in behavior? Symbolic macros do not need it and legacy macros should use private visibility for inner targets.
| for _, stmt := range f.Stmt { | ||
| if load, ok := stmt.(*build.LoadStmt); ok { | ||
| for _, to := range load.To { | ||
| if to.Name == kind { |
Member
There was a problem hiding this comment.
With native rules being Starlarkified, wouldn't this match almost every target?
3 of 4 tasks
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.
Previously, buildozer's
removeVisibilityroutine stripped visibility attributes (such as"//visibility:private"or matching the package default_visibility) from any rule whose visibility matcheddefaultVisibility.However, Starlark macros and loaded rules frequently implement custom fallback visibility logic (e.g. falling back to a non-private default if visibility is omitted). Stripping visibility from such macros causes them to silently broaden their visibility.
This change skips visibility removal if a rule's kind contains a dot (indicating a dotted macro or module) or matches any symbol loaded via a
load()statement in the BUILD file.Unit tests are included in
edit/fix_test.gocovering:default_visibilityhandling for native rules vs loaded macros