summaryrefslogtreecommitdiff
path: root/compiler/GHC/Driver/Backpack.hs
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-05-05 14:02:37 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2021-06-03 08:46:47 +0100
commit25977ab542a30df4ae71d9699d015bcdd1ab7cfb (patch)
treefc2195f9ceb5651603aa5fed03580eb47e0412d7 /compiler/GHC/Driver/Backpack.hs
parent79d12d34ad7177d33b191305f2c0157349f97355 (diff)
downloadhaskell-25977ab542a30df4ae71d9699d015bcdd1ab7cfb.tar.gz
Driver Rework Patch
This patch comprises of four different but closely related ideas. The net result is fixing a large number of open issues with the driver whilst making it simpler to understand. 1. Use the hash of the source file to determine whether the source file has changed or not. This makes the recompilation checking more robust to modern build systems which are liable to copy files around changing their modification times. 2. Remove the concept of a "stable module", a stable module was one where the object file was older than the source file, and all transitive dependencies were also stable. Now we don't rely on the modification time of the source file, the notion of stability is moot. 3. Fix TH/plugin recompilation after the removal of stable modules. The TH recompilation check used to rely on stable modules. Now there is a uniform and simple way, we directly track the linkables which were loaded into the interpreter whilst compiling a module. This is an over-approximation but more robust wrt package dependencies changing. 4. Fix recompilation checking for dynamic object files. Now we actually check if the dynamic object file exists when compiling with -dynamic-too Fixes #19774 #19771 #19758 #17434 #11556 #9121 #8211 #16495 #7277 #16093
Diffstat (limited to 'compiler/GHC/Driver/Backpack.hs')
-rw-r--r--compiler/GHC/Driver/Backpack.hs17
1 files changed, 11 insertions, 6 deletions
diff --git a/compiler/GHC/Driver/Backpack.hs b/compiler/GHC/Driver/Backpack.hs
index dceed41099..1d5b567359 100644
--- a/compiler/GHC/Driver/Backpack.hs
+++ b/compiler/GHC/Driver/Backpack.hs
@@ -50,6 +50,7 @@ import GHC.Types.Unique.DFM
import GHC.Types.Unique.DSet
import GHC.Utils.Outputable
+import GHC.Utils.Fingerprint
import GHC.Utils.Misc
import GHC.Utils.Panic
import GHC.Utils.Error
@@ -184,6 +185,9 @@ withBkpSession cid insts deps session_type do_this = do
{ backend = case session_type of
TcSession -> NoBackend
_ -> backend dflags
+ , ghcLink = case session_type of
+ TcSession -> NoLink
+ _ -> ghcLink dflags
, homeUnitInstantiations_ = insts
-- if we don't have any instantiation, don't
-- fill `homeUnitInstanceOfId` as it makes no
@@ -333,7 +337,7 @@ buildUnit session cid insts lunit = do
linkables = map (expectJust "bkp link" . hm_linkable)
. filter ((==HsSrcFile) . mi_hsc_src . hm_iface)
$ home_mod_infos
- getOfiles (LM _ _ us) = map nameOfObject (filter isObject us)
+ getOfiles LM{ linkableUnlinked = us } = map nameOfObject (filter isObject us)
obj_files = concatMap getOfiles linkables
state = hsc_units hsc_env
@@ -751,7 +755,7 @@ summariseRequirement pn mod_name = do
(unpackFS pn_fs </> moduleNameSlashes mod_name) "hsig"
env <- getBkpEnv
- time <- liftIO $ getModificationUTCTime (bkp_filename env)
+ src_hash <- liftIO $ getFileHash (bkp_filename env)
hi_timestamp <- liftIO $ modificationTimeIfExists (ml_hi_file location)
hie_timestamp <- liftIO $ modificationTimeIfExists (ml_hie_file location)
let loc = srcLocSpan (mkSrcLoc (mkFastString (bkp_filename env)) 1 1)
@@ -765,8 +769,9 @@ summariseRequirement pn mod_name = do
ms_mod = mod,
ms_hsc_src = HsigFile,
ms_location = location,
- ms_hs_date = time,
+ ms_hs_hash = src_hash,
ms_obj_date = Nothing,
+ ms_dyn_obj_date = Nothing,
ms_iface_date = hi_timestamp,
ms_hie_date = hie_timestamp,
ms_srcimps = [],
@@ -802,7 +807,6 @@ summariseDecl _pn hsc_src lmodname@(L loc modname) Nothing
emptyModNodeMap -- GHC API recomp not supported
(hscSourceToIsBoot hsc_src)
lmodname
- True -- Target lets you disallow, but not here
Nothing -- GHC API buffer support not supported
[] -- No exclusions
case r of
@@ -849,7 +853,7 @@ hsModuleToModSummary pn hsc_src modname
_ -> location0
-- This duplicates a pile of logic in GHC.Driver.Make
env <- getBkpEnv
- time <- liftIO $ getModificationUTCTime (bkp_filename env)
+ src_hash <- liftIO $ getFileHash (bkp_filename env)
hi_timestamp <- liftIO $ modificationTimeIfExists (ml_hi_file location)
hie_timestamp <- liftIO $ modificationTimeIfExists (ml_hie_file location)
@@ -898,8 +902,9 @@ hsModuleToModSummary pn hsc_src modname
hpm_module = hsmod,
hpm_src_files = [] -- TODO if we preprocessed it
}),
- ms_hs_date = time,
+ ms_hs_hash = src_hash,
ms_obj_date = Nothing, -- TODO do this, but problem: hi_timestamp is BOGUS
+ ms_dyn_obj_date = Nothing, -- TODO do this, but problem: hi_timestamp is BOGUS
ms_iface_date = hi_timestamp,
ms_hie_date = hie_timestamp
}