diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2014-12-27 10:50:01 -0800 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2015-01-03 11:56:14 -0800 |
commit | 2223e196b2dc5340d70e58be011c279d381b4319 (patch) | |
tree | 3c587547990df7c62d73598f9dfe991afb0b4880 /compiler/main/DriverPipeline.hs | |
parent | af4d99803ea7676f88f250ad56a8c31c1c8cd5bc (diff) | |
download | haskell-2223e196b2dc5340d70e58be011c279d381b4319.tar.gz |
Fix #9243 so recompilation avoidance works with -fno-code
Summary:
Where we track timestamps of object files, also track timestamps
for interface files. When -fno-code -fwrite-interface is enabled, use
the interface file timestamp as an extra check to see if the files are
up-to-date. We had to apply this logic to one-shot and make modes.
This fix would be good to merge into 7.10; it makes using -fno-code
-fwrite-interface for flywheel type checking usable.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate and new test cases
Reviewers: austin
Subscribers: carter, thomie
Differential Revision: https://phabricator.haskell.org/D596
GHC Trac Issues: #9243
Diffstat (limited to 'compiler/main/DriverPipeline.hs')
-rw-r--r-- | compiler/main/DriverPipeline.hs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index e8be29759b..6d597f9437 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -30,7 +30,7 @@ module DriverPipeline ( runPhase, exeFileName, mkExtraObjToLinkIntoBinary, mkNoteObjsToLinkIntoBinary, maybeCreateManifest, runPhase_MoveBinary, - linkingNeeded, checkLinkInfo + linkingNeeded, checkLinkInfo, writeInterfaceOnlyMode ) where #include "HsVersions.h" @@ -935,6 +935,11 @@ runPhase (RealPhase (Hsc src_flavour)) input_fn dflags0 location <- getLocation src_flavour mod_name let o_file = ml_obj_file location -- The real object file + hi_file = ml_hi_file location + dest_file | writeInterfaceOnlyMode dflags + = hi_file + | otherwise + = o_file -- Figure out if the source has changed, for recompilation avoidance. -- @@ -952,10 +957,10 @@ runPhase (RealPhase (Hsc src_flavour)) input_fn dflags0 -- (b) we aren't going all the way to .o file (e.g. ghc -S) then return SourceModified -- Otherwise look at file modification dates - else do o_file_exists <- doesFileExist o_file - if not o_file_exists + else do dest_file_exists <- doesFileExist dest_file + if not dest_file_exists then return SourceModified -- Need to recompile - else do t2 <- getModificationUTCTime o_file + else do t2 <- getModificationUTCTime dest_file if t2 > src_timestamp then return SourceUnmodified else return SourceModified @@ -975,6 +980,7 @@ runPhase (RealPhase (Hsc src_flavour)) input_fn dflags0 ms_location = location, ms_hs_date = src_timestamp, ms_obj_date = Nothing, + ms_iface_date = Nothing, ms_textual_imps = imps, ms_srcimps = src_imps } @@ -2248,6 +2254,11 @@ joinObjectFiles dflags o_files output_fn = do -- ----------------------------------------------------------------------------- -- Misc. +writeInterfaceOnlyMode :: DynFlags -> Bool +writeInterfaceOnlyMode dflags = + gopt Opt_WriteInterface dflags && + HscNothing == hscTarget dflags + -- | What phase to run after one of the backend code generators has run hscPostBackendPhase :: DynFlags -> HscSource -> HscTarget -> Phase hscPostBackendPhase _ HsBootFile _ = StopLn |