diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2021-04-14 08:50:26 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-04-22 16:59:42 -0400 |
commit | 7f4d06e6c850c865669871c7fa5249daeb18f2d8 (patch) | |
tree | f177df26ba761a9cc0b7554b58218738a76c7131 /compiler/GHC/Driver/Pipeline.hs | |
parent | b7980b5d94d34943b3965cf79c4e610f00a9ee7d (diff) | |
download | haskell-7f4d06e6c850c865669871c7fa5249daeb18f2d8.tar.gz |
driver: Consider dyn_o files when checking recompilation in -c
When -dynamic-too is enabled, there are two result files, .o and .dyn_o,
therefore we should check both to decide whether to set SourceModified
or not.
The whole recompilation logic is very messy, a more thorough refactor
would be beneficial in this area but this is the minimal patch to fix
this more high priority problem.
Fixes #17968 and hopefully #17534
Diffstat (limited to 'compiler/GHC/Driver/Pipeline.hs')
-rw-r--r-- | compiler/GHC/Driver/Pipeline.hs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/compiler/GHC/Driver/Pipeline.hs b/compiler/GHC/Driver/Pipeline.hs index e6b7be62ef..8589b81ee5 100644 --- a/compiler/GHC/Driver/Pipeline.hs +++ b/compiler/GHC/Driver/Pipeline.hs @@ -1269,8 +1269,16 @@ runPhase (RealPhase (Hsc src_flavour)) input_fn -- the object file for one module.) -- Note the nasty duplication with the same computation in compileFile above location <- getLocation src_flavour mod_name - + dt_state <- dynamicTooState dflags let o_file = ml_obj_file location -- The real object file + -- dynamic-too *also* produces the dyn_o_file, so have to check + -- that's there, and if it's not, regenerate both .o and + -- .dyn_o + dyn_o_file = case dt_state of + DT_OK + | not (writeInterfaceOnlyMode dflags) + -> Just (dynamicOutputFile dflags o_file) + _ -> Nothing hi_file = ml_hi_file location hie_file = ml_hie_file location dest_file | writeInterfaceOnlyMode dflags @@ -1280,11 +1288,11 @@ runPhase (RealPhase (Hsc src_flavour)) input_fn -- Figure out if the source has changed, for recompilation avoidance. -- - -- Setting source_unchanged to True means that M.o (or M.hie) seems + -- Setting source_unchanged to True means that M.o, M.dyn_o (or M.hie) seems -- to be up to date wrt M.hs; so no need to recompile unless imports have -- changed (which the compiler itself figures out). - -- Setting source_unchanged to False tells the compiler that M.o is out of - -- date wrt M.hs (or M.o doesn't exist) so we must recompile regardless. + -- Setting source_unchanged to False tells the compiler that M.o or M.dyn_o is out of + -- date wrt M.hs (or M.o/dyn_o doesn't exist) so we must recompile regardless. src_timestamp <- liftIO $ getModificationUTCTime (basename <.> suff) source_unchanged <- liftIO $ @@ -1295,11 +1303,12 @@ runPhase (RealPhase (Hsc src_flavour)) input_fn then return SourceModified -- Otherwise look at file modification dates else do dest_file_mod <- sourceModified dest_file src_timestamp + dyn_file_mod <- traverse (flip sourceModified src_timestamp) dyn_o_file hie_file_mod <- if gopt Opt_WriteHie dflags then sourceModified hie_file src_timestamp else pure False - if dest_file_mod || hie_file_mod + if dest_file_mod || hie_file_mod || fromMaybe False dyn_file_mod then return SourceModified else return SourceUnmodified |