summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc/Module.hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-05-21 16:51:59 +0200
committerSylvain Henry <sylvain@haskus.fr>2021-06-07 10:35:39 +0200
commit4dc681c7c0345ee8ae268749d98b419dabf6a3bc (patch)
treeab05546d61b2d90f2fc9e652a13da48ce89096ae /compiler/GHC/Tc/Module.hs
parent5e1a224435fc6ebd34d02566f17fe1eaf5475bab (diff)
downloadhaskell-4dc681c7c0345ee8ae268749d98b419dabf6a3bc.tar.gz
Make Logger independent of DynFlags
Introduce LogFlags as a independent subset of DynFlags used for logging. As a consequence in many places we don't have to pass both Logger and DynFlags anymore. The main reason for this refactoring is that I want to refactor the systools interfaces: for now many systools functions use DynFlags both to use the Logger and to fetch their parameters (e.g. ldInputs for the linker). I'm interested in refactoring the way they fetch their parameters (i.e. use dedicated XxxOpts data types instead of DynFlags) for #19877. But if I did this refactoring before refactoring the Logger, we would have duplicate parameters (e.g. ldInputs from DynFlags and linkerInputs from LinkerOpts). Hence this patch first. Some flags don't really belong to LogFlags because they are subsystem specific (e.g. most DumpFlags). For example -ddump-asm should better be passed in NCGConfig somehow. This patch doesn't fix this tight coupling: the dump flags are part of the UI but they are passed all the way down for example to infer the file name for the dumps. Because LogFlags are a subset of the DynFlags, we must update the former when the latter changes (not so often). As a consequence we now use accessors to read/write DynFlags in HscEnv instead of using `hsc_dflags` directly. In the process I've also made some subsystems less dependent on DynFlags: - CmmToAsm: by passing some missing flags via NCGConfig (see new fields in GHC.CmmToAsm.Config) - Core.Opt.*: - by passing -dinline-check value into UnfoldingOpts - by fixing some Core passes interfaces (e.g. CallArity, FloatIn) that took DynFlags argument for no good reason. - as a side-effect GHC.Core.Opt.Pipeline.doCorePass is much less convoluted.
Diffstat (limited to 'compiler/GHC/Tc/Module.hs')
-rw-r--r--compiler/GHC/Tc/Module.hs9
1 files changed, 4 insertions, 5 deletions
diff --git a/compiler/GHC/Tc/Module.hs b/compiler/GHC/Tc/Module.hs
index d5e0f3255d..3fdc33c5a0 100644
--- a/compiler/GHC/Tc/Module.hs
+++ b/compiler/GHC/Tc/Module.hs
@@ -198,7 +198,7 @@ tcRnModule :: HscEnv
tcRnModule hsc_env mod_sum save_rn_syntax
parsedModule@HsParsedModule {hpm_module= L loc this_module}
| RealSrcSpan real_loc _ <- loc
- = withTiming logger dflags
+ = withTiming logger
(text "Renamer/typechecker"<+>brackets (ppr this_mod))
(const ()) $
initTc hsc_env hsc_src save_rn_syntax this_mod real_loc $
@@ -211,7 +211,6 @@ tcRnModule hsc_env mod_sum save_rn_syntax
where
hsc_src = ms_hsc_src mod_sum
- dflags = hsc_dflags hsc_env
logger = hsc_logger hsc_env
home_unit = hsc_home_unit hsc_env
err_msg = mkPlainErrorMsgEnvelope loc $
@@ -2914,11 +2913,11 @@ rnDump rn = dumpOptTcRn Opt_D_dump_rn "Renamer" FormatHaskell (ppr rn)
tcDump :: TcGblEnv -> TcRn ()
tcDump env
- = do { dflags <- getDynFlags ;
- unit_state <- hsc_units <$> getTopEnv ;
+ = do { unit_state <- hsc_units <$> getTopEnv ;
+ logger <- getLogger ;
-- Dump short output if -ddump-types or -ddump-tc
- when (dopt Opt_D_dump_types dflags || dopt Opt_D_dump_tc dflags)
+ when (logHasDumpFlag logger Opt_D_dump_types || logHasDumpFlag logger Opt_D_dump_tc)
(dumpTcRn True Opt_D_dump_types
"" FormatText (pprWithUnitState unit_state short_dump)) ;