ghci recompilation avoidance vs. ChangeModtimeAndDigestInput

14 views
Skip to first unread message

Evan Laforge

unread,
May 28, 2018, 9:31:59 PM5/28/18
to Shake build system
Recently I switched to using git, and enabled
ChangeModtimeAndDigestInput in shake to avoid recompiling whenever I
switch branches. I then noticed that ghci tends to load modules
interpreted when it should load the .o file ("skipped" in ghc
parlance). I poked into the ghc source code, and it looks like it
checks if timestamp .o > timestamp .hs. So it seems shake (correctly)
figures out the file doesn't need to be recompiled, but ghc is still
fooled by git.

One possible solution is to make ghc also check digests like shake.
Presumably the modtime check is just a shortcut, since it does a more
complicated interface check after that. But changing ghc is
complicated and even if accepted, takes a long time to make it into a
stable compiler. Another solution might be to have shake update the
timestamps of output files even if it determines they don't need to be
rebuilt, which seems like it might be easier.

Is it easier? Possible? Has anyone explored this before?

Neil Mitchell

unread,
May 29, 2018, 4:57:03 AM5/29/18
to Evan Laforge, Shake build system
Hi Evan,

An alternative would be to checkout, touch all the .o files, then run Shake. Shake could change the files when it decides they were clean, but it feels pretty yuk and is more expensive than it otherwise should be. 

Long term, faking these things never really works, so even once you find a workaround, getting the correct fix into GHC is a good plan. I think I've been bitten by this behaviour too. 

Thanks, Neil
Reply all
Reply to author
Forward
0 new messages