Hannes Siebenhandl pushed to branch wip/fendor/no-code-output-constr at Glasgow Haskell Compiler / GHC
Commits:
-
c3f5364b
by fendor at 2026-06-23T10:39:42+02:00
-
04d96784
by Matthew Pickering at 2026-06-23T10:40:39+02:00
8 changed files:
- compiler/GHC/Driver/Backend.hs
- compiler/GHC/Driver/CodeOutput.hs
- compiler/GHC/Driver/Main/Compile.hs
- compiler/GHC/Driver/Pipeline.hs
- testsuite/tests/ghci/scripts/all.T
- + testsuite/tests/ghci/scripts/bytecodeIPE.hs
- + testsuite/tests/ghci/scripts/bytecodeIPE.script
- + testsuite/tests/ghci/scripts/bytecodeIPE.stdout
Changes:
| ... | ... | @@ -117,7 +117,6 @@ import GHC.Driver.Phases |
| 117 | 117 | |
| 118 | 118 | |
| 119 | 119 | import GHC.Utils.Error
|
| 120 | -import GHC.Utils.Panic
|
|
| 121 | 120 | |
| 122 | 121 | import GHC.Driver.Pipeline.Monad
|
| 123 | 122 | import GHC.Platform
|
| ... | ... | @@ -374,6 +373,7 @@ data DefunctionalizedCodeOutput |
| 374 | 373 | | ViaCCodeOutput
|
| 375 | 374 | | LlvmCodeOutput
|
| 376 | 375 | | JSCodeOutput
|
| 376 | + | NoCodeOutput
|
|
| 377 | 377 | |
| 378 | 378 | |
| 379 | 379 | -- | Names a function that tells the driver what should happen after
|
| ... | ... | @@ -773,8 +773,8 @@ backendCodeOutput (Named NCG) = NcgCodeOutput |
| 773 | 773 | backendCodeOutput (Named LLVM) = LlvmCodeOutput
|
| 774 | 774 | backendCodeOutput (Named ViaC) = ViaCCodeOutput
|
| 775 | 775 | backendCodeOutput (Named JavaScript) = JSCodeOutput
|
| 776 | -backendCodeOutput (Named Bytecode) = panic "backendCodeOutput: bytecodeBackend"
|
|
| 777 | -backendCodeOutput (Named NoBackend) = panic "backendCodeOutput: noBackend"
|
|
| 776 | +backendCodeOutput (Named Bytecode) = NoCodeOutput
|
|
| 777 | +backendCodeOutput (Named NoBackend) = NoCodeOutput
|
|
| 778 | 778 | |
| 779 | 779 | backendUseJSLinker :: Backend -> Bool
|
| 780 | 780 | backendUseJSLinker (Named NCG) = False
|
| ... | ... | @@ -63,6 +63,7 @@ import GHC.Types.Unique.Supply ( UniqueTag(..) ) |
| 63 | 63 | import System.IO
|
| 64 | 64 | import Data.Set (Set)
|
| 65 | 65 | import qualified Data.Set as Set
|
| 66 | +import GHC.Plugins (panic)
|
|
| 66 | 67 | |
| 67 | 68 | {-
|
| 68 | 69 | ************************************************************************
|
| ... | ... | @@ -129,6 +130,7 @@ codeOutput logger tmpfs llvm_config dflags unit_state this_mod filenm location g |
| 129 | 130 | ViaCCodeOutput -> outputC logger dflags filenm dus1 final_stream pkg_deps
|
| 130 | 131 | LlvmCodeOutput -> outputLlvm logger llvm_config dflags filenm dus1 final_stream
|
| 131 | 132 | JSCodeOutput -> outputJS logger llvm_config dflags filenm final_stream
|
| 133 | + NoCodeOutput -> panic "codeOutput: expected code output backend but got NoCodeOutput"
|
|
| 132 | 134 | ; stubs_exist <- outputForeignStubs logger tmpfs dflags unit_state this_mod location stubs
|
| 133 | 135 | ; return (filenm, stubs_exist, foreign_fps, a)
|
| 134 | 136 | }
|
| ... | ... | @@ -670,6 +670,8 @@ hscGenHardCode hsc_env cgguts mod_loc output_filename = do |
| 670 | 670 | -- next withTiming after this will be "Assembler" (hard code only).
|
| 671 | 671 | withTiming logger (text "CodeGen"<+>brackets (ppr this_mod)) (const ())
|
| 672 | 672 | $ case backendCodeOutput (backend dflags) of
|
| 673 | + NoCodeOutput ->
|
|
| 674 | + panic "hscGenHardCode: expected code output backend but got NoCodeOutput"
|
|
| 673 | 675 | JSCodeOutput ->
|
| 674 | 676 | do
|
| 675 | 677 | let js_config = initStgToJSConfig dflags
|
| ... | ... | @@ -743,6 +743,8 @@ compileEmptyStub dflags hsc_env basename location mod_name = do |
| 743 | 743 | let home_unit = hsc_home_unit hsc_env
|
| 744 | 744 | |
| 745 | 745 | case backendCodeOutput (backend dflags) of
|
| 746 | + NoCodeOutput ->
|
|
| 747 | + panic "compileEmptyStub: expected code output backend but got NoCodeOutput"
|
|
| 746 | 748 | JSCodeOutput -> do
|
| 747 | 749 | empty_stub <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule "js"
|
| 748 | 750 | let src = ppr (mkHomeModule home_unit mod_name) <+> text "= 0;"
|
| ... | ... | @@ -385,6 +385,14 @@ test('ListTuplePunsPpr', normal, ghci_script, ['ListTuplePunsPpr.script']) |
| 385 | 385 | test('ListTuplePunsPprNoAbbrevTuple', [limit_stdout_lines(14)], ghci_script, ['ListTuplePunsPprNoAbbrevTuple.script'])
|
| 386 | 386 | test('T24459', normal, ghci_script, ['T24459.script'])
|
| 387 | 387 | test('T24632', normal, ghci_script, ['T24632.script'])
|
| 388 | +# bytecode backend doesn't support '-finfo-table-map' (#27039)
|
|
| 389 | +test('bytecodeIPE',
|
|
| 390 | + [ extra_hc_opts('-finfo-table-map')
|
|
| 391 | + , extra_files(['bytecodeIPE.hs'])
|
|
| 392 | + , req_rts_linker
|
|
| 393 | + , when(arch('wasm32') or arch('javascript'), skip)
|
|
| 394 | + ],
|
|
| 395 | + ghci_script, ['bytecodeIPE.script'])
|
|
| 388 | 396 | |
| 389 | 397 | # Test package renaming in GHCi session
|
| 390 | 398 | test('GhciPackageRename',
|
| 1 | +module BytecodeIPE where
|
|
| 2 | + |
|
| 3 | +import Data.Maybe (isJust)
|
|
| 4 | +import GHC.InfoProv (whereFrom)
|
|
| 5 | + |
|
| 6 | +marker :: String
|
|
| 7 | +marker = id "bytecode-stub-init"
|
|
| 8 | +{-# NOINLINE marker #-}
|
|
| 9 | + |
|
| 10 | +-- `whereFrom` only succeeds if the module's IPE initializer ran.
|
|
| 11 | +probe :: IO Bool
|
|
| 12 | +probe = isJust <$> whereFrom marker |
| 1 | +:load bytecodeIPE.hs
|
|
| 2 | +probe |
| 1 | +False |