Skip to content

Commit 28ee6f3

Browse files
committed
Re #6689 Document GHC's recompilation checker and Template Haskell
1 parent e517fcb commit 28ee6f3

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

doc/commands/build_command.md

+24
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,30 @@ its subdirectories.
205205

206206
## Controlling what gets built
207207

208+
Stack will rebuild a targeted project package if it considers one or more of
209+
its files to be dirty.
210+
211+
Stack will consider a package to be dirty if a file is added to the
212+
`extra-source-files` field of its Cabal file or the contents of an existing file
213+
listed in the `extra-source-files` field is changed.
214+
215+
??? note "GHC's recompilation checker and Template Haskell"
216+
217+
GHC's recompilation checker (which is on by default) stops compilation early
218+
if GHC can determine that a module does not need to be recompiled.
219+
220+
For modules that use Template Haskell, when the module is compiled, GHC can
221+
determine dependencies, or be told about dependent files, of the code
222+
inserted by the splice. (Instances of the `Quasi` class promise to provide
223+
`qAddDependentFile`; see package `template-haskell`.)
224+
225+
However, GHC cannot be told of as yet *unknown* dependent files when a
226+
module using Template Haskell is compiled. For example, this can affect the
227+
`embedDir` function provided by package `file-embed`, when files are added
228+
to the directory in question after the module is compiled. The resolution is
229+
either to specify GHC's `-fforce-recomp` option (to turn off the
230+
recompilation checker for the package) or to do a clean build.
231+
208232
Stack will automatically build the necessary dependencies. See the introductory
209233
part of Stack's
210234
[user's guide](../tutorial/building_your_project.md#adding-dependencies) for

0 commit comments

Comments
 (0)