Hannes Siebenhandl pushed to branch wip/fendor/no-code-output-constr at Glasgow Haskell Compiler / GHC Commits: 046418ca by fendor at 2026-06-24T16:16:50+02:00 Add 'backendSupportsInfoTableMap' backend predicate Check whether the backend supports the `-finfo-table-map` flag and ignore it otherwise. - - - - - 61d935d3 by Matthew Pickering at 2026-06-24T16:16:50+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 - - - - - 7 changed files: - compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Session.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 ===================================== @@ -99,6 +99,7 @@ module GHC.Driver.Backend , backendPostHscPipeline , backendNormalSuccessorPhase , backendName + , backendSupportsInfoTableMap , backendValidityOfCImport , backendValidityOfCExport @@ -680,6 +681,16 @@ backendSupportsBreakpoints = \case Named Bytecode -> True Named NoBackend -> False +-- | If this flag is unset, then the driver ignores the flag @-finfo-table-map@, +-- since the backend doesn't support generating the info table map. +backendSupportsInfoTableMap :: Backend -> Bool +backendSupportsInfoTableMap (Named NCG) = True +backendSupportsInfoTableMap (Named LLVM) = False +backendSupportsInfoTableMap (Named ViaC) = True +backendSupportsInfoTableMap (Named JavaScript) = False +backendSupportsInfoTableMap (Named Bytecode) = False +backendSupportsInfoTableMap (Named NoBackend) = True -- We are not generating code, so we ignore it any way + -- | If this flag is set, then the driver forces the -- optimization level to 0, issuing a warning message if -- the command line requested a higher optimization level. ===================================== 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) {- ************************************************************************ ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3903,9 +3903,9 @@ makeDynFlagsConsistent dflags in dflags_c | gopt Opt_InfoTableMap dflags - , LlvmCodeOutput <- backendCodeOutput (backend dflags) + , backendSupportsInfoTableMap (backend dflags) = loop (gopt_unset dflags Opt_InfoTableMap) - "-finfo-table-map is incompatible with -fllvm and is disabled (See #26435)" + $ "-finfo-table-map is incompatible with " ++ show (backend dflags) ++ " and is disabled (See #26435)" | otherwise = (dflags, mempty, mempty) where loc = mkGeneralSrcSpan (fsLit "when making flags consistent") ===================================== 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/fe056b958602665057dc101c57627b1... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fe056b958602665057dc101c57627b1... You're receiving this email because of your account on gitlab.haskell.org.