Skip to content

packages: allow idempotent exports_files visibility#29220

Open
abishekgiri wants to merge 1 commit intobazelbuild:masterfrom
abishekgiri:exports-files-visibility-fix
Open

packages: allow idempotent exports_files visibility#29220
abishekgiri wants to merge 1 commit intobazelbuild:masterfrom
abishekgiri:exports-files-visibility-fix

Conversation

@abishekgiri
Copy link
Copy Markdown
Contributor

Summary

This change makes repeated exports_files() declarations with the same logical visibility idempotent, even when the visibility is represented by distinct RuleVisibility instances.

What changed

  • compare exported-file visibility with logical equality instead of object identity
  • add regression coverage for calling exports_files() twice with the same custom package visibility

Root cause

exports_files() used != to compare visibilities. That works for singleton public and private visibilities, but it rejects repeated custom visibilities because each parse can allocate a fresh RuleVisibility object even when the declared labels are identical.

Impact

Packages can safely repeat the same custom visibility in exports_files() without tripping a false "declared twice" error, while genuinely conflicting visibilities still fail.

Testing

Tried locally:

  • bazel test //src/test/java/com/google/devtools/build/lib/packages:PackagesTests --test_filter='.testExportTwice(CustomVisibilityOK|PublicOK|Fail).' --test_output=errors

Current local blocker:

  • analysis completed, but execution on this machine is blocked by an unaccepted Xcode license (xcrun failed with code 69 from apple_support)

@abishekgiri
Copy link
Copy Markdown
Contributor Author

Reopened this change from the neutral branch name exports-files-visibility-fix. The targeted test command is in the PR body; local execution on this machine is still blocked by the unaccepted Xcode license.

@abishekgiri abishekgiri marked this pull request as ready for review April 2, 2026 23:15
@github-actions github-actions bot added awaiting-review PR is awaiting review from an assigned reviewer team-Loading-API BUILD file and macro processing: labels, package(), visibility, glob labels Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR is awaiting review from an assigned reviewer team-Loading-API BUILD file and macro processing: labels, package(), visibility, glob

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant