X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fiface%2FMkIface.lhs;h=43bae8fba69d5c17a5e590d305b2151c9fcb71b2;hb=7eb5e29b4a7b6fef55512bc7bf3308e712ca3eba;hp=33b18c41ac98875ff5b557c23f6377850fc23957;hpb=7379e82aafc7d0c1b839a13a20d52babeafed023;p=ghc-hetmet.git diff --git a/compiler/iface/MkIface.lhs b/compiler/iface/MkIface.lhs index 33b18c4..43bae8f 100644 --- a/compiler/iface/MkIface.lhs +++ b/compiler/iface/MkIface.lhs @@ -131,7 +131,7 @@ We produce a line for every module B below the module, A, currently being compiled: import B ; to record the fact that A does import B indirectly. This is used to decide -to look to look for B.hi rather than B.hi-boot when compiling a module that +to look for B.hi rather than B.hi-boot when compiling a module that imports A. This line says that A imports B, but uses nothing in it. So we'll get an early bale-out when compiling A if B's version changes. @@ -181,6 +181,10 @@ code of A, and thereby haul in all the stuff reachable from it. haul in all the unfoldings for B, in case the module that imports A *is* compiled with -O. I think this is the case.] +SimonM [30/11/2007]: I believe the above is all out of date; the +current implementation doesn't do it this way. Instead, when any of +the dependencies of a declaration changes, the version of the +declaration itself changes. \begin{code} #include "HsVersions.h" @@ -229,6 +233,7 @@ import ListSetOps import Control.Monad import Data.List import Data.IORef +import System.FilePath \end{code} @@ -409,7 +414,7 @@ mkIface_ hsc_env maybe_old_iface mi_fix_fn = mkIfaceFixCache fixities } -- Add version information - ; ext_ver_fn = mkParentVerFun hsc_env eps + ; ext_ver_fn = mkParentVerFun hsc_env eps ; (new_iface, no_change_at_all, pp_diffs, pp_orphs) = {-# SCC "versioninfo" #-} addVersionInfo ext_ver_fn maybe_old_iface @@ -423,7 +428,13 @@ mkIface_ hsc_env maybe_old_iface ; dumpIfSet_dyn dflags Opt_D_dump_hi "FINAL INTERFACE" (pprModIface new_iface) - ; return (new_iface, no_change_at_all) } + -- bug #1617: on reload we weren't updating the PrintUnqualified + -- correctly. This stems from the fact that the interface had + -- not changed, so addVersionInfo returns the old ModIface + -- with the old GlobalRdrEnv (mi_globals). + ; let final_iface = new_iface{ mi_globals = Just rdr_env } + + ; return (final_iface, no_change_at_all) } where r1 `le_rule` r2 = ifRuleName r1 <= ifRuleName r2 i1 `le_inst` i2 = ifDFun i1 `le_occ` ifDFun i2 @@ -455,7 +466,7 @@ mkIface_ hsc_env maybe_old_iface ----------------------------- writeIfaceFile :: DynFlags -> ModLocation -> ModIface -> IO () writeIfaceFile dflags location new_iface - = do createDirectoryHierarchy (directoryOf hi_file_path) + = do createDirectoryHierarchy (takeDirectory hi_file_path) writeBinIface dflags hi_file_path new_iface where hi_file_path = ml_hi_file location @@ -698,20 +709,28 @@ computeChangedOccs ver_fn this_module old_usages eq_info -- return True if an external name has changed name_changed :: Name -> Bool name_changed nm - | Just ents <- lookupUFM usg_modmap (moduleName mod) - = case lookupUFM ents parent_occ of - Nothing -> pprPanic "computeChangedOccs" (ppr nm) - Just v -> v < new_version + | isWiredInName nm -- Wired-in things don't get into interface + = False -- files and hence don't get into the ver_fn + | Just ents <- lookupUFM usg_modmap (moduleName mod), + Just v <- lookupUFM ents parent_occ + = v < new_version + | modulePackageId mod == this_pkg + = WARN(True, ptext SLIT("computeChangedOccs") <+> ppr nm) True + -- should really be a panic, see #1959. The problem is that the usages doesn't + -- contain all the names that might be referred to by unfoldings. So as a + -- conservative workaround we just assume these names have changed. | otherwise = False -- must be in another package where mod = nameModule nm (parent_occ, new_version) = ver_fn nm + this_pkg = modulePackageId this_module + -- Turn the usages from the old ModIface into a mapping - usg_modmap = listToUFM [ (usg_mod usg, listToUFM (usg_entities usg)) + usg_modmap = listToUFM [ (usg_name usg, listToUFM (usg_entities usg)) | usg <- old_usages ] - get_local_eq_info :: GenIfaceEq NameSet -> GenIfaceEq OccSet + get_local_eq_info :: GenIfaceEq Name -> GenIfaceEq OccName get_local_eq_info Equal = Equal get_local_eq_info NotEqual = NotEqual get_local_eq_info (EqBut ns) = foldNameSet f Equal ns @@ -741,7 +760,7 @@ computeChangedOccs ver_fn this_module old_usages eq_info where (occs, iface_eqs) = unzip pairs add_changes so_far other = so_far -type OccIfaceEq = GenIfaceEq OccSet +type OccIfaceEq = GenIfaceEq OccName changedWrt :: OccSet -> OccIfaceEq -> Bool changedWrt so_far Equal = False