summaryrefslogtreecommitdiff
path: root/compiler/GHC/Unit/Module/ModIface.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/Unit/Module/ModIface.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/Unit/Module/ModIface.hs')
-rw-r--r--compiler/GHC/Unit/Module/ModIface.hs16
1 files changed, 13 insertions, 3 deletions
diff --git a/compiler/GHC/Unit/Module/ModIface.hs b/compiler/GHC/Unit/Module/ModIface.hs
index 18101e309b..695e1ff6c2 100644
--- a/compiler/GHC/Unit/Module/ModIface.hs
+++ b/compiler/GHC/Unit/Module/ModIface.hs
@@ -242,13 +242,17 @@ data ModIface_ (phase :: ModIfacePhase)
-- ^ Either `()` or `ModIfaceBackend` for
-- a fully instantiated interface.
- mi_ext_fields :: ExtensibleFields
+ mi_ext_fields :: ExtensibleFields,
-- ^ Additional optional fields, where the Map key represents
-- the field name, resulting in a (size, serialized data) pair.
-- Because the data is intended to be serialized through the
-- internal `Binary` class (increasing compatibility with types
-- using `Name` and `FastString`, such as HIE), this format is
-- chosen over `ByteString`s.
+ --
+
+ mi_src_hash :: !Fingerprint
+ -- ^ Hash of the .hs source, used for recompilation checking.
}
-- | Old-style accessor for whether or not the ModIface came from an hs-boot
@@ -305,6 +309,9 @@ instance Binary ModIface where
mi_module = mod,
mi_sig_of = sig_of,
mi_hsc_src = hsc_src,
+ mi_src_hash = _src_hash, -- Don't `put_` this in the instance
+ -- because we are going to write it
+ -- out separately in the actual file
mi_deps = deps,
mi_usages = usages,
mi_exports = exports,
@@ -406,6 +413,8 @@ instance Binary ModIface where
mi_module = mod,
mi_sig_of = sig_of,
mi_hsc_src = hsc_src,
+ mi_src_hash = fingerprint0, -- placeholder because this is dealt
+ -- with specially when the file is read
mi_deps = deps,
mi_usages = usages,
mi_exports = exports,
@@ -452,6 +461,7 @@ emptyPartialModIface mod
= ModIface { mi_module = mod,
mi_sig_of = Nothing,
mi_hsc_src = HsSrcFile,
+ mi_src_hash = fingerprint0,
mi_deps = noDependencies,
mi_usages = [],
mi_exports = [],
@@ -512,11 +522,11 @@ emptyIfaceHashCache _occ = Nothing
-- avoid major space leaks.
instance (NFData (IfaceBackendExts (phase :: ModIfacePhase)), NFData (IfaceDeclExts (phase :: ModIfacePhase))) => NFData (ModIface_ phase) where
rnf (ModIface f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12
- f13 f14 f15 f16 f17 f18 f19 f20 f21 f22 f23 f24) =
+ f13 f14 f15 f16 f17 f18 f19 f20 f21 f22 f23 f24 f25) =
rnf f1 `seq` rnf f2 `seq` f3 `seq` f4 `seq` f5 `seq` f6 `seq` rnf f7 `seq` f8 `seq`
f9 `seq` rnf f10 `seq` rnf f11 `seq` f12 `seq` rnf f13 `seq` rnf f14 `seq` rnf f15 `seq`
rnf f16 `seq` f17 `seq` rnf f18 `seq` rnf f19 `seq` f20 `seq` f21 `seq` f22 `seq` rnf f23
- `seq` rnf f24
+ `seq` rnf f24 `seq` f25 `seq` ()
-- | Records whether a module has orphans. An \"orphan\" is one of:
--