[Git][ghc/ghc][master] 2 commits: testsuite: add test for #23944
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Fri Dec 8 07:26:05 UTC 2023
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
c1c8abf8 by Zubin Duggal at 2023-12-08T02:25:07-05:00
testsuite: add test for #23944
- - - - -
6329d308 by Zubin Duggal at 2023-12-08T02:25:07-05:00
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,15 @@ 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
+ -- See Note [Writing interface files]
+ -- If we are writing a simple interface (not . backendWritesFiles), then
+ -- hscMaybeWriteIface in the regular pipeline will write both the hi and
+ -- dyn_hi files. This way we can avoid running the pipeline twice and
+ -- generating a duplicate linkable.
+ -- We must not run the backend a second time with `dynamicNow` enable because
+ -- all the work has already been done in the first pipeline.
+ 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
=====================================
@@ -327,3 +327,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/57c391c463f26b7025df9b340ad98416cff1d2b2...6329d308eb00891674754c1f58f1ee2880305a36
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/57c391c463f26b7025df9b340ad98416cff1d2b2...6329d308eb00891674754c1f58f1ee2880305a36
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/20231208/4450a935/attachment-0001.html>
More information about the ghc-commits
mailing list