will generate you a different interface hash most of the time in ghc --show-iface Test.hi.
It looks like the modification time of the .h file makes it into the interface hash, but only at second resolution, and you get compilation IS NOT required if you manage to run it twice per second.
I think the interface hash should be independent from the time stamp of the header file.
This bug can trigger unnecessary recompilation and makes compilations with identical inputs non-deterministic.
I might be wrong, but it looks to me as if this can only ever return False (UpToDate in current GHC head) because the mtime is so coarse - in other words if your computer is too slow, a second will pass and this will never be considered up to date?
Niklas Hambüchenchanged title from Interface hashes include time stamp of included .h file when CPP is used to Interface hashes include time stamp of dependent files (UsageFile mtime)
changed title from Interface hashes include time stamp of included .h file when CPP is used to Interface hashes include time stamp of dependent files (UsageFile mtime)
According to discussion in #7473 (closed)getModificationTime was improved on Linux to return time with resolution better than 1 second. nh2, what platform are you on?
This is now fixed but I have not yet added a test, so I will keep it open. @nh2, can you confirm this fixes your bug? Perhaps include a patch for a simpler test if possible :)
Niklas, can you please rebase this patch? I manually did it, but then the test started failing (the .stdout file had "compilation IS NOT required" once too many times). Can you please take this and verify it should work? Thanks!
Also, from reading the patch, it is not clear to me if the filename is also part of the ABI hash. It should not be, as build directory names may change, e.g. on automatic build machines.
nomeata, sorry if I am missing something obvious, but this ticket seems to be about the time stamp not appearing in the interface hash, so the fact that this ticket is just waiting for a test is not incompatible with the interface hash including the file name.
Currently we need the .h file name in the interface file so that we can check whether the file fingerprint matches, and we use the interface hash to determine whether to write a new interface file, so it's not immediately obvious that we can avoid putting the file name in the interface hash. Maybe you'd like to create a new ticket about finding some way to avoid this?
and we use the interface hash to determine whether to write a new interface file,
Ah, this is new to me. I assumed that when a module is compiled, its interface is written, and the interface hash is only used to decide whether to rebuild another module or not.
But you are right, this deserves a separate ticket.