[Git][ghc/ghc][wip/23944] 2 commits: testsuite: add test for #23944

Zubin (@wz1000) gitlab at gitlab.haskell.org
Wed Oct 11 11:35:57 UTC 2023



Zubin pushed to branch wip/23944 at Glasgow Haskell Compiler / GHC


Commits:
6e77b703 by Zubin Duggal at 2023-10-11T17:05:47+05:30
testsuite: add test for #23944

- - - - -
42d5eda9 by Zubin Duggal at 2023-10-11T17:05:47+05:30
driver: Only run a dynamic-too pipeline if object files are going to be generated

Otherwise we run into a panic in hscMaybeWriteIface: "Unexpected DT_Dyn state
when writing simple interface" when dynamic-too is enabled

We could remove the panic and just write the interface even if the state is `DT_Dyn`,
but it seems pointless to run the pipeline twice when `hscMaybeWriteIface` is already
designed to write both `hi` and `dyn_hi` files if dynamic-too is enabled.

Fixes #23944.

- - - - -


5 changed files:

- compiler/GHC/Driver/Pipeline.hs
- + testsuite/tests/driver/T23944.hs
- + testsuite/tests/driver/T23944.stderr
- + testsuite/tests/driver/T23944A.hs
- testsuite/tests/driver/all.T


Changes:

=====================================
compiler/GHC/Driver/Pipeline.hs
=====================================
@@ -788,7 +788,9 @@ hscBackendPipeline pipe_env hsc_env mod_sum result =
   if backendGeneratesCode (backend (hsc_dflags hsc_env)) then
     do
       res <- hscGenBackendPipeline pipe_env hsc_env mod_sum result
-      when (gopt Opt_BuildDynamicToo (hsc_dflags hsc_env)) $ do
+      -- Only run dynamic-too if the backend generates object files, otherwise there is no point
+      -- This is the same check as in runHscBackendPhase
+      when (gopt Opt_BuildDynamicToo (hsc_dflags hsc_env) && backendWritesFiles (backend (hsc_dflags hsc_env)) ) $ do
           let dflags' = setDynamicNow (hsc_dflags hsc_env) -- set "dynamicNow"
           () <$ hscGenBackendPipeline pipe_env (hscSetFlags dflags' hsc_env) mod_sum result
       return res


=====================================
testsuite/tests/driver/T23944.hs
=====================================
@@ -0,0 +1,5 @@
+{-# LANGUAGE TemplateHaskell #-}
+module T23944 where
+import T23944A
+
+$(foo)


=====================================
testsuite/tests/driver/T23944.stderr
=====================================
@@ -0,0 +1,2 @@
+[1 of 2] Compiling T23944A          ( T23944A.hs, interpreted )
+[2 of 2] Compiling T23944           ( T23944.hs, nothing )


=====================================
testsuite/tests/driver/T23944A.hs
=====================================
@@ -0,0 +1,7 @@
+{-# LANGUAGE TemplateHaskell #-}
+module T23944A where
+
+import Language.Haskell.TH
+
+foo :: DecsQ
+foo = pure []


=====================================
testsuite/tests/driver/all.T
=====================================
@@ -318,3 +318,4 @@ test('T22669', req_interp, makefile_test, [])
 test('T23339', req_c, makefile_test, [])
 test('T23339B', [extra_files(['T23339.hs']), req_c], makefile_test, [])
 test('T23613', normal, compile_and_run, ['-this-unit-id=foo'])
+test('T23944', [unless(have_dynamic(), skip), extra_files(['T23944A.hs'])], multimod_compile, ['T23944 T23944A', '-fprefer-byte-code -fbyte-code -fno-code -dynamic-too -fwrite-interface'])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c5212e2f1126eab2f610d827d26d474db16436fa...42d5eda96609e0c2fcda5ca834bd965cf801092a

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c5212e2f1126eab2f610d827d26d474db16436fa...42d5eda96609e0c2fcda5ca834bd965cf801092a
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/20231011/663fa5fc/attachment-0001.html>


More information about the ghc-commits mailing list