-
Notifications
You must be signed in to change notification settings - Fork 696
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
Some ghc-options should not be considered part of build hash #4247
Comments
How about adding a command to GHC that tells cabal which flags should influence the hash? For old versions this knowledge would still have to be included but at least then we don't need to chase after GHC. |
That's an interesting idea. The relevant code in GHC is It's worth noting GHC's recompilation avoidance doesn't always get this right. See #3891. So it' still challenging to compute the flags, even on GHC's side ;) |
Yep, just bumped into this when I tried to enable |
I also hit this when I did |
I think that |
No-code is great for getting something to compile. It's much faster than anything else I know of, and significantly speeds up the compile-fix-errors loop. The ideal situation in my mind would be to have a |
I think this issue is a bit stuck in idealism over pragmatism. As far as I can tell everyone agrees that:
So now this ticket is stuck on the "devise scheme to figure out which flags can be safely used". I (of course) support that idea, but would like to argue that we shouldn't let "perfect" be the enemy of "good". Since we need a code-path to filter out flags anyway, why add said code and, for now, hard-code a set of common flags that can be safely filtered out. Then once we figure out a more sustainable/future-proof way of dealing with GHC options that don't affect output we just have to drop the hard-coded set and replace it with whatever method people come up with. This would make |
@merijn Construction of cabal/cabal-install/Distribution/Client/ProjectPlanning.hs Lines 3496 to 3529 in 066b2a1
As a first approximation you could strip irrelevant options with something like this: |
to be fair, we do already hardcode knowledge about GHC (and other compilers) in |
ok, looking at the code the hashing appears to initiate in one single point: |
ok, so as a bunch of you probably already noticed in #hackage I had a bit of a setback in that most of the datatypes are being serialised for the rebuild cache and we can't easily serialise functions, making things Difficult (TM). The earlier places I suggested for adding code are just not really easily doable without either 1) gimping the functionality or 2) requiring major work. But there's is a hope. After some gym downtime of not staring at cabal code I've found another path: Two open questions:
|
…grams from the new-build hash input to reduce redundant recompilation. See haskell#4247.
Ok, I made a (surprisingly small and minimal) PR that adds the prerequisite infrastructure for filtering tool version specific command-line arguments from the new-build hash computation. Next step will be to extend the builtin programs in |
In other news, |
I'm working on a filter for GHC >=8.0 and there are some flags of which I'm not sure whether they can be ignored by new-build: Mystery flags (not documented in GHC user guide)
SafeHaskell
Makefile dependency output
Misc
|
|
Honourable mention in the category "fucking up beautiful ideas": Specifically, should Additionally, if we deem that So I'm leaning somewhat to " |
Some new flags added in 8.4 I'm unsure about: |
Also, the updated PR in #5237 lets me work around the GHC 8.4 actually adds |
Initial implementation of normalising flags for haddock and GHC 8.0-8.4 (modulo buggy handling of -Werror in 8.4) is here: https://github.com/merijn/cabal/blob/filter-flag-prototype/Cabal/Distribution/Simple/Program/GHC.hs#L51-L216 |
…grams from the new-build hash input to reduce redundant recompilation. See #4247.
Ping to everyone in this thread to have a look at #5266 and chime in if it looks ok and/or help dogfood it. |
Ok, I've been using this code for about a week now with no issues, none of the people in the original issue or that I've asked have objected, so unless someone has a complaint before tomorrow I'm merging this. |
On a related note, fixing this so that local packages exhibit the same behaviour looks to be a trivial fix. Right now any configuration change will always trigger local packages to rebuild, so |
Do it. We can always improve if we find things to be missing or wrong. |
The main downside of applying this code to local packages would be that enabling a warning flag would no longer toggle every local package to build, and thus you lose "easily verify some warning doesn't occur" functionality we now (unintentionally) have. OTOH, adding Although adding -Werror would trigger rebuilding your entire transitive dependency tree too, which is a bit unfortunate. Someone more knowledgeable about |
#5287 is updated. Now also applies all the flag ignoring stuff (including ghci options) to in-place packages and adds a new --repl-options to pass ephemeral REPL flags to (new-)repl. |
This is related to #3883 but it is a distinct problem so I wanted to make a ticket for it by itself.
Some ghc-options don't have any affect on build outputs, e.g.,
-v
, but if someone specifies it viaghc-options
, e.g., in their cabal.project file, it will cause us to rebuild all deps becauseelabProgramArgs
has changed, which changes the hash, which means we need to rebuild. This is not good.It's unclear how to go about fixing this. We could build in knowledge to cabal-install what arguments should and should not be hashed. But we'd be constantly chasing the most up-to-date set, and there would always be some time where we wouldn't have gotten it exactly right. Alternately, we could let the user specify, "use this option when building, but don't include it in the hash." But here it seems easy for a user to shoot themselves in the foot, ESP when it's a package being installed to the global store; worst case scenario you'd have to blow away the entire store because you corrupted it.
CC @bgamari who reported this most recently.
The text was updated successfully, but these errors were encountered: