@@ -1181,9 +1181,10 @@ recompilation avoidance scheme for subsequent compiles:
1181
1181
`HiFileResult` for some reason
1182
1182
1183
1183
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.
1187
1188
1188
1189
How can we tell if a `Linkable` was actually used while running some TH?
1189
1190
@@ -1203,8 +1204,13 @@ were generated) using `Annotation`s, which provide a somewhat general purpose
1203
1204
way to serialise arbitrary information along with interface files.
1204
1205
1205
1206
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.
1208
1214
-}
1209
1215
1210
1216
data RecompilationInfo m
@@ -1276,7 +1282,7 @@ loadInterface session ms linkableNeeded RecompilationInfo{..} = do
1276
1282
-- If we have an old value, just return it
1277
1283
case old_value of
1278
1284
Just (old_hir, _)
1279
- | if isJust linkableNeeded then isJust (hirCoreFp old_hir) else True
1285
+ | isNothing linkableNeeded || isJust (hirCoreFp old_hir)
1280
1286
-> do
1281
1287
-- Peform the fine grained recompilation check for TH
1282
1288
maybe_recomp <- checkLinkableDependencies get_linkable_hashes (hsc_mod_graph sessionWithMsDynFlags) (hirRuntimeModules old_hir)
@@ -1305,6 +1311,9 @@ loadInterface session ms linkableNeeded RecompilationInfo{..} = do
1305
1311
1306
1312
-- | Find the runtime dependencies by looking at the annotations
1307
1313
-- 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]
1308
1317
parseRuntimeDeps :: [ModIfaceAnnotation ] -> ModuleEnv BS. ByteString
1309
1318
parseRuntimeDeps anns = mkModuleEnv $ mapMaybe go anns
1310
1319
where
0 commit comments