[Git][ghc/ghc][master] driver: Fix -S with .cmm files

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Fri Jul 7 15:34:08 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
76983a0d by Matthew Pickering at 2023-07-07T11:32:58-04:00
driver: Fix -S with .cmm files

There was an oversight in the driver which assumed that you would always
produce a `.o` file when compiling a .cmm file.

Fixes #23610

- - - - -


4 changed files:

- compiler/GHC/Driver/Pipeline.hs
- testsuite/tests/cmm/should_compile/Makefile
- + testsuite/tests/cmm/should_compile/T23610.cmm
- testsuite/tests/cmm/should_compile/all.T


Changes:

=====================================
compiler/GHC/Driver/Pipeline.hs
=====================================
@@ -850,18 +850,18 @@ llvmManglePipeline pipe_env hsc_env location llc_fn = do
       else use (T_LlvmMangle pipe_env hsc_env llc_fn)
   asPipeline False pipe_env hsc_env location mangled_fn
 
-cmmCppPipeline :: P m => PipeEnv -> HscEnv -> FilePath -> m FilePath
+cmmCppPipeline :: P m => PipeEnv -> HscEnv -> FilePath -> m (Maybe FilePath)
 cmmCppPipeline pipe_env hsc_env input_fn = do
   output_fn <- use (T_CmmCpp pipe_env hsc_env input_fn)
   cmmPipeline pipe_env hsc_env output_fn
 
-cmmPipeline :: P m => PipeEnv -> HscEnv -> FilePath -> m FilePath
+cmmPipeline :: P m => PipeEnv -> HscEnv -> FilePath -> m (Maybe FilePath)
 cmmPipeline pipe_env hsc_env input_fn = do
   (fos, output_fn) <- use (T_Cmm pipe_env hsc_env input_fn)
   mo_fn <- hscPostBackendPipeline pipe_env hsc_env HsSrcFile (backend (hsc_dflags hsc_env)) Nothing output_fn
   case mo_fn of
-    Nothing -> panic "CMM pipeline - produced no .o file"
-    Just mo_fn -> use (T_MergeForeign pipe_env hsc_env mo_fn fos)
+    Nothing -> return Nothing
+    Just mo_fn -> Just <$> use (T_MergeForeign pipe_env hsc_env mo_fn fos)
 
 jsPipeline :: P m => PipeEnv -> HscEnv -> Maybe ModLocation -> FilePath -> m FilePath
 jsPipeline pipe_env hsc_env location input_fn = do
@@ -938,8 +938,8 @@ pipelineStart pipe_env hsc_env input_fn mb_phase =
    fromPhase LlvmLlc    = llvmLlcPipeline pipe_env hsc_env Nothing input_fn
    fromPhase LlvmMangle = llvmManglePipeline pipe_env hsc_env Nothing input_fn
    fromPhase StopLn     = return (Just input_fn)
-   fromPhase CmmCpp     = Just <$> cmmCppPipeline pipe_env hsc_env input_fn
-   fromPhase Cmm        = Just <$> cmmPipeline pipe_env hsc_env input_fn
+   fromPhase CmmCpp     = cmmCppPipeline pipe_env hsc_env input_fn
+   fromPhase Cmm        = cmmPipeline pipe_env hsc_env input_fn
    fromPhase Js         = Just <$> foreignJsPipeline pipe_env hsc_env Nothing input_fn
    fromPhase MergeForeign = panic "fromPhase: MergeForeign"
 


=====================================
testsuite/tests/cmm/should_compile/Makefile
=====================================
@@ -13,3 +13,6 @@ T16930:
 	grep -rl "after setInfoTableStackMap" `ls T16930.*`
 	grep -rl "Layout Stack" `ls T16930.*`
 	grep -rl "Post switch plan" `ls T16930.*`
+
+T23610:
+	'$(TEST_HC)' $(TEST_HC_OPTS) T23610.cmm -S


=====================================
testsuite/tests/cmm/should_compile/T23610.cmm
=====================================
@@ -0,0 +1,3 @@
+test(bits64 x) {
+    return (x);
+}


=====================================
testsuite/tests/cmm/should_compile/all.T
=====================================
@@ -8,3 +8,4 @@ test('cmm_sink_sp', [ only_ways(['optasm']), grep_errmsg(r'(\[Sp.*\]).*(=).*(\[.
 test('T16930', normal, makefile_test, ['T16930'])
 test('T17442', normal, compile, [''])
 test('T20725', normal, compile, ['-package ghc'])
+test('T23610', normal, makefile_test, ['T23610'])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/76983a0dca64dfb7e94aea0c4f494921f8513b41

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/76983a0dca64dfb7e94aea0c4f494921f8513b41
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230707/46fd1ab2/attachment-0001.html>


More information about the ghc-commits mailing list