@@ -46,6 +46,9 @@ import Control.Monad.Trans.Except
4646import Data.Function
4747import Data.Ord
4848import qualified Data.Text as T
49+import qualified Data.Text.IO as T
50+import System.IO
51+import System.Time.Extra
4952import Data.IORef
5053import Data.List.Extra
5154import Data.Maybe
@@ -107,21 +110,37 @@ compileModule
107110 -> TcModuleResult
108111 -> IO ([FileDiagnostic], Maybe CoreModule)
109112compileModule packageState deps tmr =
110− fmap (either (, Nothing) (second Just)) $
111− runGhcEnv packageState $
113+ fmap (either (, Nothing) (second Just)) $ do
114+ timer <- liftIO offsetTime
115+ runGhcEnv packageState $ do
116+ time <- liftIO timer
117+ liftIO $ T.hPutStrLn stderr $ T.pack $ "Entering GHC env: " <> show time
112118 catchSrcErrors "compile" $ do
119+ timer <- liftIO offsetTime
113120 setupEnv (deps ++ [tmr])
121+ time <- liftIO timer
122+ liftIO $ T.hPutStrLn stderr $ T.pack $ "setupEnv: " <> show time
114123
115124 let tm = tmrModule tmr
116125 session <- getSession
126+ timer <- liftIO offsetTime
117127 (warnings,desugar) <- withWarnings "compile" $ \tweak -> do
128+ time <- liftIO timer
129+ liftIO $ T.hPutStrLn stderr $ T.pack $ "withWarnings: " <> show time
118130 let pm = tm_parsed_module tm
119131 let pm' = pm{pm_mod_summary = tweak $ pm_mod_summary pm}
120132 let tm' = tm{tm_parsed_module = pm'}
121− GHC.dm_core_module <$> GHC.desugarModule tm'
133+ timer <- liftIO offsetTime
134+ r <- GHC.dm_core_module <$> GHC.desugarModule tm'
135+ time <- liftIO timer
136+ liftIO $ T.hPutStrLn stderr $ T.pack $ "desugarModule: " <> show time
137+ pure r
122138
123139 -- give variables unique OccNames
140+ timer <- liftIO offsetTime
124141 (tidy, details) <- liftIO $ tidyProgram session desugar
142+ time <- liftIO timer
143+ liftIO $ T.hPutStrLn stderr $ T.pack $ "tidyProgram: " <> show time
125144
126145 let core = CoreModule
127146 (cg_module tidy)
@@ -203,8 +222,9 @@ setupEnv tmsIn = do
203222 foldl'
204223 (\fc (im, ifr) -> GHC.extendInstalledModuleEnv fc im ifr) prevFinderCache
205224 $ zip ims ifrs
206− newFinderCacheVar <- liftIO $ newIORef $! newFinderCache
207− modifySession $ \s -> s { hsc_FC = newFinderCacheVar }
225+ liftIO $ writeIORef (hsc_FC session) newFinderCache
226+ -- newFinderCacheVar <- liftIO $ newIORef $! newFinderCache
227+ -- modifySession $ \s -> s { hsc_FC = prevFinderCache }
208228
209229 -- load dependent modules, which must be in topological order.
210230 mapM_ loadModuleHome tms