Wolfgang Jeltsch pushed to branch wip/jeltsch/smaller-pit at Glasgow Haskell Compiler / GHC Commits: ec432d89 by Wolfgang Jeltsch at 2026-10-01T23:26:12+03:00 Make Haddock avoid the PIT - - - - - 1 changed file: - utils/haddock/haddock-api/src/Haddock/Interface.hs Changes: ===================================== utils/haddock/haddock-api/src/Haddock/Interface.hs ===================================== @@ -63,7 +63,7 @@ import GHC.Driver.Session hiding (verbosity) import GHC.Driver.Phases import GHC.Driver.Pipeline (compileFile) import GHC.HsToCore.Docs (getMainDeclBinder) -import GHC.Iface.Load (loadSysInterface) +import GHC.Iface.Load (findAndReadIface) import GHC.IfaceToCore (tcIfaceInst, tcIfaceFamInst) import GHC.Tc.Utils.Monad (initIfaceLoad, initIfaceLcl) import GHC.Tc.Utils.Env (lookupGlobal_maybe) @@ -72,6 +72,7 @@ import GHC.Types.Name.Occurrence (emptyOccEnv) import GHC.Unit.Finder (findImportedModule, ModuleLookupScope(..), FindResult(Found)) import GHC.Unit.Home.ModInfo import GHC.Unit.Home.PackageTable +import GHC.Unit.Module (getModuleInstantiation) import GHC.Unit.Module.Graph (ModuleGraphNode (..), ModuleNodeInfo(..)) import GHC.Unit.Module.ModDetails import GHC.Unit.Module.ModIface (RetainedModIface, shrinkModIface, mi_semantic_module, mi_boot) @@ -254,19 +255,20 @@ dropErr :: MaybeErr e a -> Maybe a dropErr (Succeeded a) = Just a dropErr (Failed _) = Nothing -loadHiFile :: HscEnv -> Outputable.SDoc -> Module -> IO (RetainedModIface, ([ClsInst], [FamInst])) -loadHiFile hsc_env doc theModule = initIfaceLoad hsc_env $ do - - mod_iface <- loadSysInterface doc theModule - - insts <- initIfaceLcl (mi_semantic_module mod_iface) doc (mi_boot mod_iface) $ do - - new_eps_insts <- mapM tcIfaceInst (mi_insts mod_iface) - new_eps_fam_insts <- mapM tcIfaceFamInst (mi_fam_insts mod_iface) - - pure (new_eps_insts, new_eps_fam_insts) - - pure (mod_iface, insts) +loadHiFile :: Verbosity -> HscEnv -> Outputable.SDoc -> Module -> IO (RetainedModIface, ([ClsInst], [FamInst])) +loadHiFile verbosity hsc_env doc requested = initIfaceLoad hsc_env $ do + let installed = fst (getModuleInstantiation requested) + iface_fetch_result <- liftIO $ findAndReadIface hsc_env doc installed requested NotBoot + case iface_fetch_result of + Failed _ -> do + out verbosity normal "Interface fetching failed" + liftIO exitFailure + Succeeded (mod_iface, _) -> do + insts <- initIfaceLcl (mi_semantic_module mod_iface) doc (mi_boot mod_iface) $ do + new_eps_insts <- mapM tcIfaceInst (mi_insts mod_iface) + new_eps_fam_insts <- mapM tcIfaceFamInst (mi_fam_insts mod_iface) + pure (new_eps_insts, new_eps_fam_insts) + pure (shrinkModIface mod_iface, insts) processModule :: Verbosity -> ModSummary -> [Flag] -> IfaceMap -> InstIfaceMap -> WarningMap -> Ghc (Maybe Interface) processModule verbosity modSummary flags ifaceMap instIfaceMap warningMap = do @@ -279,7 +281,7 @@ processModule verbosity modSummary flags ifaceMap instIfaceMap warningMap = do unit_state = hsc_units hsc_env (mod_iface, insts) <- if Flag_NoCompilation `elem` flags - then liftIO $ loadHiFile hsc_env doc $ ms_mod modSummary + then liftIO $ loadHiFile verbosity hsc_env doc $ ms_mod modSummary else do hmi <- liftIO $ lookupHpt (hsc_HPT hsc_env) (moduleName $ ms_mod modSummary) >>= \case Nothing -> error "processModule: All modules should be loaded into the HPT by this point" @@ -374,7 +376,7 @@ createOneShotIface verbosity flags instIfaceMap moduleNameStr = do modifySession $ hscSetFlags dflags hsc_env <- getSession - (iface, insts) <- liftIO $ loadHiFile hsc_env doc $ mkMainModule_ moduleNm + (iface, insts) <- liftIO $ loadHiFile verbosity hsc_env doc $ mkMainModule_ moduleNm -- Update the DynFlags with the extensions from the source file (as stored in the interface file) -- This is instead of ms_hspp_opts from ModSummary, which is not available in one-shot mode. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ec432d89b83147adbe7d6272952d62e8... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ec432d89b83147adbe7d6272952d62e8... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
participants (1)
-
Wolfgang Jeltsch (@jeltsch)