Skip to content

Commit

Permalink
Flip --incompatible_visibility_private_attributes_at_definition
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Aug 25, 2023
1 parent 32d018e commit 7a5201e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
26 changes: 14 additions & 12 deletions site/en/concepts/visibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,18 +234,20 @@ every instance of that rule. For example, a `cc_library` rule might create an
implicit dependency from each of its rule targets to an executable target
representing a C++ compiler.

Currently, for visibility purposes these implicit dependencies are treated like
any other dependency. This means that the target being depended on (such as our
C++ compiler) must be visible to every instance of the rule. In practice this
usually means the target must have public visibility.

You can change this behavior by setting
[`--incompatible_visibility_private_attributes_at_definition`](https://github.com/bazelbuild/proposals/blob/master/designs/2019-10-15-tool-visibility.md){: .external}. When enabled, the
target in question need only be visible to the rule declaring it an implicit
dependency. That is, it must be visible to the package containing the `.bzl`
file in which the rule is defined. In our example, the C++ compiler could be
private so long as it lives in the same package as the definition of the
`cc_library` rule.
The visibility of such an implicit dependency is checked with respect to the
package containing the `.bzl` file in which the rule is defined. In our example,
the C++ compiler could be private so long as it lives in the same package as the
definition of the `cc_library` rule.

You can change this behavior by disabling
[`--incompatible_visibility_private_attributes_at_definition`](https://github.com/bazelbuild/proposals/blob/master/designs/2019-10-15-tool-visibility.md){: .external}.
When disabled, implicit dependencies are treated like any other dependency.
This means that the target being depended on (such as our C++ compiler) must be
visible to every instance of the rule. In practice this usually means the target
must have public visibility.

If you want to restrict the usage of a rule to certain packages, use
[load visibility](#load-visibility) instead.

## Load visibility {:#load-visibility}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ public final class BuildLanguageOptions extends OptionsBase {

@Option(
name = "incompatible_visibility_private_attributes_at_definition",
defaultValue = "false",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS},
metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
Expand Down Expand Up @@ -879,7 +879,7 @@ public StarlarkSemantics toStarlarkSemantics() {
public static final String INCOMPATIBLE_UNAMBIGUOUS_LABEL_STRINGIFICATION =
"+incompatible_unambiguous_label_stringification";
public static final String INCOMPATIBLE_VISIBILITY_PRIVATE_ATTRIBUTES_AT_DEFINITION =
"-incompatible_visibility_private_attributes_at_definition";
"+incompatible_visibility_private_attributes_at_definition";
public static final String INCOMPATIBLE_TOP_LEVEL_ASPECTS_REQUIRE_PROVIDERS =
"-incompatible_top_level_aspects_require_providers";
public static final String INCOMPATIBLE_DISABLE_STARLARK_HOST_TRANSITIONS =
Expand Down

0 comments on commit 7a5201e

Please sign in to comment.