Skip to content

Commit 4065ac8

Browse files
committed
setSessionDynamicFlags to prevent ghc9 from crashing
The only way to set the dynamic linker is with the function `setSessionDynFlags` so we call it with the result from `getSessionDynFlags` to give it a (hopefully sensible) argument. See also this commit: https://gitlab.haskell.org/ghc/ghc/commit/18757cab04c5c5c48eaceea19469d4811c5d0371
1 parent 79f5fee commit 4065ac8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,12 +525,15 @@ cradleToOptsAndLibDir cradle file = do
525525

526526
emptyHscEnv :: IORef NameCache -> FilePath -> IO HscEnv
527527
emptyHscEnv nc libDir = do
528+
#if MIN_VERSION_ghc(9,0,0)
529+
-- Without the seemingly redundant `getSessionDynFlags >>= setSessionDynFlags`
530+
-- the line `initDynLinker env` would crash with the errror:
531+
-- `Couldn't find a target code interpreter. Try with -fexternal-interpreter`
532+
env <- runGhc (Just libDir) $ getSessionDynFlags >>= setSessionDynFlags >> getSession
533+
#else
528534
env <- runGhc (Just libDir) getSession
529-
#if !MIN_VERSION_ghc(9,0,0)
530-
-- This causes ghc9 to crash with the error:
531-
-- Couldn't find a target code interpreter. Try with -fexternal-interpreter
532-
initDynLinker env
533535
#endif
536+
initDynLinker env
534537
pure $ setNameCache nc env{ hsc_dflags = (hsc_dflags env){useUnicode = True } }
535538

536539
data TargetDetails = TargetDetails

0 commit comments

Comments
 (0)