Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

doc request: relation to recompilation #14

Closed
jwaldmann opened this issue Feb 16, 2017 · 2 comments
Closed

doc request: relation to recompilation #14

jwaldmann opened this issue Feb 16, 2017 · 2 comments

Comments

@jwaldmann
Copy link

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)?

@thomasjm
Copy link

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?

@acfoltzer
Copy link
Owner

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

acfoltzer added a commit that referenced this issue Mar 17, 2017
Be explicit about rebuilds per #14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants