From: sewardj Date: Fri, 17 Nov 2000 10:13:22 +0000 (+0000) Subject: [project @ 2000-11-17 10:13:21 by sewardj] X-Git-Tag: Approximately_9120_patches~3321 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=f5f3b9d9a4ae248d847a7fc6e5929ddfdf0eaea8;p=ghc-hetmet.git [project @ 2000-11-17 10:13:21 by sewardj] Make file up-to-dateness checking work in batch mode. --- diff --git a/ghc/compiler/compMan/CmLink.lhs b/ghc/compiler/compMan/CmLink.lhs index 28b7a47..c6619a6 100644 --- a/ghc/compiler/compMan/CmLink.lhs +++ b/ghc/compiler/compMan/CmLink.lhs @@ -155,8 +155,9 @@ filterModuleLinkables p (li:lis) -- Linker for interactive mode #ifndef GHCI -linkObjs = panic "CmLink.linkObjs: no interpreter" -unload = panic "CmLink.unload: no interpreter" +linkObjs = panic "CmLink.linkObjs: no interpreter" +unload = panic "CmLink.unload: no interpreter" +lookupClosure = panic "CmLink.lookupClosure: no interpreter" #else linkObjs [] pls = linkFinish pls [] [] linkObjs (l@(LM _ uls) : ls) pls diff --git a/ghc/compiler/compMan/CompManager.lhs b/ghc/compiler/compMan/CompManager.lhs index 69597c6..b933084 100644 --- a/ghc/compiler/compMan/CompManager.lhs +++ b/ghc/compiler/compMan/CompManager.lhs @@ -27,7 +27,7 @@ import Interpreter ( HValue ) import Module ( ModuleName, moduleName, packageOfModule, isModuleInThisPackage, PackageName, moduleEnvElts, moduleNameUserString ) -import CmStaticInfo ( Package(..), PackageConfigInfo, GhciMode ) +import CmStaticInfo ( Package(..), PackageConfigInfo, GhciMode(..) ) import DriverPipeline import GetImports import HscTypes ( HomeSymbolTable, HomeIfaceTable, @@ -45,7 +45,7 @@ import Panic ( panic ) import Exception ( throwDyn ) import IO import Time ( ClockTime ) -import Directory ( getModificationTime ) +import Directory ( getModificationTime, doesFileExist ) \end{code} @@ -377,9 +377,29 @@ upsweep_mod ghci_mode oldUI threaded1 summary1 source_might_have_changed = do let mod_name = name_of_summary summary1 let (CmThreaded pcs1 hst1 hit1) = threaded1 let old_iface = lookupUFM hit1 (name_of_summary summary1) - compresult <- compile ghci_mode summary1 (not source_might_have_changed) + + -- We *have* to compile it if we're in batch mode and we can't see + -- a previous linkable for it on disk. + compilation_mandatory + <- if ghci_mode /= Batch then return False + else case ml_obj_file (ms_location summary1) of + Nothing -> do --putStrLn "cmcm: object?!" + return True + Just obj_fn -> do --putStrLn ("cmcm: old obj " ++ obj_fn) + b <- doesFileExist obj_fn + return (not b) + + let compilation_might_be_needed + = source_might_have_changed || compilation_mandatory + source_unchanged + = not compilation_might_be_needed + + compresult <- compile ghci_mode summary1 source_unchanged old_iface hst1 hit1 pcs1 + putStrLn ( "UPSWEEP_MOD: smhc = " ++ show source_might_have_changed + ++ ", cman = " ++ show compilation_mandatory) + case compresult of -- Compilation "succeeded", but didn't return a new iface or @@ -389,7 +409,13 @@ upsweep_mod ghci_mode oldUI threaded1 summary1 source_might_have_changed -> let hst2 = addToUFM hst1 mod_name details hit2 = hit1 threaded2 = CmThreaded pcs2 hst2 hit2 - old_linkable = findModuleLinkable oldUI mod_name + old_linkable + | ghci_mode == Interactive + = findModuleLinkable oldUI mod_name + | otherwise + = LM mod_name + [DotO (unJust (ml_obj_file (ms_location summary1)) + "upsweep_mod")] in return (threaded2, Just old_linkable) -- Compilation really did happen, and succeeded. A new diff --git a/ghc/compiler/main/HscMain.lhs b/ghc/compiler/main/HscMain.lhs index 108688e..a4209ae 100644 --- a/ghc/compiler/main/HscMain.lhs +++ b/ghc/compiler/main/HscMain.lhs @@ -168,7 +168,8 @@ hscRecomp ghci_mode dflags location maybe_checked_iface hst hit pcs_ch ------------------- -- PARSE ------------------- - ; maybe_parsed <- myParseModule dflags (unJust (ml_hspp_file location) "hscRecomp:hspp") + ; maybe_parsed <- myParseModule dflags (unJust (ml_hspp_file location) + "hscRecomp:hspp") ; case maybe_parsed of { Nothing -> return (HscFail pcs_ch); Just rdr_module -> do {