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 Introduce 'NoCodeOutput' constructor to avoid partial `backendCodeOutput` This makes `backendCodeOutput` total, but forces us to explicitly handle the new `NoCodeOutput` case when using it. Thus, we add some new `panic`'s when generating files. The advantage is that `backendCodeOutput` can be used for checking capabilities without requiring a prior check via `backendWritesFiles`. - - - - - 04d96784 by Matthew Pickering at 2026-06-23T10:40:39+02:00 Add failing test for `-finfo-table-map` and bytecode backend If you compile a module using the bytecode backend, with -finfo-table-map, then the info table map doesn't get populated for the module. This is because the -finfo-table-map code path is implemented mostly in the StgToCmm phase which isn't run when creating bytecode. Ticket #27039 - - - - - 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: ===================================== compiler/GHC/Driver/Backend.hs ===================================== @@ -117,7 +117,6 @@ import GHC.Driver.Phases import GHC.Utils.Error -import GHC.Utils.Panic import GHC.Driver.Pipeline.Monad import GHC.Platform @@ -374,6 +373,7 @@ data DefunctionalizedCodeOutput | ViaCCodeOutput | LlvmCodeOutput | JSCodeOutput + | NoCodeOutput -- | Names a function that tells the driver what should happen after @@ -773,8 +773,8 @@ backendCodeOutput (Named NCG) = NcgCodeOutput backendCodeOutput (Named LLVM) = LlvmCodeOutput backendCodeOutput (Named ViaC) = ViaCCodeOutput backendCodeOutput (Named JavaScript) = JSCodeOutput -backendCodeOutput (Named Bytecode) = panic "backendCodeOutput: bytecodeBackend" -backendCodeOutput (Named NoBackend) = panic "backendCodeOutput: noBackend" +backendCodeOutput (Named Bytecode) = NoCodeOutput +backendCodeOutput (Named NoBackend) = NoCodeOutput backendUseJSLinker :: Backend -> Bool backendUseJSLinker (Named NCG) = False ===================================== compiler/GHC/Driver/CodeOutput.hs ===================================== @@ -63,6 +63,7 @@ import GHC.Types.Unique.Supply ( UniqueTag(..) ) import System.IO import Data.Set (Set) import qualified Data.Set as Set +import GHC.Plugins (panic) {- ************************************************************************ @@ -129,6 +130,7 @@ codeOutput logger tmpfs llvm_config dflags unit_state this_mod filenm location g ViaCCodeOutput -> outputC logger dflags filenm dus1 final_stream pkg_deps LlvmCodeOutput -> outputLlvm logger llvm_config dflags filenm dus1 final_stream JSCodeOutput -> outputJS logger llvm_config dflags filenm final_stream + NoCodeOutput -> panic "codeOutput: expected code output backend but got NoCodeOutput" ; stubs_exist <- outputForeignStubs logger tmpfs dflags unit_state this_mod location stubs ; return (filenm, stubs_exist, foreign_fps, a) } ===================================== compiler/GHC/Driver/Main/Compile.hs ===================================== @@ -670,6 +670,8 @@ hscGenHardCode hsc_env cgguts mod_loc output_filename = do -- next withTiming after this will be "Assembler" (hard code only). withTiming logger (text "CodeGen"<+>brackets (ppr this_mod)) (const ()) $ case backendCodeOutput (backend dflags) of + NoCodeOutput -> + panic "hscGenHardCode: expected code output backend but got NoCodeOutput" JSCodeOutput -> do let js_config = initStgToJSConfig dflags ===================================== compiler/GHC/Driver/Pipeline.hs ===================================== @@ -743,6 +743,8 @@ compileEmptyStub dflags hsc_env basename location mod_name = do let home_unit = hsc_home_unit hsc_env case backendCodeOutput (backend dflags) of + NoCodeOutput -> + panic "compileEmptyStub: expected code output backend but got NoCodeOutput" JSCodeOutput -> do empty_stub <- newTempName logger tmpfs (tmpDir dflags) TFL_CurrentModule "js" let src = ppr (mkHomeModule home_unit mod_name) <+> text "= 0;" ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -385,6 +385,14 @@ test('ListTuplePunsPpr', normal, ghci_script, ['ListTuplePunsPpr.script']) test('ListTuplePunsPprNoAbbrevTuple', [limit_stdout_lines(14)], ghci_script, ['ListTuplePunsPprNoAbbrevTuple.script']) test('T24459', normal, ghci_script, ['T24459.script']) test('T24632', normal, ghci_script, ['T24632.script']) +# bytecode backend doesn't support '-finfo-table-map' (#27039) +test('bytecodeIPE', + [ extra_hc_opts('-finfo-table-map') + , extra_files(['bytecodeIPE.hs']) + , req_rts_linker + , when(arch('wasm32') or arch('javascript'), skip) + ], + ghci_script, ['bytecodeIPE.script']) # Test package renaming in GHCi session test('GhciPackageRename', ===================================== testsuite/tests/ghci/scripts/bytecodeIPE.hs ===================================== @@ -0,0 +1,12 @@ +module BytecodeIPE where + +import Data.Maybe (isJust) +import GHC.InfoProv (whereFrom) + +marker :: String +marker = id "bytecode-stub-init" +{-# NOINLINE marker #-} + +-- `whereFrom` only succeeds if the module's IPE initializer ran. +probe :: IO Bool +probe = isJust <$> whereFrom marker ===================================== testsuite/tests/ghci/scripts/bytecodeIPE.script ===================================== @@ -0,0 +1,2 @@ +:load bytecodeIPE.hs +probe ===================================== testsuite/tests/ghci/scripts/bytecodeIPE.stdout ===================================== @@ -0,0 +1 @@ +False View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/332e590f0efc57c6d41bdabb25f1f6d... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/332e590f0efc57c6d41bdabb25f1f6d... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Hannes Siebenhandl (@fendor)