From 222e99d9e6b24c17a67c07d24d05999701b83e96 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Fri, 16 Dec 2016 12:00:27 -0500 Subject: 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 --- 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 141f59f299..9a64794b77 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" } -- cgit v1.2.1