From 0fb34c27a7808f62aa6a46081fb60dba339e91f6 Mon Sep 17 00:00:00 2001 From: Scott Cao Date: Thu, 14 Nov 2024 22:27:02 -0800 Subject: [PATCH] Always use label of LinkableGraph for traversal Summary: D65716309 added an alias for a cpp_library as a dep instead of a cpp_library directly and that broke `haskell_ghci` rules with the following error: ``` Error running analysis for `fbcode//common/hs/thrift/exactprint:ghci (cfg:linux-x86_64-fbcode-platform010-clang17-asan-ubsan-dev#f0bd86d3824be5aa)` Caused by: Traceback (most recent call last): File , in * fbcode/buck2/prelude/haskell/haskell_ghci.bzl:691, in haskell_ghci_impl omnibus_data = _build_haskell_omnibus_so(ctx) * fbcode/buck2/prelude/haskell/haskell_ghci.bzl:191, in _build_haskell_omnibus_so all_nodes_to_exclude = depth_first_traversal( * fbcode/buck2/prelude/utils/graph_utils.bzl:186, in depth_first_traversal return depth_first_traversal_by(graph_nodes, roots, lookup) * fbcode/buck2/prelude/utils/graph_utils.bzl:237, in depth_first_traversal_by fail("Expected node {} in graph nodes".format(node_formatter(node))) error: fail: Expected node fbcode//tools/build/sanitizers:fbcode-sanitizer-cpp (cfg:linux-x86_64-fbcode-platform010-clang17-asan-ubsan-dev#f0bd86d3824be5aa) in graph nodes --> fbcode/buck2/prelude/utils/graph_utils.bzl:237:13 | 237 | fail("Expected node {} in graph nodes".format(node_formatter(node))) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ``` The issue is that this graph traversal code confuses labels encoded in LinkableGraph objects (which would use the label of the aliased target) with labels of deps (which would use the label of the alias directly). Fix this by ensuring that this code consistently looks at labels of LinkableGraph objects. Reviewed By: iguridi Differential Revision: D65989756 fbshipit-source-id: 2fcc30fad197bfdf0f85975ab82f2da57567a2d4 --- haskell/haskell_ghci.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haskell/haskell_ghci.bzl b/haskell/haskell_ghci.bzl index 3ad2d24ad..f096c4a93 100644 --- a/haskell/haskell_ghci.bzl +++ b/haskell/haskell_ghci.bzl @@ -190,7 +190,7 @@ def _build_haskell_omnibus_so(ctx: AnalysisContext) -> HaskellOmnibusData: # Need to exclude all transitive deps of excluded deps all_nodes_to_exclude = depth_first_traversal( dep_graph, - [dep.label for dep in preload_deps], + [dep[LinkableGraph].label for dep in preload_deps if LinkableGraph in dep], ) # Body nodes should support haskell omnibus (e.g. cxx_library)