Skip to content

Commit

Permalink
Some fixes for 9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
wz1000 committed Nov 22, 2023
1 parent fb934ab commit 2cdb033
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
15 changes: 13 additions & 2 deletions ghcide/session-loader/Development/IDE/Session.hs
Original file line number Diff line number Diff line change
Expand Up @@ -729,8 +729,17 @@ emptyHscEnv :: IORef NameCache -> FilePath -> IO HscEnv
#endif
emptyHscEnv nc libDir = do
-- We call setSessionDynFlags so that the loader is initialised
env <- runGhc (Just libDir) $ getSessionDynFlags >>= setSessionDynFlags >> getSession
-- We need to do this before we call initUnits.
env <- runGhc (Just libDir) $
getSessionDynFlags >>= setSessionDynFlags >> getSession
-- On GHC 9.2 calling setSessionDynFlags caches the unit databases
-- for an empty environment. This prevents us from reading the
-- package database subsequently. So clear the unit db cache in
-- hsc_unit_dbs
pure $ setNameCache nc (hscSetFlags ((hsc_dflags env){useUnicode = True }) env)
#if !MIN_VERSION_ghc(9,3,0)
{hsc_unit_dbs = Nothing}
#endif

data TargetDetails = TargetDetails
{
Expand Down Expand Up @@ -832,6 +841,8 @@ newComponentCache recorder exts cradlePath _cfp hsc_env old_cis new_cis = do
-- some code. If the binary is dynamically linked, then this will have
-- no effect.
-- See https://github.com/haskell/haskell-language-server/issues/221
-- We need to do this after the call to setSessionDynFlags initialises
-- the loader
when (os == "linux") $ do
initObjLinker hscEnv'
res <- loadDLL hscEnv' "libm.so.6"
Expand All @@ -856,7 +867,7 @@ newComponentCache recorder exts cradlePath _cfp hsc_env old_cis new_cis = do
-- which we need for any changes to the package flags in the dynflags
-- to be visible.
-- See #2693
evalGhcEnv hsc_env $ do
evalGhcEnv hscEnv' $ do
_ <- setSessionDynFlags df
getSession
#endif
Expand Down
3 changes: 3 additions & 0 deletions ghcide/src/Development/IDE/GHC/Compat/Env.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ module Development.IDE.GHC.Compat.Env (
Env.hsc_logger,
Env.hsc_tmpfs,
Env.hsc_unit_env,
#if !MIN_VERSION_ghc(9,3,0)
Env.hsc_unit_dbs,
#endif
Env.hsc_hooks,
hscSetHooks,
TmpFs,
Expand Down

0 comments on commit 2cdb033

Please sign in to comment.