diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2021-05-21 16:51:59 +0200 |
---|---|---|
committer | Sylvain Henry <sylvain@haskus.fr> | 2021-06-07 10:35:39 +0200 |
commit | 4dc681c7c0345ee8ae268749d98b419dabf6a3bc (patch) | |
tree | ab05546d61b2d90f2fc9e652a13da48ce89096ae /compiler/GHC/SysTools/Info.hs | |
parent | 5e1a224435fc6ebd34d02566f17fe1eaf5475bab (diff) | |
download | haskell-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/SysTools/Info.hs')
-rw-r--r-- | compiler/GHC/SysTools/Info.hs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/compiler/GHC/SysTools/Info.hs b/compiler/GHC/SysTools/Info.hs index 733c2eaade..12be61ea0b 100644 --- a/compiler/GHC/SysTools/Info.hs +++ b/compiler/GHC/SysTools/Info.hs @@ -195,10 +195,10 @@ getLinkerInfo' logger dflags = do parseLinkerInfo (lines stdo) (lines stde) exitc ) (\err -> do - debugTraceMsg logger dflags 2 + debugTraceMsg logger 2 (text "Error (figuring out linker information):" <+> text (show err)) - errorMsg logger dflags $ hang (text "Warning:") 9 $ + errorMsg logger $ hang (text "Warning:") 9 $ text "Couldn't figure out linker information!" $$ text "Make sure you're using GNU ld, GNU gold" <+> text "or the built in OS X linker, etc." @@ -213,7 +213,7 @@ getCompilerInfo logger dflags = do Just v -> return v Nothing -> do let pgm = pgm_c dflags - v <- getCompilerInfo' logger dflags pgm + v <- getCompilerInfo' logger pgm writeIORef (rtccInfo dflags) (Just v) return v @@ -225,13 +225,13 @@ getAssemblerInfo logger dflags = do Just v -> return v Nothing -> do let (pgm, _) = pgm_a dflags - v <- getCompilerInfo' logger dflags pgm + v <- getCompilerInfo' logger pgm writeIORef (rtasmInfo dflags) (Just v) return v -- See Note [Run-time linker info]. -getCompilerInfo' :: Logger -> DynFlags -> String -> IO CompilerInfo -getCompilerInfo' logger dflags pgm = do +getCompilerInfo' :: Logger -> String -> IO CompilerInfo +getCompilerInfo' logger pgm = do let -- Try to grab the info from the process output. parseCompilerInfo _stdo stde _exitc -- Regular GCC @@ -264,10 +264,10 @@ getCompilerInfo' logger dflags pgm = do parseCompilerInfo (lines stdo) (lines stde) exitc ) (\err -> do - debugTraceMsg logger dflags 2 + debugTraceMsg logger 2 (text "Error (figuring out C compiler information):" <+> text (show err)) - errorMsg logger dflags $ hang (text "Warning:") 9 $ + errorMsg logger $ hang (text "Warning:") 9 $ text "Couldn't figure out C compiler information!" $$ text "Make sure you're using GNU gcc, or clang" return UnknownCC |