@@ -66,6 +66,7 @@ import Data.Time.Clock.POSIX (posixSecondsToUTCTime, utcTi
66
66
import Data.Tuple.Extra (dupe )
67
67
import Data.Unique as Unique
68
68
import Debug.Trace
69
+ import Development.IDE.Core.FileStore (resetInterfaceStore )
69
70
import Development.IDE.Core.Preprocessor
70
71
import Development.IDE.Core.RuleTypes
71
72
import Development.IDE.Core.Shake
@@ -396,7 +397,7 @@ mkHiFileResultCompile se session' tcm simplified_guts ltype = catchErrs $ do
396
397
397
398
let genLinkable = case ltype of
398
399
ObjectLinkable -> generateObjectCode
399
- BCOLinkable -> generateByteCode WriteCoreFile
400
+ BCOLinkable -> generateByteCode se WriteCoreFile
400
401
401
402
(linkable, details, mguts, diags) <-
402
403
if mg_hsc_src simplified_guts == HsBootFile
@@ -545,8 +546,8 @@ generateObjectCode session summary guts = do
545
546
546
547
data WriteCoreFile = WriteCoreFile | CoreFileExists ! UTCTime
547
548
548
- generateByteCode :: WriteCoreFile -> HscEnv -> ModSummary -> CgGuts -> IO (IdeResult Linkable )
549
- generateByteCode write_core hscEnv summary guts = do
549
+ generateByteCode :: ShakeExtras -> WriteCoreFile -> HscEnv -> ModSummary -> CgGuts -> IO (IdeResult Linkable )
550
+ generateByteCode se write_core hscEnv summary guts = do
550
551
fmap (either (, Nothing ) (second Just )) $
551
552
catchSrcErrors (hsc_dflags hscEnv) " bytecode" $ do
552
553
(warnings, (_, bytecode, sptEntries)) <-
@@ -566,7 +567,7 @@ generateByteCode write_core hscEnv summary guts = do
566
567
WriteCoreFile -> liftIO $ do
567
568
let core_fp = ml_core_file $ ms_location summary
568
569
core_file = codeGutsToCoreFile guts
569
- atomicFileWrite core_fp $ \ fp ->
570
+ atomicFileWrite se core_fp $ \ fp ->
570
571
writeBinCoreFile fp core_file
571
572
getModificationTime core_fp
572
573
let linkable = LM time (ms_mod summary) [unlinked]
@@ -651,12 +652,14 @@ addRelativeImport :: NormalizedFilePath -> ModuleName -> DynFlags -> DynFlags
651
652
addRelativeImport fp modu dflags = dflags
652
653
{importPaths = nubOrd $ maybeToList (moduleImportPath fp modu) ++ importPaths dflags}
653
654
654
- atomicFileWrite :: FilePath -> (FilePath -> IO a ) -> IO ()
655
- atomicFileWrite targetPath write = do
655
+ -- | Also resets the interface store
656
+ atomicFileWrite :: ShakeExtras -> FilePath -> (FilePath -> IO a ) -> IO ()
657
+ atomicFileWrite se targetPath write = do
656
658
let dir = takeDirectory targetPath
657
659
createDirectoryIfMissing True dir
658
660
(tempFilePath, cleanUp) <- newTempFileWithin dir
659
- (write tempFilePath >> renameFile tempFilePath targetPath) `onException` cleanUp
661
+ (write tempFilePath >> renameFile tempFilePath targetPath >> atomically (resetInterfaceStore se (toNormalizedFilePath' targetPath)))
662
+ `onException` cleanUp
660
663
661
664
generateHieAsts :: HscEnv -> TcModuleResult -> IO ([FileDiagnostic ], Maybe (HieASTs Type ))
662
665
generateHieAsts hscEnv tcm =
@@ -834,18 +837,18 @@ writeAndIndexHieFile hscEnv se mod_summary srcPath exports ast source =
834
837
handleGenerationErrors dflags " extended interface write/compression" $ do
835
838
hf <- runHsc hscEnv $
836
839
GHC. mkHieFile' mod_summary exports ast source
837
- atomicFileWrite targetPath $ flip GHC. writeHieFile hf
840
+ atomicFileWrite se targetPath $ flip GHC. writeHieFile hf
838
841
hash <- Util. getFileHash targetPath
839
842
indexHieFile se mod_summary srcPath hash hf
840
843
where
841
844
dflags = hsc_dflags hscEnv
842
845
mod_location = ms_location mod_summary
843
846
targetPath = Compat. ml_hie_file mod_location
844
847
845
- writeHiFile :: HscEnv -> HiFileResult -> IO [FileDiagnostic ]
846
- writeHiFile hscEnv tc =
848
+ writeHiFile :: ShakeExtras -> HscEnv -> HiFileResult -> IO [FileDiagnostic ]
849
+ writeHiFile se hscEnv tc =
847
850
handleGenerationErrors dflags " interface write" $ do
848
- atomicFileWrite targetPath $ \ fp ->
851
+ atomicFileWrite se targetPath $ \ fp ->
849
852
writeIfaceFile hscEnv fp modIface
850
853
where
851
854
modIface = hm_iface $ hirHomeMod tc
@@ -1210,12 +1213,13 @@ ml_core_file ml = ml_hi_file ml <.> "core"
1210
1213
-- See Note [Recompilation avoidance in the presence of TH]
1211
1214
loadInterface
1212
1215
:: (MonadIO m , MonadMask m )
1213
- => HscEnv
1216
+ => ShakeExtras
1217
+ -> HscEnv
1214
1218
-> ModSummary
1215
1219
-> Maybe LinkableType
1216
1220
-> RecompilationInfo m
1217
1221
-> m ([FileDiagnostic ], Maybe HiFileResult )
1218
- loadInterface session ms linkableNeeded RecompilationInfo {.. } = do
1222
+ loadInterface se session ms linkableNeeded RecompilationInfo {.. } = do
1219
1223
let sessionWithMsDynFlags = hscSetFlags (ms_hspp_opts ms) session
1220
1224
mb_old_iface = hm_iface . hirHomeMod . fst <$> old_value
1221
1225
mb_old_version = snd <$> old_value
@@ -1309,7 +1313,7 @@ loadInterface session ms linkableNeeded RecompilationInfo{..} = do
1309
1313
-> do_regenerate msg
1310
1314
| otherwise -> return ([] , Just old_hir)
1311
1315
Nothing -> do
1312
- (warns, hmi) <- liftIO $ mkDetailsFromIface sessionWithMsDynFlags ms iface lb
1316
+ (warns, hmi) <- liftIO $ mkDetailsFromIface se sessionWithMsDynFlags ms iface lb
1313
1317
-- parse the runtime dependencies from the annotations
1314
1318
let runtime_deps
1315
1319
| not (mi_used_th iface) = emptyModuleEnv
@@ -1361,8 +1365,8 @@ showReason UpToDate = "UpToDate"
1361
1365
showReason MustCompile = " MustCompile"
1362
1366
showReason (RecompBecause s) = s
1363
1367
1364
- mkDetailsFromIface :: HscEnv -> ModSummary -> ModIface -> Maybe IdeLinkable -> IO ([FileDiagnostic ], HomeModInfo )
1365
- mkDetailsFromIface session ms iface ide_linkable = do
1368
+ mkDetailsFromIface :: ShakeExtras -> HscEnv -> ModSummary -> ModIface -> Maybe IdeLinkable -> IO ([FileDiagnostic ], HomeModInfo )
1369
+ mkDetailsFromIface se session ms iface ide_linkable = do
1366
1370
details <- liftIO $ fixIO $ \ details -> do
1367
1371
let hsc' = session { hsc_HPT = addToHpt (hsc_HPT session) (moduleName $ mi_module iface) (HomeModInfo iface details Nothing ) }
1368
1372
initIfaceLoad hsc' (typecheckIface iface)
@@ -1371,7 +1375,7 @@ mkDetailsFromIface session ms iface ide_linkable = do
1371
1375
Just (GhcLinkable lb) -> pure ([] , Just lb)
1372
1376
Just (CoreLinkable t core_file) -> do
1373
1377
cgi_guts <- coreFileToCgGuts session iface details core_file
1374
- generateByteCode (CoreFileExists t) session ms cgi_guts
1378
+ generateByteCode se (CoreFileExists t) session ms cgi_guts
1375
1379
1376
1380
return (warns, HomeModInfo iface details linkable)
1377
1381
0 commit comments