-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conflict between haskell_libraries with the same name in different directories #219
Comments
Here is a potential fix: f26cca4. @judah @mboes I discovered that GHC does not allow underscores or two dashes in a row in package names, so using (The CI failures is because we need to adjust the names of generated files in all the tests, so before starting with this boilerplate I decided to settle with what to use as the delimiter.) |
@mrkkrp, we should also take into account the I also think the |
@mrkkrp This form of encoding should always be injective, otherwise you'll get ambiguities. As it happens we already have an injective encoding snippet in the codebase: https://github.com/tweag/rules_haskell/blob/master/haskell/actions.bzl#L89-L91. This scheme is taken from the Bazel source code itself, so I suggest reusing it everywhere, just like GHC uses "z-encoding" everywhere. See here for the original source. |
The problem here is that this thing, package id, should be a valid package id that GHC accepts. GHC however does not accept underscores or any tricky things like two dashes in a row. In other words, there is no way to achieve injectivity here because the set of names GHC accepts is smaller than the set of possible package names. Which means, we will lose some information when we obtain GHC package id from bazel package name, which means there will always be potential for ambiguity. That said, this is a good catch by @judah, I'm already experimenting with this. So far I think we indeed could use something similar to that existing mangling function:
Note that still, particularly perverted package names will have the potential for clashing, e.g. I can have two packages: |
I'll go with this, probably as good as you can get here:
|
Of course we can! GHC's z-encoding is an example of that: linkers only want |
Or we could just require unique package names. It's not really any different from existing systems. |
Example:
9039058
A binary depends on two
haskell_library
rules with the same name:tests/library-deps/sublib:sublib
andtests/library-deps:sublib
. This fails:It conflicts with tests/library-deps/sublib:sublib; in fact,
renaming one of the
sublib
rules to, e.g.,...:sublibA
lets the build succeed.The relevant code is here:
rules_haskell/haskell/actions.bzl
Line 784 in 9a2ba48
We should be able to change that function to make a package name that includes the ctx.label's package and workspace_root. (I'm not sure at the moment whether we'd need to escape slashes like we do here:
rules_haskell/haskell/actions.bzl
Line 88 in 9a2ba48
The text was updated successfully, but these errors were encountered: