Skip to content

Commit

Permalink
Fix call to attr_deps_haskell_lib_infos
Browse files Browse the repository at this point in the history
Summary:
Haskell builds must always include the `template_deps` lib infos right?

Leaving them out makes `common/hs/manifold:manifold_ghci` fail at evaluation time with:

```
$ buck2 run mode/dev common/hs/manifold:manifold_ghci
GHCi, version 8.8.3: https://www.haskell.org/ghc/  :? for help
package flags have changed, resetting and loading new packages...
Loaded GHCi configuration from /tmp/manifold_ghci-3813794/start.ghci
[1 of 5] Compiling Manifold.Exception ( common/hs/manifold/Manifold/Exception.hs, interpreted )
[2 of 5] Compiling Manifold.Metadata ( common/hs/manifold/Manifold/Metadata.hs, interpreted )
[3 of 5] Compiling Manifold.Option  ( common/hs/manifold/Manifold/Option.hs, interpreted )
[4 of 5] Compiling Manifold.HTTP    ( common/hs/manifold/Manifold/HTTP.hs, interpreted )
[5 of 5] Compiling Manifold.Client  ( common/hs/manifold/Manifold/Client.hs, interpreted )
Ok, five modules loaded.
*Manifold.Client>  enumerateAll [startKey "ovrsource"] "glean_databases" ""
unknown package: fbcode-common-hs-mangle-library
```

However, when we fix the code to include them we see a new error:
```
BUILD FAILED
Error running analysis for `fbcode//common/hs/manifold:manifold_ghci (cfg:linux-x86_64-fbcode-platform010-no-san#17ac72a600bb636a)`

