updOptLevel,
setTmpDir,
setPackageName,
+ doingTickyProfiling,
-- ** Parsing DynFlags
parseDynamicFlags,
import Maybes ( orElse )
import SrcLoc
import FastString
+import FiniteMap
import Outputable
import {-# SOURCE #-} ErrUtils ( Severity(..), Message, mkLocMessage )
-import Data.IORef ( readIORef )
+import Data.IORef
import Control.Monad ( when )
import Data.Char
| Opt_RegsGraph -- do graph coloring register allocation
| Opt_RegsIterative -- do iterative coalescing graph coloring register allocation
+ -- profiling opts
+ | Opt_AutoSccsOnAllToplevs
+ | Opt_AutoSccsOnExportedToplevs
+ | Opt_AutoSccsOnIndividualCafs
+
-- misc opts
| Opt_Cpp
| Opt_Pp
pkgDatabase :: Maybe (UniqFM PackageConfig),
pkgState :: PackageState,
+ -- Temporary files
+ -- These have to be IORefs, because the defaultCleanupHandler needs to
+ -- know what to clean when an exception happens
+ filesToClean :: IORef [FilePath],
+ dirsToClean :: IORef (FiniteMap FilePath FilePath),
+
-- hsc dynamic flags
flags :: [DynFlag],
-- | The target code type of the compilation (if any).
--
+-- Whenever you change the target, also make sure to set 'ghcLink' to
+-- something sensible.
+--
-- 'HscNothing' can be used to avoid generating any output, however, note
-- that:
--
-- * This will not run the desugaring step, thus no warnings generated in
--- this step will be output. In particular, this includes warnings
--- related to pattern matching.
+-- this step will be output. In particular, this includes warnings related
+-- to pattern matching. You can run the desugarer manually using
+-- 'GHC.desugarModule'.
--
--- * At the moment switching from 'HscNothing' to 'HscInterpreted' without
--- unloading first is not safe. To unload use
--- @GHC.setTargets [] >> GHC.load LoadAllTargets@.
+-- * If a program uses Template Haskell the typechecker may try to run code
+-- from an imported module. This will fail if no code has been generated
+-- for this module. You can use 'GHC.needsTemplateHaskell' to detect
+-- whether this might be the case and choose to either switch to a
+-- different target or avoid typechecking such modules. (The latter may
+-- preferable for security reasons.)
--
data HscTarget
- = HscC
- | HscAsm
- | HscJava
- | HscInterpreted
- | HscNothing
+ = HscC -- ^ Generate C code.
+ | HscAsm -- ^ Generate assembly using the native code generator.
+ | HscJava -- ^ Generate Java bytecode.
+ | HscInterpreted -- ^ Generate bytecode. (Requires 'LinkInMemory')
+ | HscNothing -- ^ Don't generate any code. See notes above.
deriving (Eq, Show)
-- | Will this target result in an object file on the disk?
data GhcLink
= NoLink -- ^ Don't link at all
| LinkBinary -- ^ Link object code into a binary
- | LinkInMemory -- ^ Use the in-memory dynamic linker
+ | LinkInMemory -- ^ Use the in-memory dynamic linker (works for both
+ -- bytecode and object code).
| LinkDynLib -- ^ Link objects into a dynamic lib (DLL on Windows, DSO on ELF platforms)
deriving (Eq, Show)
isNoLink NoLink = True
isNoLink _ = False
+-- Is it worth evaluating this Bool and caching it in the DynFlags value
+-- during initDynFlags?
+doingTickyProfiling :: DynFlags -> Bool
+doingTickyProfiling dflags = WayTicky `elem` wayNames dflags
+
data PackageFlag
= ExposePackage String
| HidePackage String
ways <- readIORef v_Ways
build_tag <- readIORef v_Build_tag
rts_build_tag <- readIORef v_RTS_Build_tag
+ refFilesToClean <- newIORef []
+ refDirsToClean <- newIORef emptyFM
return dflags{
wayNames = ways,
buildTag = build_tag,
- rtsBuildTag = rts_build_tag
+ rtsBuildTag = rts_build_tag,
+ filesToClean = refFilesToClean,
+ dirsToClean = refDirsToClean
}
-- | The normal 'DynFlags'. Note that they is not suitable for use in this form
depExcludeMods = [],
depSuffixes = [],
-- end of ghc -M values
+ filesToClean = panic "defaultDynFlags: No filesToClean",
+ dirsToClean = panic "defaultDynFlags: No dirsToClean",
haddockOptions = Nothing,
flags = [
Opt_AutoLinkPackages,
(IntSuffix $ \n -> upd $ \dfs -> dfs{ ctxtStkDepth = n })
Supported
+ ------ Profiling ----------------------------------------------------
+
+ -- XXX Should the -f* flags be deprecated?
+ -- They don't seem to be documented
+ , Flag "fauto-sccs-on-all-toplevs"
+ (NoArg (setDynFlag Opt_AutoSccsOnAllToplevs))
+ Supported
+ , Flag "auto-all"
+ (NoArg (setDynFlag Opt_AutoSccsOnAllToplevs))
+ Supported
+ , Flag "no-auto-all"
+ (NoArg (unSetDynFlag Opt_AutoSccsOnAllToplevs))
+ Supported
+ , Flag "fauto-sccs-on-exported-toplevs"
+ (NoArg (setDynFlag Opt_AutoSccsOnExportedToplevs))
+ Supported
+ , Flag "auto"
+ (NoArg (setDynFlag Opt_AutoSccsOnExportedToplevs))
+ Supported
+ , Flag "no-auto"
+ (NoArg (unSetDynFlag Opt_AutoSccsOnExportedToplevs))
+ Supported
+ , Flag "fauto-sccs-on-individual-cafs"
+ (NoArg (setDynFlag Opt_AutoSccsOnIndividualCafs))
+ Supported
+ , Flag "caf-all"
+ (NoArg (setDynFlag Opt_AutoSccsOnIndividualCafs))
+ Supported
+ , Flag "no-caf-all"
+ (NoArg (unSetDynFlag Opt_AutoSccsOnIndividualCafs))
+ Supported
+
------ DPH flags ----------------------------------------------------
, Flag "fdph-seq"
, (Opt_ScopedTypeVariables, Opt_RelaxedPolyRec) -- Ditto for scoped type variables; see
-- Note [Scoped tyvars] in TcBinds
+ , (Opt_ImpredicativeTypes, Opt_RankNTypes)
]
glasgowExtsFlags :: [DynFlag]
, Opt_PatternGuards
, Opt_LiberalTypeSynonyms
, Opt_RankNTypes
- , Opt_ImpredicativeTypes
, Opt_TypeOperators
, Opt_RecursiveDo
, Opt_ParallelListComp