From a0c37152be8276a62d83bd2a84e53ba09a26a220 Mon Sep 17 00:00:00 2001 From: Googler Date: Tue, 11 Oct 2022 09:42:23 -0700 Subject: [PATCH] Automated rollback of commit dadc49e437018f482640ed76fae5307daf9911a8. *** Reason for rollback *** Breaks Tensorflow. See https://github.com/bazelbuild/bazel/issues/16296 *** Original change description *** Apply graph_structure aspect across all edges RELNOTES: None. PiperOrigin-RevId: 480381529 Change-Id: Ied2f6b14a4b80e3c77691cf716c199b9c8a63f85 --- .../cc/experimental_cc_shared_library.bzl | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/main/starlark/builtins_bzl/common/cc/experimental_cc_shared_library.bzl b/src/main/starlark/builtins_bzl/common/cc/experimental_cc_shared_library.bzl index cccea324ec9e60..32483582fbfb09 100644 --- a/src/main/starlark/builtins_bzl/common/cc/experimental_cc_shared_library.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/experimental_cc_shared_library.bzl @@ -586,21 +586,11 @@ def _cc_shared_library_impl(ctx): def _graph_structure_aspect_impl(target, ctx): children = [] - # Collect graph structure info from any possible deplike attribute. The aspect - # itself applies across every deplike attribute (attr_aspects is *), so enumerate - # over all attributes and consume GraphNodeInfo if available. - for fieldname in dir(ctx.rule.attr): - if fieldname == "_cc_toolchain" or fieldname == "target_compatible_with": - continue - deps = getattr(ctx.rule.attr, fieldname, None) - if type(deps) == "list": - for dep in deps: - if type(dep) == "Target" and GraphNodeInfo in dep: - children.append(dep[GraphNodeInfo]) - - # Single dep. - elif type(deps) == "Target" and GraphNodeInfo in deps: - children.append(deps[GraphNodeInfo]) + # For now ignore cases when deps is of type label instead of label_list. + if hasattr(ctx.rule.attr, "deps") and type(ctx.rule.attr.deps) != "Target": + for dep in ctx.rule.attr.deps: + if GraphNodeInfo in dep: + children.append(dep[GraphNodeInfo]) # TODO(bazel-team): Add flag to Bazel that can toggle the initialization of # linkable_more_than_once.