rules_haskell icon indicating copy to clipboard operation
rules_haskell copied to clipboard

Allow to define template Haskell dependencies separately

Open aherrmann opened this issue 5 years ago • 2 comments

Is your feature request related to a problem? Please describe. Right now Haskell compilation for haskell_library|binary|test, i.e. haskell/private/actions.compile.bzl, requires interface files, object files, and linked libraries of dependencies, as well as direct and transitive C libraries as inputs. The reason is that the target may contain template Haskell code in which case GHC needs to load some of these linked libraries at compile time.

However, in many cases the dependency on linked libraries is not necessary and disables potential build parallelism as well as cache hits if interface files did not change but linked libraries did.

Additionally, the fact that there is no distinction between regular dependencies and template Haskell dependencies prevents us from making runtime dependencies (data attribute) of template Haskell dependencies available during compilation. See https://github.com/tweag/rules_haskell/issues/1337#issuecomment-650345817.

Describe the solution you'd like Add a th_deps attribute to haskell_library|binary|test that allows to distinguish regular and template Haskell dependencies as described above.

Describe alternatives you've considered In the specific case of data dependencies of template Haskell the issue can be worked around with extra_srcs and CPP as described here.

aherrmann avatar Jul 01 '20 13:07 aherrmann

N.B. it would be great if this could apply both to haskell_repl and haskell_library targets.

patrickt avatar Sep 08 '20 13:09 patrickt

This is related to https://github.com/tweag/rules_haskell/issues/878.

Describe alternatives you've considered Ideally we would list Template Haskell dependencies separately, in a new attribute called compile_only_deps or similar.

aherrmann avatar Feb 15 '22 17:02 aherrmann