[commit: ghc] master: Make up a module name for c-- files (222e99d)

git at git.haskell.org git at git.haskell.org
Fri Dec 16 17:11:41 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/222e99d9e6b24c17a67c07d24d05999701b83e96/ghc

>---------------------------------------------------------------

commit 222e99d9e6b24c17a67c07d24d05999701b83e96
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Fri Dec 16 12:00:27 2016 -0500

    Make up a module name for c-- files
    
    Summary:
    We used to pass a bottoming Module to the NCG, which resulted in panics
    when `-v` was used due to debug output (see #11784). Instead we make up
    a module name. This is a bit scary since `PIC.howToAccessLabel` might
    actually use the Module, but if it wasn't crashing before I suppose it's
    fine.
    
    Test Plan: `touch hi.cmm; ghc -v2 -c -dcmm-lint hi.cmm`
    
    Reviewers: austin, simonmar
    
    Reviewed By: simonmar
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2864
    
    GHC Trac Issues: #11784


>---------------------------------------------------------------

222e99d9e6b24c17a67c07d24d05999701b83e96
 compiler/main/HscMain.hs | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/compiler/main/HscMain.hs b/compiler/main/HscMain.hs
index 141f59f..9a64794 100644
--- a/compiler/main/HscMain.hs
+++ b/compiler/main/HscMain.hs
@@ -1363,10 +1363,13 @@ hscCompileCmmFile hsc_env filename output_filename = runHsc hsc_env $ do
         dumpIfSet_dyn dflags Opt_D_dump_cmm_verbose "Parsed Cmm" (ppr cmm)
         (_, cmmgroup) <- cmmPipeline hsc_env initTopSRT cmm
         rawCmms <- cmmToRawCmm dflags (Stream.yield cmmgroup)
-        _ <- codeOutput dflags no_mod output_filename no_loc NoStubs [] rawCmms
+        let -- Make up a module name to give the NCG. We can't pass bottom here
+            -- lest we reproduce #11784.
+            mod_name = mkModuleName $ "Cmm$" ++ FilePath.takeFileName filename
+            cmm_mod = mkModule (thisPackage dflags) mod_name
+        _ <- codeOutput dflags cmm_mod output_filename no_loc NoStubs [] rawCmms
         return ()
   where
-    no_mod = panic "hscCompileCmmFile: no_mod"
     no_loc = ModLocation{ ml_hs_file  = Just filename,
                           ml_hi_file  = panic "hscCompileCmmFile: no hi file",
                           ml_obj_file = panic "hscCompileCmmFile: no obj file" }



More information about the ghc-commits mailing list