diff options
Diffstat (limited to 'compiler/iface/FlagChecker.hs')
-rw-r--r-- | compiler/iface/FlagChecker.hs | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/compiler/iface/FlagChecker.hs b/compiler/iface/FlagChecker.hs index 5e4a7092bf..0365be7338 100644 --- a/compiler/iface/FlagChecker.hs +++ b/compiler/iface/FlagChecker.hs @@ -10,6 +10,7 @@ import Binary import BinIface () import DynFlags import HscTypes +import Module import Name import Fingerprint -- import Outputable @@ -21,11 +22,12 @@ import System.FilePath (normalise) -- | Produce a fingerprint of a @DynFlags@ value. We only base -- the finger print on important fields in @DynFlags@ so that -- the recompilation checker can use this fingerprint. -fingerprintDynFlags :: DynFlags -> (BinHandle -> Name -> IO ()) +fingerprintDynFlags :: DynFlags -> Module -> (BinHandle -> Name -> IO ()) -> IO Fingerprint -fingerprintDynFlags DynFlags{..} nameio = - let mainis = (mainModIs, mainFunIs) +fingerprintDynFlags DynFlags{..} this_mod nameio = + let mainis = if mainModIs == this_mod then Just mainFunIs else Nothing + -- see #5878 -- pkgopts = (thisPackage dflags, sort $ packageFlags dflags) safeHs = setSafeMode safeHaskell -- oflags = sort $ filter filterOFlags $ flags dflags @@ -38,12 +40,8 @@ fingerprintDynFlags DynFlags{..} nameio = cpp = (map normalise includePaths, sOpt_P settings) -- normalise: eliminate spurious differences due to "./foo" vs "foo" - -- -i, -osuf, -hcsuf, -hisuf, -odir, -hidir, -stubdir, -o, -ohi - paths = (map normalise importPaths, - [ objectSuf, hcSuf, hiSuf ], - [ objectDir, hiDir, stubDir, outputHi ]) - -- NB. not outputFile, we don't want "ghc --make M -o <file>" - -- to force recompilation when <file> changes. + -- Note [path flags and recompilation] + paths = [ hcSuf ] -- -fprof-auto etc. prof = if opt_SccProfilingOn then fromEnum profAuto else 0 @@ -51,3 +49,33 @@ fingerprintDynFlags DynFlags{..} nameio = in -- pprTrace "flags" (ppr (mainis, safeHs, lang, cpp, paths)) $ computeFingerprint nameio (mainis, safeHs, lang, cpp, paths, prof) + +{- Note [path flags and recompilation] + +There are several flags that we deliberately omit from the +recompilation check; here we explain why. + +-osuf, -odir, -hisuf, -hidir + If GHC decides that it does not need to recompile, then + it must have found an up-to-date .hi file and .o file. + There is no point recording these flags - the user must + have passed the correct ones. Indeed, the user may + have compiled the source file in one-shot mode using + -o to specify the .o file, and then loaded it in GHCi + using -odir. + +-stubdir + We omit this one because it is automatically set by -outputdir, and + we don't want changes in -outputdir to automatically trigger + recompilation. This could be wrong, but only in very rare cases. + +-i (importPaths) + For the same reason as -osuf etc. above: if GHC decides not to + recompile, then it must have already checked all the .hi files on + which the current module depends, so it must have found them + successfully. It is occasionally useful to be able to cd to a + different directory and use -i flags to enable GHC to find the .hi + files; we don't want this to force recompilation. + +The only path-related flag left is -hcsuf. +-} |