Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • changelog.d/unit-index
    1 1
     section: compiler
    
    2 2
     synopsis: Use global ``UnitIndex`` to deduplicate ``UnitInfo``s over multiple home units
    
    3
    -issues: #27500 #26423
    
    4
    -mrs: !16115
    
    3
    +issues: #27500 #26423 #27748
    
    4
    +mrs: !16115 !16598
    
    5 5
     
    
    6 6
     description: {
    
    7 7
         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
    145 145
       checkUnitCycles initial_dflags home_unit_graph
    
    146 146
     
    
    147 147
       let dflags = homeUnitEnv_dflags $ HUG.unitEnv_lookup mainUnitId home_unit_graph
    
    148
    -  unitEnv <- assertUnitEnvInvariant <$> (liftIO $ initUnitEnv mainUnitId home_unit_graph (ghcNameVersion dflags) (targetPlatform dflags))
    
    149
    -  let final_hsc_env = hsc_env { hsc_unit_env = unitEnv }
    
    148
    +  newUnitEnv <-  do
    
    149
    +    env <- liftIO $ initUnitEnv mainUnitId home_unit_graph (ghcNameVersion dflags) (targetPlatform dflags)
    
    150
    +    -- We need to reuse the 'UnitIndexCache' as we used it above in 'initUnits'.
    
    151
    +    -- See Note [Sharing 'UnitInfo's across the 'UnitEnv'] why this must be shared.
    
    152
    +    pure $ assertUnitEnvInvariant $ env
    
    153
    +      { ue_uic = hscUIC hsc_env
    
    154
    +      }
    
    155
    +
    
    156
    +  let final_hsc_env = hsc_env { hsc_unit_env = newUnitEnv }
    
    150 157
     
    
    151 158
       GHC.setSession final_hsc_env
    
    152 159