Skip to content

Commit 3747ae5

Browse files
committed
use the type check modsummary
1 parent f0ba40b commit 3747ae5

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

Diff for: ghcide/session-loader/Development/IDE/Session.hs

+4
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ import GHC.Driver.Errors.Types
125125
import GHC.Types.Error (errMsgDiagnostic,
126126
singleMessage)
127127
import GHC.Unit.State
128+
import Debug.Trace (traceM)
128129

129130
data Log
130131
= LogSettingInitialDynFlags
@@ -530,7 +531,10 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
530531
-- See Note [Avoiding bad interface files]
531532
let hscComponents = sort $ map show uids
532533
cacheDirOpts = hscComponents ++ componentOptions opts
534+
let opts_hash = B.unpack $ B16.encode $ H.finalize $ H.updates H.init (map B.pack cacheDirOpts)
535+
traceM $ "Setting cache dirs for " ++ show rawComponentUnitId ++ " " ++ opts_hash ++ " " ++ show cacheDirOpts
533536
cacheDirs <- liftIO $ getCacheDirs prefix cacheDirOpts
537+
534538
processed_df <- setCacheDirs recorder cacheDirs df2
535539
-- The final component information, mostly the same but the DynFlags don't
536540
-- contain any packages which are also loaded

Diff for: ghcide/src/Development/IDE/Core/Compile.hs

+6-1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ import GHC.Driver.Config.CoreToStg.Prep
126126
#if MIN_VERSION_ghc(9,7,0)
127127
import Data.Foldable (toList)
128128
import GHC.Unit.Module.Warnings
129+
import Development.IDE.Core.WorkerThread (awaitRunInThread)
129130
#else
130131
import Development.IDE.Core.FileStore (shareFilePath)
131132
#endif
@@ -196,6 +197,7 @@ typecheckModule (IdeDefer defer) hsc tc_helpers pm = do
196197
where
197198
demoteIfDefer = if defer then demoteTypeErrorsToWarnings else id
198199

200+
199201
-- | Install hooks to capture the splices as well as the runtime module dependencies
200202
captureSplicesAndDeps :: TypecheckHelpers -> HscEnv -> (HscEnv -> IO a) -> IO (a, Splices, ModuleEnv BS.ByteString)
201203
captureSplicesAndDeps TypecheckHelpers{..} env k = do
@@ -432,6 +434,7 @@ mkHiFileResultCompile se session' tcm simplified_guts = catchErrs $ do
432434
let session = hscSetFlags (ms_hspp_opts ms) session'
433435
ms = pm_mod_summary $ tmrParsed tcm
434436

437+
traceM $ "[TRACE] Generating hi file for " ++ show (moduleName $ ms_mod ms)
435438
(details, guts) <- do
436439
-- write core file
437440
-- give variables unique OccNames
@@ -724,11 +727,13 @@ addRelativeImport fp modu dflags = dflags
724727
-- | Also resets the interface store
725728
atomicFileWrite :: ShakeExtras -> FilePath -> (FilePath -> IO a) -> IO a
726729
atomicFileWrite se targetPath write = do
730+
-- awaitRunInThread (restartQueue se) $ do
731+
traceM $ "[TRACE] Writing file: " <> targetPath
727732
let dir = takeDirectory targetPath
728733
createDirectoryIfMissing True dir
729734
(tempFilePath, cleanUp) <- newTempFileWithin dir
730735
(write tempFilePath >>= \x -> renameFile tempFilePath targetPath >> atomically (resetInterfaceStore se (toNormalizedFilePath' targetPath)) >> pure x)
731-
`onException` cleanUp
736+
`onException` (cleanUp >> throwIO (userError "atomicFileWrite: write failed"))
732737

733738
generateHieAsts :: HscEnv -> TcModuleResult -> IO ([FileDiagnostic], Maybe (HieASTs Type))
734739
generateHieAsts hscEnv tcm =

Diff for: ghcide/src/Development/IDE/Core/Rules.hs

+5-1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ import System.Info.Extra (isWindows)
169169

170170
import qualified Data.IntMap as IM
171171
import GHC.Fingerprint
172+
import Debug.Trace (traceM)
172173

173174

174175
data Log
@@ -1039,10 +1040,13 @@ usePropertyByPathAction path plId p = do
10391040
getLinkableRule :: Recorder (WithPriority Log) -> Rules ()
10401041
getLinkableRule recorder =
10411042
defineEarlyCutoff (cmapWithPrio LogShake recorder) $ Rule $ \GetLinkable f -> do
1042-
ModSummaryResult{msrModSummary = ms} <- use_ GetModSummary f
1043+
-- ModSummaryResult{msrModSummary = ms} <- use_ GetModSummary f
1044+
tmr <- use_ TypeCheck f
1045+
let ms = tmrModSummary tmr
10431046
HiFileResult{hirModIface, hirModDetails, hirCoreFp} <- use_ GetModIface f
10441047
let obj_file = ml_obj_file (ms_location ms)
10451048
core_file = ml_core_file (ms_location ms)
1049+
traceM $ "GetLinkable core_file " ++ show core_file
10461050
case hirCoreFp of
10471051
Nothing -> error $ "called GetLinkable for a file without a linkable: " ++ show f
10481052
Just (bin_core, fileHash) -> do

0 commit comments

Comments
 (0)