rules_haskell icon indicating copy to clipboard operation
rules_haskell copied to clipboard

Profiled builds of haskell_doctest fail

Open aherrmann opened this issue 4 years ago • 2 comments

Describe the bug Building a haskell_doctest target in profiling mode (-c dbg) fails.

To Reproduce

$ bazel build //tests/haskell_doctest:doctest-lib-all-success -c dbg
...
tests/haskell_doctest/Bar.hs:3:1: error:
    Could not find module ‘Foo’
    There are files missing in the ‘lib-a’ package,
    try running 'ghc-pkg check'.
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
3 | import Foo (foo)
  | ^^^^^^^^^^^^^^^^
...

Expected behavior The build should succeed.

Environment

  • OS name + version: Ubuntu 19.10
  • Bazel version: 2.1.0
  • Version of the rules: 04f22a04cb12f7782a9a2c581db5f4f564bf69fd

Additional context This seems to only affect modules that import other modules. While //tests/haskell_doctest:doctest-lib-all-success fails, //tests/haskell_doctest:doctest-lib succeeds. The difference is that the latter excludes the only module that has an import statement.

aherrmann avatar Jun 09 '20 10:06 aherrmann

I suppose you are using stack_snapshot, hence when using -c dbg, your package database only contains -prof versions (hence static) of the packages. (That's why GHC complains about missing files).

If you add -prof to doctest_flags, this issues disappears, but then doctest fails because it cannot load static libraries by definition (it uses ghci).

Possible solutions I'm thinking about:

  • build with -c dbg should provide dynamic and profiled libraries, hence doctest may load the dynamic ones.
  • bazel transition may be used to disable -c dbg on its dependencies.

guibou avatar Sep 03 '21 20:09 guibou

n.b., Still reproducible as of a464b7e with Bazel 4.2.1 (not surprising, given the above comment)

Xophmeister avatar Mar 29 '22 11:03 Xophmeister