-
Notifications
You must be signed in to change notification settings - Fork 843
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
Detect unlisted modules and TH dependent files (#32,#105) #734
Conversation
An idea mentioned in #105 (comment) is to display warnings for any files not listed from the .cabal file. For modules, this should be straightforward, but for TH dependencies I don't think there's a good way to know whether the file should be listed or not. For example, using gitrev makes a module depend on |
@@ -178,6 +178,7 @@ executable stack | |||
ghc-options: -Wall -threaded -rtsopts | |||
other-modules: Plugins | |||
Plugins.Commands | |||
Paths_stack |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this discovered by this code itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup!
Actually, I think your current solution is the right one, it avoids an ugly race condition where a TH-loaded file is edited after the build is started.
Not yet, let's wait until we see it cause trouble in practice
None at all, but let's wait till this is merged to master and then do the cleanup on master itself.
Absolutely
I'll need to defer to @chrisdone on that
Yes, and may as well include it in this branch (though doing on master after merge is also fine). Overall: I like the approach, and the code is shorter than I was hoping for, which is great. Having a few integration tests around this would be nice, but I'm OK merging this to master now. Please do so when you're ready. I'm doing some testing on Windows and will shout if there's a problem, but I doubt that will be the case. |
In testing (at least on Windows): rebuilding did not occur after a change to a TH-included file. I used |
There seem to be worse issues on Windows. Just saw this, seems to be an error from GHC itself while writing the .dump-hi file:
|
That's interesting, I did not trigger that bug in my testing. |
@snoyberg TH dependency changes should now work on Windows (was a newline issue). For the "invalid character" problem, have you tried building stack itself on Windows using this version of stack? I've tried to reproduce on Linux using |
Probably triggered by this bit of output it's trying to write to the .dump-hi (note the
|
I can confirm that the original bug I reported is resolved. I'll play a bit more and see if I can reproduce the other problem. |
If you set your |
No, doesn't seem to make any difference. |
Do you have any interesting environment variables set by any chance? |
1ad1359
to
06218bd
Compare
I merged the Windows code page fix to master and then rebased this PR onto it. Solves the "invalid character" for me. |
I'm still gonna review this when I get round to it, btw. |
This seems to basically work. The approach it takes is to have GHC dump the interfaces (using
-ddump-hi -ddump-to-file
) while it builds, and then it parses the dumped interfaces when checking for changes (before the next build) to detect any unlisted modules and TH dependencies.I'd like input on some of these before moving further.
build
after a clean (without changing any files in the interim) it thinks those files are new and so it runs the build anyway. That's because the dumped HI files didn't exist for the firstbuild
so it didn't record the state of the unlisted files. Is this a corner case worth fixing? To do so, it'd have to do a pass looking over the.dump-hi
files immediately after the build to find the unlisted files and record their state..dump-hi
files before every build. That seems to be pretty fast, but caching would be faster. Worth doing? (this and the previous item probably make sense to do together)nub
is used a bunch in the existing code. I think converting the code to use Sets would eliminate many of thosenub
s, but any remaining should probably becomenubOrd
s (from extra) instead. Agreed?ghciPkgModules
(previously it only got the listed ones). Is that the correct behaviour?Stack.Iface
module Dan added isn't used at all (this code draws inspiration from it, though). Should I just remove that?ping @chrisdone @snoyberg