-
Notifications
You must be signed in to change notification settings - Fork 701
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
Installed package IDs are not unique #2830
Comments
/cc @ezyang |
The short answer is, Nix-like Cabal is going to fix this. The longer answer is, it looks like GHC's ABI calculation (which is used to compute is behaving differently than you might expect. Let me first explain how ABI calculation works. When you depend on an external package, there are two ways that this factors into the ABI: (1) for every transitively reachable package, GHC will include the source package ID (GHC 7.8)/package key (GHC 7.10) in the ABI hash, and (2) for every used declaration/directly imported module, GHC will include the declaration/module hash in the ABI hash. Notice that (2) is completely sufficient to ensure that GHC doesn't make an unsound compilation. So I sort of suspect dep_pkgs were sort of added as some sort of hack to make sure that the ABI changed if you changed versions. So, as you have observed, by the definition of ABI, it doesn't have to change if an upstream package changes, but all of the things the module in question cares about don't change (are ABI compatible). But this can lead to the situation you described here, where you really want the IPIDs to say something about how the package database is set up, but Cabal gets the IPID from GHC, and GHC really doesn't care about that... (as long as it can find the right package ids/package keys in the non-ignored portion of the database). So how do you fix this? Stop using the ABI hash for IPIDs. Just make it something that is entirely Cabal managed. You pick your own naming policy. Done. |
@ezyang Thanks for the explanation. Closing, since the fix is in the works. |
Can we get this cited somewhere reasonable? I was pretty surprised to find out ABIs didn't track depends, though it made sense after I looked at the code. |
Not sure what is the appropriate place. Cabal documentation is a bit higher-level. FAQ, maybe? |
I'm under the impression the the ipids for registered packages are generated by Cabal, but I may be mistaken. If in fact this is done by GHC, let me know and I'll move the issue to GHC Trac.
Original issue is at commercialhaskell/stack#992. Essentially:
foo-1
andbar-1
, where bar depends onfoo-1
, and registered them both into package database A. They ended up with hashes ABC and DEF.foo-1
. Thenfoo-1
andbar-1
were both compiled and registered into package database B. As expected,foo-1
ended up with a different hash (HIG), butbar-1
ended up with the same DEF hash, even though it was installed in a different location and depended on a different installed copy of foo.foo-1-ABC
andbar-1-DEF
, with both package databases A and B available. GHC selected thebar-1-DEF
from package database B, which requiredfoo-1-HIG
, which was not included (and conflicted withfoo-1-ABC
), leading to a build failure.I worked around this in stack by unregistering unneeded packages from package database B (known there as the local database). However, I think I've seen evidence that this situation can occur when the Haskell Platform is being used, since you can end up with two copies the same hash with different dependencies.
As I see it, there are two answers to this:
The text was updated successfully, but these errors were encountered: