f670437ffe623ee5ae3056708ea44596b3bab7d0
[ghc.git] / compiler / iface / FlagChecker.hs
1 {-# LANGUAGE RecordWildCards #-}
2
3 -- | This module manages storing the various GHC option flags in a modules
4 -- interface file as part of the recompilation checking infrastructure.
5 module FlagChecker (
6 fingerprintDynFlags
7 ) where
8
9 import Binary
10 import BinIface ()
11 import DynFlags
12 import HscTypes
13 import Name
14 import Fingerprint
15 -- import Outputable
16
17 import Data.List (sort)
18 import System.FilePath (normalise)
19
20 -- | Produce a fingerprint of a @DynFlags@ value. We only base
21 -- the finger print on important fields in @DynFlags@ so that
22 -- the recompilation checker can use this fingerprint.
23 fingerprintDynFlags :: DynFlags -> (BinHandle -> Name -> IO ())
24 -> IO Fingerprint
25
26 fingerprintDynFlags DynFlags{..} nameio =
27 let mainis = (mainModIs, mainFunIs)
28 -- pkgopts = (thisPackage dflags, sort $ packageFlags dflags)
29 safeHs = setSafeMode safeHaskell
30 -- oflags = sort $ filter filterOFlags $ flags dflags
31
32 -- *all* the extension flags and the language
33 lang = (fmap fromEnum language,
34 sort $ map fromEnum $ extensionFlags)
35
36 -- -I, -D and -U flags affect CPP
37 cpp = (map normalise includePaths, sOpt_P settings)
38 -- normalise: eliminate spurious differences due to "./foo" vs "foo"
39
40 -- -i, -osuf, -hcsuf, -hisuf, -odir, -hidir, -stubdir, -o, -ohi
41 paths = (map normalise importPaths,
42 [ objectSuf, hcSuf, hiSuf ],
43 [ objectDir, hiDir, stubDir, outputFile, outputHi ])
44
45 in -- pprTrace "flags" (ppr (mainis, safeHs, lang, cpp, paths)) $
46 computeFingerprint nameio (mainis, safeHs, lang, cpp, paths)
47