@@ -120,7 +120,6 @@ import Text.ParserCombinators.ReadP (readP_to_S)
120
120
121
121
-- See Note [Guidelines For Using CPP In GHCIDE Import Statements]
122
122
123
- #if MIN_VERSION_ghc(9,3,0)
124
123
import qualified Data.Set as OS
125
124
import qualified Development.IDE.GHC.Compat.Util as Compat
126
125
import GHC.Data.Graph.Directed
@@ -131,7 +130,6 @@ import GHC.Driver.Errors.Types
131
130
import GHC.Types.Error (errMsgDiagnostic ,
132
131
singleMessage )
133
132
import GHC.Unit.State
134
- #endif
135
133
136
134
data Log
137
135
= LogSettingInitialDynFlags
@@ -245,13 +243,6 @@ data SessionLoadingOptions = SessionLoadingOptions
245
243
, getCacheDirs :: String -> [String ] -> IO CacheDirs
246
244
-- | Return the GHC lib dir to use for the 'unsafeGlobalDynFlags'
247
245
, getInitialGhcLibDir :: Recorder (WithPriority Log ) -> FilePath -> IO (Maybe LibDir )
248
- # if ! MIN_VERSION_ghc (9 ,3 ,0 )
249
- , fakeUid :: UnitId
250
- -- ^ unit id used to tag the internal component built by ghcide
251
- -- To reuse external interface files the unit ids must match,
252
- -- thus make sure to build them with `--this-unit-id` set to the
253
- -- same value as the ghcide fake uid
254
- # endif
255
246
}
256
247
257
248
instance Default SessionLoadingOptions where
@@ -260,9 +251,6 @@ instance Default SessionLoadingOptions where
260
251
,loadCradle = loadWithImplicitCradle
261
252
,getCacheDirs = getCacheDirsDefault
262
253
,getInitialGhcLibDir = getInitialGhcLibDirDefault
263
- #if !MIN_VERSION_ghc(9,3,0)
264
- ,fakeUid = Compat. toUnitId (Compat. stringToUnit " main" )
265
- #endif
266
254
}
267
255
268
256
-- | Find the cradle for a given 'hie.yaml' configuration.
@@ -542,11 +530,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
542
530
all_deps' <- forM all_deps $ \ RawComponentInfo {.. } -> do
543
531
-- Remove all inplace dependencies from package flags for
544
532
-- components in this HscEnv
545
- #if MIN_VERSION_ghc(9,3,0)
546
533
let (df2, uids) = (rawComponentDynFlags, [] )
547
- #else
548
- let (df2, uids) = _removeInplacePackages fakeUid _inplace rawComponentDynFlags
549
- #endif
550
534
let prefix = show rawComponentUnitId
551
535
-- See Note [Avoiding bad interface files]
552
536
let hscComponents = sort $ map show uids
@@ -771,11 +755,7 @@ cradleToOptsAndLibDir recorder loadConfig cradle file old_fps = do
771
755
PreferSingleComponentLoading -> LoadFile
772
756
PreferMultiComponentLoading -> LoadWithContext old_fps
773
757
774
- #if MIN_VERSION_ghc(9,3,0)
775
758
emptyHscEnv :: NameCache -> FilePath -> IO HscEnv
776
- #else
777
- emptyHscEnv :: IORef NameCache -> FilePath -> IO HscEnv
778
- #endif
779
759
emptyHscEnv nc libDir = do
780
760
-- We call setSessionDynFlags so that the loader is initialised
781
761
-- We need to do this before we call initUnits.
@@ -786,9 +766,6 @@ emptyHscEnv nc libDir = do
786
766
-- package database subsequently. So clear the unit db cache in
787
767
-- hsc_unit_dbs
788
768
pure $ setNameCache nc (hscSetFlags ((hsc_dflags env){useUnicode = True }) env)
789
- #if !MIN_VERSION_ghc(9,3,0)
790
- {hsc_unit_dbs = Nothing }
791
- #endif
792
769
793
770
data TargetDetails = TargetDetails
794
771
{
@@ -826,14 +803,9 @@ toFlagsMap TargetDetails{..} =
826
803
[ (l, (targetEnv, targetDepends)) | l <- targetLocations]
827
804
828
805
829
- #if MIN_VERSION_ghc(9,3,0)
830
806
setNameCache :: NameCache -> HscEnv -> HscEnv
831
- #else
832
- setNameCache :: IORef NameCache -> HscEnv -> HscEnv
833
- #endif
834
807
setNameCache nc hsc = hsc { hsc_NC = nc }
835
808
836
- #if MIN_VERSION_ghc(9,3,0)
837
809
-- This function checks the important property that if both p and q are home units
838
810
-- then any dependency of p, which transitively depends on q is also a home unit.
839
811
-- GHC had an implementation of this function, but it was horribly inefficient
@@ -890,7 +862,6 @@ checkHomeUnitsClosed' ue home_id_set
890
862
Just depends ->
891
863
let todo'' = (depends OS. \\ done) `OS.union` todo'
892
864
in DigraphNode uid uid (OS. toList depends) : go (OS. insert uid done) todo''
893
- #endif
894
865
895
866
-- | Create a mapping from FilePaths to HscEnvEqs
896
867
-- This combines all the components we know about into
@@ -920,18 +891,13 @@ newComponentCache recorder exts cradlePath _cfp hsc_env old_cis new_cis dir = do
920
891
hscEnv' <- -- Set up a multi component session with the other units on GHC 9.4
921
892
Compat. initUnits dfs hsc_env
922
893
923
- #if MIN_VERSION_ghc(9,3,0)
924
894
let closure_errs = checkHomeUnitsClosed' (hsc_unit_env hscEnv') (hsc_all_home_unit_ids hscEnv')
925
895
multi_errs = map (ideErrorWithSource (Just " cradle" ) (Just DiagnosticSeverity_Warning ) _cfp . T. pack . Compat. printWithoutUniques) closure_errs
926
896
bad_units = OS. fromList $ concat $ do
927
897
x <- bagToList $ mapBag errMsgDiagnostic $ unionManyBags $ map Compat. getMessages closure_errs
928
898
DriverHomePackagesNotClosed us <- pure x
929
899
pure us
930
900
isBad ci = (homeUnitId_ (componentDynFlags ci)) `OS.member` bad_units
931
- #else
932
- let isBad = const False
933
- multi_errs = []
934
- #endif
935
901
-- Whenever we spin up a session on Linux, dynamically load libm.so.6
936
902
-- in. We need this in case the binary is statically linked, in which
937
903
-- case the interactive session will fail when trying to load
@@ -953,23 +919,10 @@ newComponentCache recorder exts cradlePath _cfp hsc_env old_cis new_cis dir = do
953
919
let df = componentDynFlags ci
954
920
let createHscEnvEq = maybe newHscEnvEqPreserveImportPaths (newHscEnvEq dir) cradlePath
955
921
thisEnv <- do
956
- #if MIN_VERSION_ghc(9,3,0)
957
922
-- In GHC 9.4 we have multi component support, and we have initialised all the units
958
923
-- above.
959
924
-- We just need to set the current unit here
960
925
pure $ hscSetActiveUnitId (homeUnitId_ df) hscEnv'
961
- #else
962
- -- This initializes the units for GHC 9.2
963
- -- Add the options for the current component to the HscEnv
964
- -- We want to call `setSessionDynFlags` instead of `hscSetFlags`
965
- -- because `setSessionDynFlags` also initializes the package database,
966
- -- which we need for any changes to the package flags in the dynflags
967
- -- to be visible.
968
- -- See #2693
969
- evalGhcEnv hscEnv' $ do
970
- _ <- setSessionDynFlags df
971
- getSession
972
- #endif
973
926
henv <- createHscEnvEq thisEnv (zip uids dfs)
974
927
let targetEnv = (if isBad ci then multi_errs else [] , Just henv)
975
928
targetDepends = componentDependencyInfo ci
@@ -1201,7 +1154,6 @@ setOptions cfp (ComponentOptions theOpts compRoot _) dflags rootDir = do
1201
1154
initOne this_opts = do
1202
1155
(dflags', targets') <- addCmdOpts this_opts dflags
1203
1156
let dflags'' =
1204
- #if MIN_VERSION_ghc(9,3,0)
1205
1157
case unitIdString (homeUnitId_ dflags') of
1206
1158
-- cabal uses main for the unit id of all executable packages
1207
1159
-- This makes multi-component sessions confused about what
@@ -1214,9 +1166,6 @@ setOptions cfp (ComponentOptions theOpts compRoot _) dflags rootDir = do
1214
1166
hashed_uid = Compat. toUnitId (Compat. stringToUnit (" main-" ++ hash))
1215
1167
in setHomeUnitId_ hashed_uid dflags'
1216
1168
_ -> dflags'
1217
- #else
1218
- dflags'
1219
- #endif
1220
1169
1221
1170
let targets = makeTargetsAbsolute root targets'
1222
1171
root = case workingDirectory dflags'' of
0 commit comments