From 4dc681c7c0345ee8ae268749d98b419dabf6a3bc Mon Sep 17 00:00:00 2001 From: Sylvain Henry Date: Fri, 21 May 2021 16:51:59 +0200 Subject: 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. --- compiler/GHC/Driver/Config.hs | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'compiler/GHC/Driver/Config.hs') diff --git a/compiler/GHC/Driver/Config.hs b/compiler/GHC/Driver/Config.hs index 7a96271403..2d4135a847 100644 --- a/compiler/GHC/Driver/Config.hs +++ b/compiler/GHC/Driver/Config.hs @@ -2,7 +2,6 @@ module GHC.Driver.Config ( initOptCoercionOpts , initSimpleOpts - , initParserOpts , initBCOOpts , initEvalOpts ) @@ -13,9 +12,7 @@ import GHC.Prelude import GHC.Driver.Session import GHC.Core.SimpleOpt import GHC.Core.Coercion.Opt -import GHC.Parser.Lexer import GHC.Runtime.Interpreter (BCOOpts(..)) -import GHC.Utils.Error (mkPlainMsgEnvelope) import GHCi.Message (EvalOpts(..)) import GHC.Conc (getNumProcessors) @@ -34,18 +31,6 @@ initSimpleOpts dflags = SimpleOpts , so_co_opts = initOptCoercionOpts dflags } --- | Extracts the flag information needed for parsing -initParserOpts :: DynFlags -> ParserOpts -initParserOpts = - mkParserOpts - <$> warningFlags - <*> extensionFlags - <*> mkPlainMsgEnvelope - <*> safeImportsOn - <*> gopt Opt_Haddock - <*> gopt Opt_KeepRawTokenStream - <*> const True - -- | Extract BCO options from DynFlags initBCOOpts :: DynFlags -> IO BCOOpts initBCOOpts dflags = do -- cgit v1.2.1