Skip to content

Commit

Permalink
Always use label of LinkableGraph for traversal
Browse files Browse the repository at this point in the history
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 <builtin>, in <module>
      * 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
  • Loading branch information
Scott Cao authored and facebook-github-bot committed Nov 15, 2024
1 parent fb8b7ac commit 0fb34c2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion haskell/haskell_ghci.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0fb34c2

Please sign in to comment.