diff options
author | Carrie Xu <carrie.xmy@gmail.com> | 2021-10-06 23:02:04 +0800 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-12-01 03:08:46 -0500 |
commit | 7acb945d443e26c7e51850c9c51321b0a5a7978a (patch) | |
tree | 7ee62d80c789f3a801c8314d1b1252c1a9ca186c | |
parent | 87bd9a675441513871de55c3cca47a7bb3341639 (diff) | |
download | haskell-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
-rw-r--r-- | compiler/GHC/Driver/Pipeline.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Driver/Session.hs | 11 | ||||
-rw-r--r-- | compiler/GHC/Utils/Logger.hs | 18 | ||||
-rw-r--r-- | docs/users_guide/debugging.rst | 12 | ||||
-rw-r--r-- | ghc/GHCi/UI.hs | 2 | ||||
-rw-r--r-- | testsuite/tests/driver/Makefile | 6 | ||||
-rw-r--r-- | testsuite/tests/driver/T20316.stderr | 6 | ||||
-rw-r--r-- | testsuite/tests/driver/T20316.stdout | 4 | ||||
-rw-r--r-- | testsuite/tests/driver/all.T | 1 |
9 files changed, 41 insertions, 21 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 diff --git a/docs/users_guide/debugging.rst b/docs/users_guide/debugging.rst index ec40a5e251..569923ade4 100644 --- a/docs/users_guide/debugging.rst +++ b/docs/users_guide/debugging.rst @@ -27,10 +27,14 @@ Dumping out compiler intermediate structures :shortdesc: Dump to files instead of stdout :type: dynamic - Causes the output from all of the flags listed below to be dumped - to a file. The file name depends upon the output produced; for instance, - output from :ghc-flag:`-ddump-simpl` will end up in - :file:`{module}.dump-simpl`. + Causes the output from each of flags starting with "-ddump", to be + dumped to a file or files. If you want to have all the output from one + single flag saved to one file, use :ghc-flag:`-ddump-file-prefix=⟨str⟩` + (see descriptions below). Otherwise, the output will go to several + files, including one for non-module specific and several for module + specific. The suffix of a dump file depends on the flag turned on, for + instance, output from :ghc-flag:`-ddump-simpl` will end up in + :file:`prefix.dump-simpl`. .. ghc-flag:: -ddump-file-prefix=⟨str⟩ :shortdesc: Set the prefix of the filenames used for debugging output. diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index b628575362..3a7946bca8 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -1299,7 +1299,7 @@ runStmt input step = do setDumpFilePrefix :: GHC.GhcMonad m => InteractiveContext -> m () -- #17500 setDumpFilePrefix ic = do dflags <- GHC.getInteractiveDynFlags - GHC.setInteractiveDynFlags dflags { dumpPrefix = Just (modStr ++ ".") } + GHC.setInteractiveDynFlags dflags { dumpPrefix = modStr ++ "." } where modStr = moduleNameString $ moduleName $ icInteractiveModule $ ic diff --git a/testsuite/tests/driver/Makefile b/testsuite/tests/driver/Makefile index 58d35b5a06..0542f9de47 100644 --- a/testsuite/tests/driver/Makefile +++ b/testsuite/tests/driver/Makefile @@ -733,3 +733,9 @@ T20084: # Don't compile "$(TEST_HC)" $(TEST_HC_OPTS) T20084.hs +.PHONY: T20316 +T20316: + echo 'main = print "Hello World"' > T20316.hs + "$(TEST_HC)" $(TEST_HC_OPTS) -fno-code T20316.hs -ddump-to-file -ddump-timings; + echo "*** non-module.dump-timings ***" + cat non-module.dump-timings | grep alloc | sed 's/alloc.*//' diff --git a/testsuite/tests/driver/T20316.stderr b/testsuite/tests/driver/T20316.stderr new file mode 100644 index 0000000000..ef979dec18 --- /dev/null +++ b/testsuite/tests/driver/T20316.stderr @@ -0,0 +1,6 @@ +*** initializing unit database: +*** Chasing dependencies: +*** Parser [Main]: +*** Renamer/typechecker [Main]: +*** Desugar [Main]: +*** CoreTidy [Main]: diff --git a/testsuite/tests/driver/T20316.stdout b/testsuite/tests/driver/T20316.stdout new file mode 100644 index 0000000000..280a3c80e7 --- /dev/null +++ b/testsuite/tests/driver/T20316.stdout @@ -0,0 +1,4 @@ +[1 of 1] Compiling Main ( T20316.hs, nothing ) +*** non-module.dump-timings *** +initializing unit database: +Chasing dependencies: diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T index 742f74f953..4af15b7640 100644 --- a/testsuite/tests/driver/all.T +++ b/testsuite/tests/driver/all.T @@ -301,3 +301,4 @@ test('T20459', normal, multimod_compile_fail, ['T20459B', '']) test('T20200loop', extra_files(['T20200loop']), multimod_compile, ['Datatypes', '-iT20200loop -O -v0']) +test('T20316', normal, makefile_test, []) |