import ErrUtils ( showPass )
import Util
import DriverUtil
+import TmpFiles
import Outputable
import Panic
import CmdLineOpts ( DynFlags(..) )
let mg2_with_srcimps = topological_sort True mg2unsorted
-- Sort out which linkables we wish to keep in the unlinked image.
- -- For each module, we take:
- --
- -- - the old in-core linkable, if available
- -- - an on-disk linkable, if available
- --
- -- and we take the youngest of these, provided it is younger than the
- -- source file.
- --
- -- If a module has a valid linkable, then it may be STABLE (see below),
- -- and it is classified as SOURCE UNCHANGED for the purposes of calling
- -- compile.
+ -- See getValidLinkables below for details.
valid_linkables <- getValidLinkables ui1 mg2unsorted_names
mg2_with_srcimps
-- Easy; just relink it all.
do when (verb >= 2) $
hPutStrLn stderr "Upsweep completely successful."
+
+ -- clean up after ourselves
+ cleanTempFilesExcept verb (ppFilesFromSummaries modsDone)
+
linkresult
<- link ghci_mode dflags a_root_is_Main ui3 pls2
case linkresult of
= map (unJust "linkables_to_link" . findModuleLinkable_maybe ui4)
mods_to_keep_names
+ -- clean up after ourselves
+ cleanTempFilesExcept verb (ppFilesFromSummaries mods_to_keep)
+
linkresult <- link ghci_mode dflags False linkables_to_link pls2
case linkresult of
LinkErrs _ _
map ms_mod mods_to_keep)
+ppFilesFromSummaries summaries
+ = [ fn | Just fn <- map (ml_hspp_file . ms_location) summaries ]
+
-----------------------------------------------------------------------------
-- getValidLinkables
+-- For each module (or SCC of modules), we take:
+--
+-- - the old in-core linkable, if available
+-- - an on-disk linkable, if available
+--
+-- and we take the youngest of these, provided it is younger than the
+-- source file. We ignore the on-disk linkables unless all of the
+-- dependents of this SCC also have on-disk linkables.
+--
+-- If a module has a valid linkable, then it may be STABLE (see below),
+-- and it is classified as SOURCE UNCHANGED for the purposes of calling
+-- compile.
+--
+-- ToDo: this pass could be merged with the preUpsweep.
+
getValidLinkables
:: [Linkable] -- old linkables
-> [ModuleName] -- all home modules
let all_home = map (moduleName.ms_mod) home_summaries
-- imports for modules we don't already have
- let needed_imps = filter (`notElem` all_home) imps
+ let needed_imps = nub (filter (`notElem` all_home) imps)
-- summarise them
needed_summaries <- mapM getSummary needed_imps