Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flip --incompatible_visibility_private_attributes_at_definition and make it less breaking #19141

Closed
wants to merge 2 commits into from

Conversation

fmeum
Copy link
Collaborator

@fmeum fmeum commented Aug 1, 2023

In addition to flipping the flag, also add a check for visibility from the target as a fallback to make the flip less breaking.

Closes #19330

RELNOTES[INC]: --incompatible_visibility_private_attributes_at_definition is flipped to true. See #19330 for details.

@fmeum
Copy link
Collaborator Author

fmeum commented Aug 1, 2023

@meteorcloudy I would like to see this flag flipped, but would like to see the results of a downstream run before I bring this up for discussion. Could you trigger one for me on this PR?

@meteorcloudy
Copy link
Member

Here you go: https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds?branch=pull%2F19141%2Fhead

But there are many existing failures in downstream pipeline, you may need to compare the results.

@fmeum fmeum force-pushed the flip-check-at-definition branch 2 times, most recently from 7a5201e to a09caf1 Compare August 25, 2023 10:40
@fmeum fmeum marked this pull request as ready for review August 25, 2023 10:41
@fmeum fmeum changed the title TMP: Flip --incompatible_visibility_private_attributes_at_definition Flip --incompatible_visibility_private_attributes_at_definition Aug 25, 2023
@github-actions github-actions bot added awaiting-review PR is awaiting review from an assigned reviewer team-Documentation Documentation improvements that cannot be directly linked to other team labels labels Aug 25, 2023
@fmeum fmeum added team-Configurability platforms, toolchains, cquery, select(), config transitions and removed team-Documentation Documentation improvements that cannot be directly linked to other team labels labels Aug 25, 2023
@fmeum
Copy link
Collaborator Author

fmeum commented Aug 25, 2023

Downstream is looking good: https://buildkite.com/bazel/bazelisk-plus-incompatible-flags/builds/1625

Not entirely sure which team this belongs to, but based on prior interactions about this flag and the relation to visibility, I will go with Team-Configurability.

@aranguyen Could you review this? I had a previous discussion about this with Greg on #19139. We can also wait for Greg to be back in office if you don't feel like you have sufficient context.

CC @laurentlb as the reviewer of the original proposal (https://github.com/bazelbuild/proposals/blob/main/designs/2019-10-15-tool-visibility.md). With load visibility available now, there doesn't seem to be any reason not to flip this for Bazel. Blaze may be a different story, but could be solved with an RC file entry if you don't want to perform a migration.

@fmeum fmeum requested review from aranguyen and removed request for gregestren, fweikert and philomathing August 25, 2023 10:45
@comius comius requested review from comius and brandjon and removed request for aranguyen September 6, 2023 12:48
Copy link
Contributor

@comius comius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has a potential to show preexisting correctness bugs on unexpected edge cases. I'll run the internal tests and report back.

@comius comius added awaiting-review PR is awaiting review from an assigned reviewer and removed awaiting-review PR is awaiting review from an assigned reviewer labels Sep 6, 2023
@comius
Copy link
Contributor

comius commented Sep 6, 2023

@brandjon, can you provide a second pair of eyes?

This has been implemented in 2019: PiperOrigin-RevId: 277683498

Technically this could show us some edge cases / correctness issues. I remember fixing one related to this in the past that involved about 5 conditions to trigger.

I'll run internal tests and if we don't have a plan for other actions that could de-risk us, I propose we move forward.

This is a feature that both internal and external users were asking for and is a pain point for toolchain owners in general.

@fmeum I don't see aspects covered in the tests of the original implementation. Could you add some tests for that? Should an implicit dependency in that case be visible to an aspect, not rule?

cc @mai93

@comius
Copy link
Contributor

comius commented Sep 6, 2023

The test I was referring to is: targetCompatibleWith_mismatchesExecCompatibleWithinAspect.

The aspect case is even more complex. Implicit dependency might be coming from the target an aspect is over or from an aspect. Please add tests. Undo approval.

Copy link
Contributor

@comius comius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests that cover aspect's implicit dependecies and implicit dependencies of targets an aspect is over.

@comius
Copy link
Contributor

comius commented Sep 6, 2023

I believe IntelliJ issues are related to aspects functionality. Please address them.

@comius comius added awaiting-user-response Awaiting a response from the author and removed awaiting-review PR is awaiting review from an assigned reviewer labels Sep 6, 2023
@fmeum fmeum changed the title Flip --incompatible_visibility_private_attributes_at_definition Flip --incompatible_visibility_private_attributes_at_definition and make it less breaking Sep 22, 2023
@fmeum fmeum force-pushed the flip-check-at-definition branch from a09caf1 to 927b47b Compare September 22, 2023 06:58
@fmeum fmeum requested a review from a team as a code owner September 22, 2023 06:58
@fmeum fmeum requested review from aranguyen and removed request for a team September 22, 2023 06:58
@fmeum fmeum force-pushed the flip-check-at-definition branch from 927b47b to a32cc80 Compare September 22, 2023 07:01
@fmeum fmeum requested a review from comius September 22, 2023 07:26
@fmeum
Copy link
Collaborator Author

fmeum commented Sep 22, 2023

@comius I made the change you suggested in #19330 (comment).

@fmeum fmeum requested a review from mai93 September 22, 2023 20:59
@fmeum fmeum deleted the flip-check-at-definition branch October 6, 2023 09:36
@comius
Copy link
Contributor

comius commented Oct 27, 2023

There's one use case we haven't foreseen. Restricting visibility of tools to builtin rules.

@fmeum
Copy link
Collaborator Author

fmeum commented Oct 27, 2023

@comius Could you elaborate on this? Wouldn't something like visibility = ["@_builtins//..."] work?

@comius
Copy link
Contributor

comius commented Oct 27, 2023

@comius Could you elaborate on this? Wouldn't something like visibility = ["@_builtins//..."] work?

I've just got a report from an internal user, that they tried "@_builtins//:__pkg__" and that it doesn't work. The error message indicates that fallback happened, however I didn't debug it.

It happened on an internal ruleset. Possibly a simple reproduction in Bazel is to reduce visibility of @bazel_tools/tools/def_parser:def_parser, which is used in cc_binary

@fmeum
Copy link
Collaborator Author

fmeum commented Oct 29, 2023

I checked that visibility = ["@@_builtins//:__subpackages__"] on def_parser suffices to build cc_binarys. Note the double @, which is necessary since _builtins does not have a repo mapping entry in bazel_tools.

@comius If a rule foo extends a rule bar, are implicit dependencies of bar checked against the definition of bar (instead of foo)? I could see this leading to problems if not.

@Wyverald
Copy link
Member

cc also @brandjon; this is somewhat annoying since @_builtins is really a "pseudo-repo" -- it doesn't have a definition, you can't build any targets in it, and the only thing you're really allowed to do is to load .bzl files from it. I'm not too familiar with what this PR entails, but if it has now required @_builtins to be an actual repo, we might need to have a more principled solution.

mai93 pushed a commit that referenced this pull request Dec 12, 2023
… make it less breaking

In addition to flipping the flag, also add a check for visibility from the target as a fallback to make the flip less breaking.

Closes #19330

RELNOTES[INC]: --incompatible_visibility_private_attributes_at_definition is flipped to true. See #19330 for details.

Closes #19141.

PiperOrigin-RevId: 569556377
Change-Id: Ic691c5585d9ba2d95b6ff3c32b9979f777147d8b
(cherry picked from commit 0656103)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-user-response Awaiting a response from the author team-Configurability platforms, toolchains, cquery, select(), config transitions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

incompatible_visibility_private_attributes_at_definition
5 participants