Caused by:
    Traceback (most recent call last):
      File <builtin>, in <module>
      * fbcode/buck2/prelude/haskell/haskell_ghci.bzl:657, in haskell_ghci_impl
          symlinked_things = ctx.actions.symlinked_dir(
    error: Multiple artifacts and/or metadata files are declared at the same output location `manifold_ghci.packages/fbcode-common-hs-util-addressable` declared at `fbcode/buck2/prelude/haskell/haskell_ghci.bzl:657:32-660:14`.
       --> fbcode/buck2/prelude/haskell/haskell_ghci.bzl:657:32
        |
    657 |               symlinked_things = ctx.actions.symlinked_dir(
        |  ________________________________^
    658 | |                 lib_symlinks_root,
    659 | |                 lib_symlinks,
    660 | |             )
        | |_____________^
        |
```

The problem is that there are two different configurations of `common/hs/util:addressable` being pulled:
```
buck2 cquery 'allpaths(common/hs/manifold:manifold, common/hs/util:addressable)'
Buck UI: https://www.internalfb.com/buck2/a8612b6b-0237-417f-8dc8-0dee1fa6bb5c
Network: Up: 0B  Down: 0B
Jobs completed: 2. Time elapsed: 0.2s.
fbcode//common/hs/manifold:manifold (cfg:linux-x86_64-fbcode-platform010-asan-ubsan-dev#2092a9d2d16c9cde)
fbcode//servicerouter/client/hs:client (cfg:linux-x86_64-fbcode-platform010-asan-ubsan-dev#2092a9d2d16c9cde)
fbcode//servicerouter/client/hs:client-ServiceRouter/Client.hsc (cfg:linux-x86_64-fbcode-platform010-asan-ubsan-dev#2092a9d2d16c9cde)
fbcode//servicerouter/client/hs:client-ServiceRouter/Client.hsc-deps (cfg:linux-x86_64-fbcode-platform010-asan-ubsan-dev#2092a9d2d16c9cde)
fbcode//common/hs/util:hs_struct (cfg:linux-x86_64-fbcode-platform010-asan-ubsan-dev#2092a9d2d16c9cde)
fbcode//common/hs/util:hs_std_variant (fbcode//buck2/platform/execution:linux-x86_64#88b1cd0143d85f1e)
fbcode//common/hs/util:hs_set (fbcode//buck2/platform/execution:linux-x86_64#88b1cd0143d85f1e)
fbcode//common/hs/util:hs_option (fbcode//buck2/platform/execution:linux-x86_64#88b1cd0143d85f1e)
fbcode//common/hs/util:hs_map (fbcode//buck2/platform/execution:linux-x86_64#88b1cd0143d85f1e)
fbcode//common/hs/util:hs_array (fbcode//buck2/platform/execution:linux-x86_64#88b1cd0143d85f1e)
fbcode//common/hs/util:addressable (fbcode//buck2/platform/execution:linux-x86_64#88b1cd0143d85f1e)
fbcode//common/hs/util:hs_struct-Foreign/CPP/HsStruct/Unsafe.hsc (cfg:linux-x86_64-fbcode-platform010-asan-ubsan-dev#2092a9d2d16c9cde)
fbcode//common/hs/util:hs_struct-Foreign/CPP/HsStruct/Unsafe.hsc-deps (cfg:linux-x86_64-fbcode-platform010-asan-ubsan-dev#2092a9d2d16c9cde)
fbcode//common/hs/util:hs_struct-Foreign/CPP/HsStruct/Types.hsc (cfg:linux-x86_64-fbcode-platform010-asan-ubsan-dev#2092a9d2d16c9cde)
fbcode//common/hs/util:hs_struct-Foreign/CPP/HsStruct/Types.hsc-deps (cfg:linux-x86_64-fbcode-platform010-asan-ubsan-dev#2092a9d2d16c9cde)
fbcode//common/hs/util:hs_std_tuple (cfg:linux-x86_64-fbcode-platform010-asan-ubsan-dev#2092a9d2d16c9cde)
fbcode//common/hs/util:hs_option (cfg:linux-x86_64-fbcode-platform010-asan-ubsan-dev#2092a9d2d16c9cde)
fbcode//common/hs/util:addressable (cfg:linux-x86_64-fbcode-platform010-asan-ubsan-dev#2092a9d2d16c9cde)
```
{https://www.internalfb.com/intern/graphviz/?paste=P1030375195}

TODO: fix the new error

Reviewed By: simonmar

Differential Revision: D52778012

fbshipit-source-id: e070f40b02c81b6522055b257e66120b03de4f2c
  • Loading branch information
Pepe Iborra authored and facebook-github-bot committed Jan 15, 2024
1 parent 80ce3f6 commit 56b2e03
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
4 changes: 2 additions & 2 deletions prelude/haskell/haskell.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ load(
load(
"@prelude//haskell:util.bzl",
"attr_deps",
"attr_deps_haskell_link_infos_sans_template_deps",
"attr_deps_haskell_link_infos",
"attr_deps_merged_link_infos",
"attr_deps_profiling_link_infos",
"attr_deps_shared_library_infos",
Expand Down Expand Up @@ -628,7 +628,7 @@ def haskell_library_impl(ctx: AnalysisContext) -> list[Provider]:
preferred_linkage = Linkage("static")

# Get haskell and native link infos from all deps
hlis = attr_deps_haskell_link_infos_sans_template_deps(ctx)
hlis = attr_deps_haskell_link_infos(ctx)
nlis = attr_deps_merged_link_infos(ctx)
prof_nlis = attr_deps_profiling_link_infos(ctx)
shared_library_infos = attr_deps_shared_library_infos(ctx)
Expand Down
10 changes: 0 additions & 10 deletions prelude/haskell/util.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,6 @@ def attr_deps_haskell_link_infos(ctx: AnalysisContext) -> list[HaskellLinkInfo]:
],
)

# DONT CALL THIS FUNCTION, you want attr_deps_haskell_link_infos instead
def attr_deps_haskell_link_infos_sans_template_deps(ctx: AnalysisContext) -> list[HaskellLinkInfo]:
return filter(
None,
[
d.get(HaskellLinkInfo)
for d in attr_deps(ctx)
],
)

def attr_deps_haskell_lib_infos(
ctx: AnalysisContext,
link_style: LinkStyle,
Expand Down

0 comments on commit 56b2e03

Please sign in to comment.