summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorCarrie Xu <carrie.xmy@gmail.com>2021-10-06 23:02:04 +0800
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-12-01 03:08:46 -0500
commit7acb945d443e26c7e51850c9c51321b0a5a7978a (patch)
tree7ee62d80c789f3a801c8314d1b1252c1a9ca186c /compiler
parent87bd9a675441513871de55c3cca47a7bb3341639 (diff)
downloadhaskell-7acb945d443e26c7e51850c9c51321b0a5a7978a.tar.gz
Dump non-module specific info to file #20316
- Change the dumpPrefix to FilePath, and default to non-module - Add dot to seperate dump-file-prefix and suffix - Modify user guide to introduce how dump files are named - This commit does not affect Ghci dump file naming. See also #17500
Diffstat (limited to 'compiler')
-rw-r--r--compiler/GHC/Driver/Pipeline.hs2
-rw-r--r--compiler/GHC/Driver/Session.hs11
-rw-r--r--compiler/GHC/Utils/Logger.hs18
3 files changed, 15 insertions, 16 deletions
diff --git a/compiler/GHC/Driver/Pipeline.hs b/compiler/GHC/Driver/Pipeline.hs
index c758202268..8645184b1f 100644
--- a/compiler/GHC/Driver/Pipeline.hs
+++ b/compiler/GHC/Driver/Pipeline.hs
@@ -634,7 +634,7 @@ mkPipeEnv stop_phase input_fn output =
setDumpPrefix :: PipeEnv -> HscEnv -> HscEnv
setDumpPrefix pipe_env hsc_env =
- hscUpdateFlags (\dflags -> dflags { dumpPrefix = Just (src_basename pipe_env ++ ".")}) hsc_env
+ hscUpdateFlags (\dflags -> dflags { dumpPrefix = src_basename pipe_env ++ "."}) hsc_env
{- The Pipelines -}
diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs
index ccf4d18f2f..f7d24d1fd5 100644
--- a/compiler/GHC/Driver/Session.hs
+++ b/compiler/GHC/Driver/Session.hs
@@ -549,9 +549,10 @@ data DynFlags = DynFlags {
-- used to query the appropriate fields
-- (outputFile/dynOutputFile, ways, etc.)
- -- | This is set by 'GHC.Driver.Pipeline.setDumpPrefix'
- -- or 'ghc.GHCi.UI.runStmt' based on where its output is going.
- dumpPrefix :: Maybe FilePath,
+ -- | This defaults to 'non-module'. It can be set by
+ -- 'GHC.Driver.Pipeline.setDumpPrefix' or 'ghc.GHCi.UI.runStmt' based on
+ -- where its output is going.
+ dumpPrefix :: FilePath,
-- | Override the 'dumpPrefix' set by 'GHC.Driver.Pipeline.setDumpPrefix'
-- or 'ghc.GHCi.UI.runStmt'.
@@ -1159,7 +1160,7 @@ defaultDynFlags mySettings llvmConfig =
outputHi = Nothing,
dynOutputHi = Nothing,
dynLibLoader = SystemDependent,
- dumpPrefix = Nothing,
+ dumpPrefix = "non-module.",
dumpPrefixForce = Nothing,
ldInputs = [],
includePaths = IncludeSpecs [] [] [],
@@ -2192,7 +2193,7 @@ dynamic_flags_deps = [
, make_ord_flag defGhcFlag "dumpdir" (hasArg setDumpDir)
, make_ord_flag defGhcFlag "outputdir" (hasArg setOutputDir)
, make_ord_flag defGhcFlag "ddump-file-prefix"
- (hasArg (setDumpPrefixForce . Just))
+ (hasArg (setDumpPrefixForce . Just . flip (++) "."))
, make_ord_flag defGhcFlag "dynamic-too"
(NoArg (setGeneralFlag Opt_BuildDynamicToo))
diff --git a/compiler/GHC/Utils/Logger.hs b/compiler/GHC/Utils/Logger.hs
index 48601dd655..5593425b53 100644
--- a/compiler/GHC/Utils/Logger.hs
+++ b/compiler/GHC/Utils/Logger.hs
@@ -116,7 +116,7 @@ data LogFlags = LogFlags
, log_enable_timestamps :: !Bool -- ^ Enable timestamps
, log_dump_to_file :: !Bool -- ^ Enable dump to file
, log_dump_dir :: !(Maybe FilePath) -- ^ Dump directory
- , log_dump_prefix :: !(Maybe FilePath) -- ^ Normal dump path ("basename.")
+ , log_dump_prefix :: !FilePath -- ^ Normal dump path ("basename.")
, log_dump_prefix_override :: !(Maybe FilePath) -- ^ Overriden dump path
, log_enable_debug :: !Bool -- ^ Enable debug output
, log_verbosity :: !Int -- ^ Verbosity level
@@ -133,7 +133,7 @@ defaultLogFlags = LogFlags
, log_enable_timestamps = True
, log_dump_to_file = False
, log_dump_dir = Nothing
- , log_dump_prefix = Nothing
+ , log_dump_prefix = ""
, log_dump_prefix_override = Nothing
, log_enable_debug = False
, log_verbosity = 0
@@ -485,8 +485,7 @@ withDumpFileHandle dumps logflags flag action = do
chooseDumpFile :: LogFlags -> DumpFlag -> Maybe FilePath
chooseDumpFile logflags flag
| log_dump_to_file logflags || forced_to_file
- , Just prefix <- getPrefix
- = Just $ setDir (prefix ++ dump_suffix)
+ = Just $ setDir (getPrefix ++ dump_suffix)
| otherwise
= Nothing
@@ -510,13 +509,12 @@ chooseDumpFile logflags flag
-- dump file location is being forced
-- by the --ddump-file-prefix flag.
| Just prefix <- log_dump_prefix_override logflags
- = Just prefix
- -- dump file location chosen by GHC.Driver.Pipeline.runPipeline
- | Just prefix <- log_dump_prefix logflags
- = Just prefix
- -- we haven't got a place to put a dump file.
+ = prefix
+ -- dump file locations, module specified to [modulename] set by
+ -- GHC.Driver.Pipeline.runPipeline; non-module specific, e.g. Chasing dependencies,
+ -- to 'non-module' by default.
| otherwise
- = Nothing
+ = log_dump_prefix logflags
setDir f = case log_dump_dir logflags of
Just d -> d </> f
Nothing -> f