Skip to content

Commit 8c3abd3

Browse files
fmeumcopybara-github
authored andcommitted
Fix label comparison in cc_helper.bzl
Labels are value objects and comparing just their name and packages can result in false positives across different repos. Closes #26359. PiperOrigin-RevId: 800356246 Change-Id: If17f37207dcc7329c19e65b7d1531f910ac4a286
1 parent f9877f7 commit 8c3abd3

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

cc/common/cc_helper.bzl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -901,10 +901,6 @@ def _copts_filter(ctx, additional_make_variable_substitutions):
901901
# Expand nocopts and create CoptsFilter.
902902
return _expand(ctx, nocopts, additional_make_variable_substitutions)
903903

904-
# This should be enough to assume if two labels are equal.
905-
def _are_labels_equal(a, b):
906-
return a.name == b.name and a.package == b.package
907-
908904
def _map_to_list(m):
909905
result = []
910906
for k, v in m.items():
@@ -925,7 +921,7 @@ def _calculate_artifact_label_map(attr_list, attr_name):
925921
if "." + artifact.extension not in extensions.CC_HEADER:
926922
old_label = artifact_label_map.get(artifact, None)
927923
artifact_label_map[artifact] = attr.label
928-
if old_label != None and not _are_labels_equal(old_label, attr.label) and (
924+
if old_label != None and old_label != attr.label and (
929925
"." + artifact.extension in extensions.CC_AND_OBJC or attr_name == "module_interfaces"
930926
):
931927
fail(

0 commit comments

Comments
 (0)