Skip to content
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

Lint error with also files and digest+modtime checking #427

Closed
ndmitchell opened this issue Mar 4, 2016 · 8 comments
Closed

Lint error with also files and digest+modtime checking #427

ndmitchell opened this issue Mar 4, 2016 · 8 comments

Comments

@ndmitchell
Copy link
Owner

Given the test suite fragment:

[obj "rewrite1",obj "rewrite2"] &%> \outs -> do
    alwaysRerun
    forM_ outs $ \out -> writeFile' out "rewrite"

The run:

build ["rewrite1","--digest-and"]
build ["rewrite1","--digest-and","--lint","--sleep"]

Will fail with a lint error. The sequence of events the second time is:

  • I load rewrite1 and determine the file has not changed modtime or hash, but that I depend on rewrite1 rewrite2.
  • I load rewrite1 rewrite2 and determine the files have not changed modtime or hash, but that I depend on alwaysRerun which has changed.
  • I rerun rewrite1 rewrite2 which updates both files in their modtime but not hash, so I report that neither file has changed.
  • Since nothing has changed, I record that rewrite1 has not changed and continue.

This bug is reduced down from snowleopard/hadrian#206

Two possible solutions:

  • Also files should not be storing the timestamp twice, which is a (minor) performance issue as well. There are a few plans around to fix that.
  • I could check the storedValue after building all the dependencies. That seems a reasonable thing to do and kills this bug regardless.
@Mathnerd314
Copy link
Contributor

I think there's a third solution:

@ndmitchell
Copy link
Owner Author

@Mathnerd314 - yes, that works too. In fact, I originally had that as the lint checking function, but there are a few bugs you can introduce that don't get caught by that lesser check - can't remember what off the top of my head but I'll try and remember.

@ndmitchell ndmitchell reopened this Mar 5, 2016
@ndmitchell
Copy link
Owner Author

In fact checking the stored value after may be a performance win anyway.

@ndmitchell
Copy link
Owner Author

As per #453, if checking the stored value after is valid then the builtin rule should take a Bool. If not, it should take an Action Bool - so figuring out if that order is valid matters.

My mild concern is that if you change the rules of Main.exe to no longer require A.hs, then delete Main.exe, you are going to end up rebuilding A.hs anyway - whereas currently you wouldn't. But alternatively I think you've got into a bit of a weird state anyway, you'll probably recover anyway, and it's only giving marginally more safety at most.

@Mathnerd314
Copy link
Contributor

change the rules of Main.exe

If the rules change, Shake needs to discard the old result and its stored dependencies regardless (see #446). Doing dependencies first also disallows "unstable" rules that use different files depending on the phase of the moon, but I don't see that as a loss (instead, you depend on a separate "phase of the moon" rule first).

Were the bugs with EqualCheap vs. EqualExpensive found around dad4f85 and d073276?

@ndmitchell
Copy link
Owner Author

OK, I'm convinced, stored value should be checked at the end of all the dependencies, not the beginning. Allowing rules on the phase of the moon should be explicit (although I do worry about Werewolf exceptions 😃).

Yep, those do look like the bugs I must have found.

@ndmitchell
Copy link
Owner Author

Solved by pushing the stored value check to after the dependencies have been checked.

@ndmitchell
Copy link
Owner Author

In fact, looking at the code, I don't see how this can't have broken AssumeSkip. It didn't break any tests, and I suspect that's mostly because no one knows how to use AssumeSkip - see #436. I'll leave it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants