stack_snapshot: Precise extra dependencies - #1068
Conversation
|
Really nice! This fixes a similar error on my side. |
GHC doesn't normalize paths. E.g. due to package environment files and |
d528c78 to
14272ac
Compare
|
rebased on master |
14272ac to
70b5e9b
Compare
thufschmitt
left a comment
There was a problem hiding this comment.
Just one minor comment, but apart from that, 👍
eda5b17 to
fe8e2b1
Compare
The problem is that |
|
#385 and #1008 showed how dangerous it can be to invoke precedent to name fields, but to use a different attribute type. It's usually a sign that the intended semantics is different from the one in precedents, in which case we should really use a different attribute name. So given your new semantics, I'm wary of keeping Since include dirs (and probably library dirs) are transitive, as noted in my previous comment, we're not gaining much cachability by letting the user state dependencies in a more fine grained way. The original motivation for this change was the absence of dedup was leading to long command-line length. Couldn't we instead try deduping ourselves in some place appropriate, instead of changing the API? |
We can try to deduplicate the list in the
I'm happy to choose a different name. How about
Note, this PR does not change those semantics. Cabal will still accumulate the include paths from all transitive package dependencies.
That depends on the particular library dependency. E.g. Granted, most use-cases don't depend on this feature, and if it's really required the same can be achieved using |
Hm, that's a good point. Now that we have |
That's an interesting idea. It places |
I like the idea. But it looks like we'll run into other difficulties if we take that route. We have to state the snapshot twice. But worse, we need a circular dependency between the I guess |
Agreed, that's a bit of a hack.
Okay, I've renamed the |
7f57a6c to
5c48f3d
Compare
Precisely control which packages to add system dependencies to.
5c48f3d to
f7333bc
Compare
Precisely control which packages to add additional dependencies to.
This PR changes
stack_snapshotso that thedepsattribute no longer takes a list of targets to add as dependencies to all packages in the snapshot. Instead, it takes a dictionary mapping Stack package names to lists of targets to precisely control which dependencies to add to which package in the snapshot.Motivation
This change is motivated by #1062. Simply adding all
depsto all packages in the snapshot has the effect that the library-dirs and include-dirs of thesedepswill be added to the package-db entry of each package in the snapshot. GHC doesn't deduplicate the include-dirs and this leads to overflowing the maximum command-line length, even on Linux.Unfortunately, we cannot avoid adding to the library-dirs and include-dirs of snapshot packages that actually depend on extra libraries. Their cabal files will list
extra-librariesandincludes, andSetup.hsenforces that these can be found in the library-dirs and include-dirs of the resulting package configuration.An advantage is that this thins the dependency graph and gives the user more control. The downside is that
stack_snapshotbecomes more cumbersome to use.Alternatives
An alternative approach would be to automatically detect which snapshot packages depend on which extra libraries and only add the extra dependencies where necessary. This would require either parsing the Cabal files, or for
stack dot(orstack ls dependencies json) to listextra-librariesdependencies. However, that would also require some user input or heuristics to map fromextra-librariesto Bazel targets, and would assume that allincludesare provided by targets providingextra-libraries.Closes #1062