@@ -1181,9 +1181,10 @@ recompilation avoidance scheme for subsequent compiles:
11811181 `HiFileResult` for some reason
11821182
118311834. 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
11881189How 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
12031204way to serialise arbitrary information along with interface files.
12041205
12051206Then 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
12101216data 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]
13081317parseRuntimeDeps :: [ModIfaceAnnotation ] -> ModuleEnv BS. ByteString
13091318parseRuntimeDeps anns = mkModuleEnv $ mapMaybe go anns
13101319 where
0 commit comments