Description
Describe the bug
I have a project with two sublibraries, one of which depends on the other. Omitting irrelevant fields, the layout is thus:
library foo
...
hs-source-dirs: src
library bar
...
build-depends: foo
hs-source-dirs: src
Notably, we see that both foo
and bar
share the same hs-source-dirs
. When I try to do cabal build
, the dependency of bar
on foo
is not detected: instead, I get GHC warnings about files needed for compilation not being noted as dependencies.
This can be fixed by changing the hs-source-dirs
to this:
library foo
...
hs-source-dirs: foo
library bar
...
build-depends: foo
hs-source-dirs: bar
or even this:
library foo
...
hs-source-dirs: src/foo
library bar
...
build-depends: foo
hs-source-dirs: src/bar
To Reproduce
Steps to reproduce the behavior:
Set up two sublibraries as above, then call
$ cabal build
Expected behavior
Dependencies should be detected properly, and no warnings from GHC should be showing up due to 'missing' files needed for compilation.
System information
- Arch Linux
Cabal
3.14.1.1 (same ascabal-install
version)- GHC 9.8.2
Additional context
This behaviour is quite long-standing: I only discovered this was a problem by finding a response from years ago specifying that sharing hs-source-dirs
like this would trigger this behaviour.