doc request: relation to recompilation
Closed this issue · 2 comments
What I don't get from the documentation:
If I use $(gitHash)
in a module whose source does not change (often) - will ghc still re-compile it each time, or how do I tell it that it should? (I assume it should, because the splice must be run?)
E.g., the build script should touch
this module? But touching changes the project's git hash (do they store file dates)?
I have the same question...in my experience using stack
, it will not necessarily re-compile the module, so sometimes the hash reported by $(gitHash)
gets out of date. @acfoltzer , any chance you have thoughts on the best way to force it to be rebuilt every time?
Ideally we could force a single module to be re-built -- I wouldn't want to pass --force-dirty
to stack
because that would do a bunch of extra work. Maybe the build script should touch
the module, then run stack build
, then git reset
the change?
The code makes a best effort to call addDependentFile
for the places in a .git
directory that can affect the hash and whether the repo is dirty.
For the hash:
.git/HEAD
- the ref pointed to by HEAD whenever it is a non-detached HEAD
.git/packed-refs
in case that exists, because HEAD can be a reference into that file
For the dirty flag it's just .git/index
.
So, you should not need to explicitly tell it to recompile the module as long as the package as a whole is being built.
That last point might be what's sticking for you, @thomasjm, since if stack
decides it doesn't need to build your package, it could wind up out of date. I am not familiar with the details of how it decides whether or not a package needs rebuilding, but from personal experience I know it's not perfect and we often have to use --force-dirty
. It looks like Template Haskell dependencies were addressed a while ago, but there's a recent comment indicating that there might be cases where it's not working: commercialhaskell/stack#105