[Git][ghc/ghc][wip/fendor/uic-reuse] Reuse the UnitIndexCache after initialising multiple home units
Hannes Siebenhandl pushed to branch wip/fendor/uic-reuse at Glasgow Haskell Compiler / GHC Commits: ec0faf75 by fendor at 2026-08-26T17:20:38+02:00 Reuse the UnitIndexCache after initialising multiple home units - - - - - 2 changed files: - changelog.d/unit-index - compiler/GHC/Driver/Session/Units.hs Changes: ===================================== changelog.d/unit-index ===================================== @@ -1,7 +1,7 @@ section: compiler synopsis: Use global ``UnitIndex`` to deduplicate ``UnitInfo``s over multiple home units -issues: #27500 #26423 -mrs: !16115 +issues: #27500 #26423 #27748 +mrs: !16115 !16598 description: { The ``UnitState`` used to be duplicated for all ``HomeUnitEnv``, not sharing any of the ``UnitInfo``s. ===================================== compiler/GHC/Driver/Session/Units.hs ===================================== @@ -145,8 +145,15 @@ initMulti unitArgsFiles lintDynFlagsAndSrcs = do checkUnitCycles initial_dflags home_unit_graph let dflags = homeUnitEnv_dflags $ HUG.unitEnv_lookup mainUnitId home_unit_graph - unitEnv <- assertUnitEnvInvariant <$> (liftIO $ initUnitEnv mainUnitId home_unit_graph (ghcNameVersion dflags) (targetPlatform dflags)) - let final_hsc_env = hsc_env { hsc_unit_env = unitEnv } + newUnitEnv <- do + env <- liftIO $ initUnitEnv mainUnitId home_unit_graph (ghcNameVersion dflags) (targetPlatform dflags) + -- We need to reuse the 'UnitIndexCache' as we used it above in 'initUnits'. + -- See Note [Sharing 'UnitInfo's across the 'UnitEnv'] why this must be shared. + pure $ assertUnitEnvInvariant $ env + { ue_uic = hscUIC hsc_env + } + + let final_hsc_env = hsc_env { hsc_unit_env = newUnitEnv } GHC.setSession final_hsc_env View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ec0faf753d2093f99f9f899de175097f... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ec0faf753d2093f99f9f899de175097f... 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)
-
Hannes Siebenhandl (@fendor)