Commit 9c68db9d authored by Simon Marlow's avatar Simon Marlow Committed by pcapriotti

Read the source file timestamp *before* preprocessing (#6106)

MERGED from commit d82da293
parent cd00c771
...@@ -1213,15 +1213,13 @@ summariseFile hsc_env old_summaries file mb_phase obj_allowed maybe_buf ...@@ -1213,15 +1213,13 @@ summariseFile hsc_env old_summaries file mb_phase obj_allowed maybe_buf
= do = do
let location = ms_location old_summary let location = ms_location old_summary
-- return the cached summary if the source didn't change src_timestamp <- get_src_timestamp
src_timestamp <- case maybe_buf of
Just (_,t) -> return t
Nothing -> liftIO $ getModificationTime file
-- The file exists; we checked in getRootSummary above. -- The file exists; we checked in getRootSummary above.
-- If it gets removed subsequently, then this -- If it gets removed subsequently, then this
-- getModificationTime may fail, but that's the right -- getModificationTime may fail, but that's the right
-- behaviour. -- behaviour.
-- return the cached summary if the source didn't change
if ms_hs_date old_summary == src_timestamp if ms_hs_date old_summary == src_timestamp
then do -- update the object-file timestamp then do -- update the object-file timestamp
obj_timestamp <- obj_timestamp <-
...@@ -1231,12 +1229,17 @@ summariseFile hsc_env old_summaries file mb_phase obj_allowed maybe_buf ...@@ -1231,12 +1229,17 @@ summariseFile hsc_env old_summaries file mb_phase obj_allowed maybe_buf
else return Nothing else return Nothing
return old_summary{ ms_obj_date = obj_timestamp } return old_summary{ ms_obj_date = obj_timestamp }
else else
new_summary new_summary src_timestamp
| otherwise | otherwise
= new_summary = do src_timestamp <- get_src_timestamp
new_summary src_timestamp
where where
new_summary = do get_src_timestamp = case maybe_buf of
Just (_,t) -> return t
Nothing -> liftIO $ getModificationTime file
new_summary src_timestamp = do
let dflags = hsc_dflags hsc_env let dflags = hsc_dflags hsc_env
(dflags', hspp_fn, buf) (dflags', hspp_fn, buf)
...@@ -1251,11 +1254,6 @@ summariseFile hsc_env old_summaries file mb_phase obj_allowed maybe_buf ...@@ -1251,11 +1254,6 @@ summariseFile hsc_env old_summaries file mb_phase obj_allowed maybe_buf
-- to findModule will find it, even if it's not on any search path -- to findModule will find it, even if it's not on any search path
mod <- liftIO $ addHomeModuleToFinder hsc_env mod_name location mod <- liftIO $ addHomeModuleToFinder hsc_env mod_name location
src_timestamp <- case maybe_buf of
Just (_,t) -> return t
Nothing -> liftIO $ getModificationTime file
-- getMofificationTime may fail
-- when the user asks to load a source file by name, we only -- when the user asks to load a source file by name, we only
-- use an object file if -fobject-code is on. See #1205. -- use an object file if -fobject-code is on. See #1205.
obj_timestamp <- obj_timestamp <-
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment