Skip to content

Commit 2cdb033

Browse files
committed
Some fixes for 9.2
1 parent fb934ab commit 2cdb033

File tree

2 files changed

+16
-2
lines changed
  • ghcide

2 files changed

+16
-2
lines changed

ghcide/session-loader/Development/IDE/Session.hs

+13-2
Original file line numberDiff line numberDiff line change
@@ -729,8 +729,17 @@ emptyHscEnv :: IORef NameCache -> FilePath -> IO HscEnv
729729
#endif
730730
emptyHscEnv nc libDir = do
731731
-- We call setSessionDynFlags so that the loader is initialised
732-
env <- runGhc (Just libDir) $ getSessionDynFlags >>= setSessionDynFlags >> getSession
732+
-- We need to do this before we call initUnits.
733+
env <- runGhc (Just libDir) $
734+
getSessionDynFlags >>= setSessionDynFlags >> getSession
735+
-- On GHC 9.2 calling setSessionDynFlags caches the unit databases
736+
-- for an empty environment. This prevents us from reading the
737+
-- package database subsequently. So clear the unit db cache in
738+
-- hsc_unit_dbs
733739
pure $ setNameCache nc (hscSetFlags ((hsc_dflags env){useUnicode = True }) env)
740+
#if !MIN_VERSION_ghc(9,3,0)
741+
{hsc_unit_dbs = Nothing}
742+
#endif
734743

735744
data TargetDetails = TargetDetails
736745
{
@@ -832,6 +841,8 @@ newComponentCache recorder exts cradlePath _cfp hsc_env old_cis new_cis = do
832841
-- some code. If the binary is dynamically linked, then this will have
833842
-- no effect.
834843
-- See https://github.com/haskell/haskell-language-server/issues/221
844+
-- We need to do this after the call to setSessionDynFlags initialises
845+
-- the loader
835846
when (os == "linux") $ do
836847
initObjLinker hscEnv'
837848
res <- loadDLL hscEnv' "libm.so.6"
@@ -856,7 +867,7 @@ newComponentCache recorder exts cradlePath _cfp hsc_env old_cis new_cis = do
856867
-- which we need for any changes to the package flags in the dynflags
857868
-- to be visible.
858869
-- See #2693
859-
evalGhcEnv hsc_env $ do
870+
evalGhcEnv hscEnv' $ do
860871
_ <- setSessionDynFlags df
861872
getSession
862873
#endif

ghcide/src/Development/IDE/GHC/Compat/Env.hs

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ module Development.IDE.GHC.Compat.Env (
1919
Env.hsc_logger,
2020
Env.hsc_tmpfs,
2121
Env.hsc_unit_env,
22+
#if !MIN_VERSION_ghc(9,3,0)
23+
Env.hsc_unit_dbs,
24+
#endif
2225
Env.hsc_hooks,
2326
hscSetHooks,
2427
TmpFs,

0 commit comments

Comments
 (0)