module GHC.Driver.Config
( initOptCoercionOpts
, initSimpleOpts
, initBCOOpts
, initEvalOpts
)
where
import GHC.Prelude
import GHC.Driver.Session
import GHC.Core.SimpleOpt
import GHC.Core.Coercion.Opt
import GHC.Runtime.Interpreter (BCOOpts(..))
import GHCi.Message (EvalOpts(..))
import GHC.Conc (getNumProcessors)
import Control.Monad.IO.Class
initOptCoercionOpts :: DynFlags -> OptCoercionOpts
initOptCoercionOpts :: DynFlags -> OptCoercionOpts
initOptCoercionOpts DynFlags
dflags = OptCoercionOpts
{ optCoercionEnabled :: Bool
optCoercionEnabled = Bool -> Bool
not (DynFlags -> Bool
hasNoOptCoercion DynFlags
dflags)
}
initSimpleOpts :: DynFlags -> SimpleOpts
initSimpleOpts :: DynFlags -> SimpleOpts
initSimpleOpts DynFlags
dflags = SimpleOpts
{ so_uf_opts :: UnfoldingOpts
so_uf_opts = DynFlags -> UnfoldingOpts
unfoldingOpts DynFlags
dflags
, so_co_opts :: OptCoercionOpts
so_co_opts = DynFlags -> OptCoercionOpts
initOptCoercionOpts DynFlags
dflags
, so_eta_red :: Bool
so_eta_red = GeneralFlag -> DynFlags -> Bool
gopt GeneralFlag
Opt_DoEtaReduction DynFlags
dflags
}
initBCOOpts :: DynFlags -> IO BCOOpts
initBCOOpts :: DynFlags -> IO BCOOpts
initBCOOpts DynFlags
dflags = do
Int
n_jobs <- case DynFlags -> Maybe Int
parMakeCount DynFlags
dflags of
Maybe Int
Nothing -> forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO Int
getNumProcessors
Just Int
n -> forall (m :: * -> *) a. Monad m => a -> m a
return Int
n
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Int -> BCOOpts
BCOOpts Int
n_jobs
initEvalOpts :: DynFlags -> Bool -> EvalOpts
initEvalOpts :: DynFlags -> Bool -> EvalOpts
initEvalOpts DynFlags
dflags Bool
step =
EvalOpts
{ useSandboxThread :: Bool
useSandboxThread = GeneralFlag -> DynFlags -> Bool
gopt GeneralFlag
Opt_GhciSandbox DynFlags
dflags
, singleStep :: Bool
singleStep = Bool
step
, breakOnException :: Bool
breakOnException = GeneralFlag -> DynFlags -> Bool
gopt GeneralFlag
Opt_BreakOnException DynFlags
dflags
, breakOnError :: Bool
breakOnError = GeneralFlag -> DynFlags -> Bool
gopt GeneralFlag
Opt_BreakOnError DynFlags
dflags
}