diff --git a/ghcide/session-loader/Development/IDE/Session.hs b/ghcide/session-loader/Development/IDE/Session.hs index cbf6655bda..431d6d4714 100644 --- a/ghcide/session-loader/Development/IDE/Session.hs +++ b/ghcide/session-loader/Development/IDE/Session.hs @@ -525,12 +525,15 @@ cradleToOptsAndLibDir cradle file = do emptyHscEnv :: IORef NameCache -> FilePath -> IO HscEnv emptyHscEnv nc libDir = do +#if MIN_VERSION_ghc(9,0,0) + -- Without the seemingly redundant `getSessionDynFlags >>= setSessionDynFlags` + -- the line `initDynLinker env` would crash with the errror: + -- `Couldn't find a target code interpreter. Try with -fexternal-interpreter` + env <- runGhc (Just libDir) $ getSessionDynFlags >>= setSessionDynFlags >> getSession +#else env <- runGhc (Just libDir) getSession -#if !MIN_VERSION_ghc(9,0,0) - -- This causes ghc9 to crash with the error: - -- Couldn't find a target code interpreter. Try with -fexternal-interpreter - initDynLinker env #endif + initDynLinker env pure $ setNameCache nc env{ hsc_dflags = (hsc_dflags env){useUnicode = True } } data TargetDetails = TargetDetails