-
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
Calculate IPID from source before building #2752
Conversation
The only problematic thing is that when we call `cabal clean` or `cabal haddock` (and possibly others), _without_ first having called `configure`, we attempt to build the setup script without calling the solver at all. This means that if you do, say, cabal configure cabal clean cabal clean for a package with a custom setup script that really needs setup dependencies (for instance, because there are two versions of Cabal in the global package DB and the setup script needs the _older_ one), then first call to `clean` will succeed, but the second call will fail because we will try to build the setup script without the solver and that will fail.
This happened independently in a number of places, which was bad; and was about to get worse with the base 3/4 thing.
Never consider flag choices as independent from their package.
(previously the default was the topdown solver for GHC < 7). Also adds a deprecation warning when the topdown solver is selected.
Correct the link - package version policy.
This is consistent with the the current -auto-all behavior. This fixes haskell#2479.
cabal check will fail on -fprof-auto passed as a ghc-option
Fixed bash completion for sandbox subcommands
Slightly better error message in case of backjump limit reached
…r names appear unexpectedly in compiler output (fixes haskell#2542) This fixes cases where strings like "ld" appear in compiler output on lines that have nothing to do with the linker command invocation.
bootstrap.sh: fixes linker matching to avoid cases where tested linker names appear unexpectedly in compiler output (fixes haskell#2542)
I was the one who introduced that bit, and it seems like well may have caused more trouble than it helped... so, sorry :( Anyway, clang has since then grown the ability to `-print-prog-name`, so I've done away with all that grepping through -### stuff. @creswick @23Skidoo, could you see if this works for you?
Rewrite linker check to avoid grepping "ld"s.
Add Functor, Foldable and Traversable instances to Condition
Paths_ module: don't require base >= 4.
This reverts commit c9a7735.
Print a more friendly message when http_proxy is down.
OK, a few more problems which I've noticed when testing this revision with GHC:
I can contribute fixes for these. |
This flag (through a terrible hack) also supports install directory variables (e.g. $pkgver). Depends on PR haskell#2752. Signed-off-by: Edward Z. Yang <[email protected]>
Another thing todo: need to make it possible for cabal-install to get the IPID. (For build paths and stuff.) I think I'm going to go ahead and implement this. UPDATE: This doesn't seem to be critical path, cabal-install seems to work fine without the IPID. |
So, the easiest way to fix this is to change our invocation of 'ghc-pkg' from 'reregister' to 'register'. But this means we have to be careful to unregister a package from the inplace database before attempting to register it again. While implementing this, I noticed that the UniqueIPID test was a bit bad: it was registering in the GLOBAL user database (it's passing the |
Currently, this patch applies new IPID calculation to ALL versions of GHC (it's not feature gated.) This is desirable because it means that Cabal doesn't have to maintain two feature paths (sdist computed IPIDs and ABI hash IPIDs) and we can simplify code accordingly. But there are BC considerations... GHC 7.8 and earlier, prior to this patch. There's no support for multiple instances in the package database; so we want ghc-pkg to complain if we install the same package name/version pair multiple times. The current behavior is that './Setup register GHC 7.8 and earlier, after this patch. Let me first describe the state from this literal patch, then describe some possible alternative worlds we can live in. With this patch, Now for alternatives. Earlier this thread I proposed that we refuse to register a package unless you Another possibility is to just not bother; @ttuegle has suggested that GHC 7.10, prior to this patch. Primary difference: Cabal computes a "package key", which is then passed to GHC for compilation to be used for symbol names and type equality. The default behavior of GHC 7.10, after this patch. Well, technically this patch doesn't do it but the companion patch #2748 enables multi instances. With these two patches, it means that if we register an existing IPID, we will overwrite it, but otherwise if it doesn't already exist, it will just be added to the database (without deleting any existing packages). As a refinement, if we want to prevent overwriting an existing IPID, we can just change our invocation of My recommendation. It seems most uniform if we continue to use UPDATE: One complication: GHC 7.6's |
OK implemented here #2792 |
OK, another major bug: cabal-install needs to get the IPID so that it can compute the install directory correctly. |
Thought about this some more, as before there are delicate backwards compatibility considerations, stemming from the fact that a './Setup' executable (in the case of Custom build type) can be compiled with an older version of Cabal. The ideal situation is that the installation directory is based off of the installed package ID. OK, but how do we get the IPID from the configure step where it is currently computed? There are two options:
In fact, it seems that we'll have to do a combination of both. Since there's no support for getting an IPID from EDIT: But method (2) doesn't work, because the library directory is configured during configure (which is when the IPID is calculated). So if |
Well, you can require it to be compiled against a recent version. We do this for |
Well, this code is going to apply to all packages being built with Cabal, so an admonition otherwise would basically prevent people from using Setup with old Cabal ever. Not good. |
I've pushed a fix for this problem. Seems to work OK. |
Haha! Testing caught a file handle exhaustion problem (only GHC7.8 and earlier). I know what the problem is, cooking up a fix. |
OK, so I fixed the FD exhaustion problem by forcing the fingerprint, but now there is a second problem where |
QQ: If I want to test (including @ezyang's fixes), which commit should I be testing? |
Use my branch cabal-no-pks https://github.com/ezyang/cabal/tree/cabal-no-pks |
I've tried that branch on a few of my own (smallish) projects, and all seems to work OK. (Not that I'm doing anything particularly advanced, mind you.) Am I right in thinking that the "global" package database gets ignored if you've previously built dependencies for your project and you then create a sandbox to build a project in? (Hope that sentence makes sense, I'm on painkillers ATM. Damn teeth!) That seems to be the case for one of my multi-package projects. (It's not a big deal, just a little observation that I thought I'd get cleared up.) Overall, I'm very excited to see this work (hopefully) go into master soon! Hopefully we can reengineer/reimagine sandboxes to be much much simpler once it's in. |
... and of course, just as I say that, I hit a little snag:
(FWIW, the scenario here is that I initially ran "cabal install ./cqrs-memory" and then ran "cabal install ./cqrs-memory --enable-tests". Apparently these "hash" to the same IPID.) One can argue whether the unregister/reinstall shouldn't just happen automatically, but the error message could certainly be improved. I tried "the obvious thing", namely
but that doesn't work because ghc-pkg doesn't understand the hash->pkg link. So I tried
but that doesn't work either. Interestingly, What command am I supposed to be running to get rid of the already-registered "duplicate"? (Incidentally, the error message itself should probably show the precise command that you can run, if any.) |
Oh, I bet it's because the sandbox logic isn't unregistering packages from the sandbox database. (That's also why ghc-pkg isn't showing it up: the package is in the sandbox. Use |
Oh, right: Here's the command that works:
The message should probably just print that command? |
I had already done much of the work (at vagrawal@adf17a7 and https://phabricator.haskell.org/D1119). In short, it adds various nix-like facilities like using central package DB for all packages, garbage collection, allowing multiple instances (already in this patch), non-mutability without GC and also many other improvements like uninstalling and upgrading and creating lightweight sandbox manually with I had written a sort of concise specification for that patch for my mentor once. You can check it out at https://gist.github.com/fugyk/bea5e97e9f24c51c0174. The last commit was done in hurry so the current patch might not work as expected.
There are quite some known snags in this patch. I will try to list some of them here:
I have to say, I am not in favour of merging package key with IPID for the above reasons, but I guess it is needed for some simplicity in the infrastructure. |
This particular thing is probably not a huge issue, I think. For most people who are not on a rolling release distribution (no idea about Windows here), their LLVM (or whatever) probably isn't going to change in any significant way. |
|
It's not very elegant, but there's no way around it, I think. |
@23Skidoo : Thanks, that's a bit more elegant :). About the command line flags... what about just doing a really dumb thing and e.g. sorting + uniq'ing them and then hashing? I think it's probably better here to just assume that all command line flags have an effect on the output -- exceptions could then be explicitly removed from that list if deemed necessary. That way you'd at least always get rebuilds when appropriate at the cost of sometimes getting rebuilds when they actually technically weren't necessary. I think that's a better solution than one where you risk not getting rebuilds when you should. Does that make sense? EDIT: Actually, command line flag order might even matter -- I'm not sure. |
See also #2830 |
9833a34
to
2749c38
Compare
This PR has been closed due to github's bug. I was trying to update my email address in git for submission of code samples in GSoC website, but I have overwritten all of the history due to carelessness. But after reverting back, this PR is not updating and is in permanently closed status. I have contacted github support and got the reply that it can't be opened back and I have to create a new PR. I am not opening a new PR as both of the closed PR is superseded by @ezyang's PR. |
This patch allows cabal to calculate IPID before building the package. The benefits to this method is that we can stop a duplicate compilation by looking at IPID and that IPID generated by this method is unique and changes with source (and also #2745, so now it changes only installation IPID and not inplace IPID when doing cabal build). Now this patch generates IPID strictly from source(by calculating hash of sdist), but there can still be mutations in compiled package without changing the source. It is not immediately clear as which thing is best to include in the hash but there are some candidates:
Also I had done some work to change the library path to IPID(not very hard), but then found out a recent change by @ezyang having a more broad plan including backpack, so I have reverted but I think it is a better way to go(and it will bring one step closer to #2745). Please comment if I can replace it. I can also do locking before building part as suggested by @ttuegel. Please let me know if it is a good way to go as @dcoutts said that it is not critical and can be left for now.