Skip to content

Commit d7b5057

Browse files
committed
Address some review comments
1 parent 1f88915 commit d7b5057

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

ghcide/src/Development/IDE/Core/Compile.hs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,9 +1181,10 @@ recompilation avoidance scheme for subsequent compiles:
11811181
`HiFileResult` for some reason
11821182
11831183
4. If the file in question used Template Haskell on the previous compile, then
1184-
we need to recompile if any `Linkable` in its transitive closure changed. This
1185-
sounds bad, but it is possible to make some improvements.
1186-
In particular, we only need to recompile if any of the `Linkable`s actually used during the previous compile change.
1184+
we need to recompile if any `Linkable` in its transitive closure changed. This
1185+
sounds bad, but it is possible to make some improvements. In particular, we only
1186+
need to recompile if any of the `Linkable`s actually used during the previous
1187+
compile change.
11871188
11881189
How can we tell if a `Linkable` was actually used while running some TH?
11891190
@@ -1203,8 +1204,13 @@ were generated) using `Annotation`s, which provide a somewhat general purpose
12031204
way to serialise arbitrary information along with interface files.
12041205
12051206
Then when deciding whether to recompile, we need to check that the versions
1206-
of the linkables used during a previous compile match whatever is currently
1207-
in the HPT.
1207+
(i.e. hashes) of the linkables used during a previous compile match whatever is
1208+
currently in the HPT.
1209+
1210+
As we always generate Linkables from core files, we use the core file hash
1211+
as a (hopefully) deterministic measure of whether the Linkable has changed.
1212+
This is better than using the object file hash (if we have one) because object
1213+
file generation is not deterministic.
12081214
-}
12091215

12101216
data RecompilationInfo m
@@ -1276,7 +1282,7 @@ loadInterface session ms linkableNeeded RecompilationInfo{..} = do
12761282
-- If we have an old value, just return it
12771283
case old_value of
12781284
Just (old_hir, _)
1279-
| if isJust linkableNeeded then isJust (hirCoreFp old_hir) else True
1285+
| isNothing linkableNeeded || isJust (hirCoreFp old_hir)
12801286
-> do
12811287
-- Peform the fine grained recompilation check for TH
12821288
maybe_recomp <- checkLinkableDependencies get_linkable_hashes (hsc_mod_graph sessionWithMsDynFlags) (hirRuntimeModules old_hir)
@@ -1305,6 +1311,9 @@ loadInterface session ms linkableNeeded RecompilationInfo{..} = do
13051311

13061312
-- | Find the runtime dependencies by looking at the annotations
13071313
-- serialized in the iface
1314+
-- The bytestrings are the hashes of the core files for modules we
1315+
-- required to run the TH splices in the given module.
1316+
-- See Note [Recompilation avoidance in the presence of TH]
13081317
parseRuntimeDeps :: [ModIfaceAnnotation] -> ModuleEnv BS.ByteString
13091318
parseRuntimeDeps anns = mkModuleEnv $ mapMaybe go anns
13101319
where

0 commit comments

Comments
 (0)