Skip to content

Commit 6c99563

Browse files
committed
9.4 support + MHU
1 parent fdbc555 commit 6c99563

File tree

70 files changed

+1372
-248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1372
-248
lines changed

.github/actions/setup-build/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ inputs:
77
cabal:
88
description: "Cabal version"
99
required: false
10-
default: "3.6"
10+
default: "3.8.1.0"
1111
os:
1212
description: "Operating system: Linux, Windows or macOS"
1313
required: true

.github/workflows/test.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ jobs:
5757
strategy:
5858
fail-fast: true
5959
matrix:
60-
ghc: [ "9.2.4"
60+
ghc: [ "9.4.2"
61+
, "9.4.1"
62+
, "9.2.4"
6163
, "9.2.3"
6264
, "9.0.2"
6365
, "8.10.7"
@@ -69,6 +71,9 @@ jobs:
6971
]
7072
include:
7173
# only test supported ghc major versions
74+
- os: ubuntu-latest
75+
ghc: '9.4.2'
76+
test: true
7277
- os: ubuntu-latest
7378
ghc: '9.2.4'
7479
test: true
@@ -84,6 +89,9 @@ jobs:
8489
- os: ubuntu-latest
8590
ghc: '8.6.5'
8691
test: true
92+
- os: windows-latest
93+
ghc: '9.4.2'
94+
test: true
8795
- os: windows-latest
8896
ghc: '9.2.4'
8997
test: true

.gitlab-ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ variables:
99
# Commit of ghc/ci-images repository from which to pull Docker images
1010
DOCKER_REV: "4ed1a4f27828ba96a34662dc954335e29b470cd2"
1111

12-
CABAL_INSTALL_VERSION: 3.6.2.0
12+
CABAL_INSTALL_VERSION: 3.8.1.0
1313

1414
.windows_matrix: &windows_matrix
1515
matrix:
@@ -21,6 +21,10 @@ variables:
2121
CABAL_PROJECT: cabal.project
2222
- GHC_VERSION: 9.2.4
2323
CABAL_PROJECT: cabal.project
24+
- GHC_VERSION: 9.4.1
25+
CABAL_PROJECT: cabal.project
26+
- GHC_VERSION: 9.4.2
27+
CABAL_PROJECT: cabal.project
2428

2529
workflow:
2630
rules:

bindist/ghcs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
9.0.2,cabal.project
55
9.2.3,cabal.project
66
9.2.4,cabal.project
7+
9.4.1,cabal.project
8+
9.4.2,cabal.project

bindist/ghcs-Msys

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
9.0.2,cabal.project
33
9.2.3,cabal.project
44
9.2.4,cabal.project
5+
9.4.1,cabal.project
6+
9.4.2,cabal.project

cabal.project

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ source-repository-package
6767
tag: 7a0af7a8fd38045fd15fb13445bdcc7085325460
6868
-- https://github.com/tibbe/ekg-json/pull/12
6969

70+
source-repository-package
71+
type:git
72+
location: https://github.com/wz1000/hiedb
73+
tag: 67b92df2359558091df9102db5b701327308b930
74+
75+
source-repository-package
76+
type:git
77+
location: https://github.com/wz1000/hie-bios
78+
tag: aa73d3d2eb89df0003d2468a105e326d71b62cc7
79+
7080
-- Needed for ghcide-bench until a new release of lsp-test is out
7181
source-repository-package
7282
type:git
@@ -76,6 +86,9 @@ source-repository-package
7686
-- https://github.com/haskell/lsp/pull/450
7787

7888
allow-newer:
89+
base, ghc-prim, ghc-bignum, ghc, Cabal, binary, bytestring, unix, time, template-haskell,
90+
ghc-paths:Cabal,
91+
7992
-- ghc-9.2
8093
----------
8194
hiedb:base,

ghcide/ghcide.cabal

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ test-suite ghcide-tests
350350
--------------------------------------------------------------
351351
ghcide,
352352
ghcide-test-utils-internal,
353-
ghc-typelits-knownnat,
354353
lsp,
355354
lsp-types,
356355
hls-plugin-api,
@@ -378,6 +377,8 @@ test-suite ghcide-tests
378377
build-depends:
379378
record-dot-preprocessor,
380379
record-hasfield
380+
if impl(ghc < 9.3)
381+
build-depends: ghc-typelits-knownnat
381382
hs-source-dirs: test/cabal test/exe bench/lib
382383
ghc-options: -threaded -Wall -Wno-name-shadowing -O0 -Wno-unticked-promoted-constructors
383384
main-is: Main.hs

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

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{-# LANGUAGE ExistentialQuantification #-}
22
{-# LANGUAGE RankNTypes #-}
33
{-# LANGUAGE TypeFamilies #-}
4+
{-# LANGUAGE CPP #-}
45

56
{-|
67
The logic for setting up a ghcide session by tapping into hie-bios.
@@ -100,6 +101,9 @@ import HieDb.Types
100101
import HieDb.Utils
101102
import qualified System.Random as Random
102103
import System.Random (RandomGen)
104+
import Control.Monad.IO.Unlift (MonadUnliftIO)
105+
import Control.Exception (evaluate)
106+
import Control.DeepSeq
103107

104108
data Log
105109
= LogSettingInitialDynFlags
@@ -208,11 +212,13 @@ data SessionLoadingOptions = SessionLoadingOptions
208212
, getCacheDirs :: String -> [String] -> IO CacheDirs
209213
-- | Return the GHC lib dir to use for the 'unsafeGlobalDynFlags'
210214
, getInitialGhcLibDir :: Recorder (WithPriority Log) -> FilePath -> IO (Maybe LibDir)
215+
#if !MIN_VERSION_ghc(9,3,0)
211216
, fakeUid :: UnitId
212217
-- ^ unit id used to tag the internal component built by ghcide
213218
-- To reuse external interface files the unit ids must match,
214219
-- thus make sure to build them with `--this-unit-id` set to the
215220
-- same value as the ghcide fake uid
221+
#endif
216222
}
217223

218224
instance Default SessionLoadingOptions where
@@ -221,7 +227,9 @@ instance Default SessionLoadingOptions where
221227
,loadCradle = loadWithImplicitCradle
222228
,getCacheDirs = getCacheDirsDefault
223229
,getInitialGhcLibDir = getInitialGhcLibDirDefault
230+
#if !MIN_VERSION_ghc(9,3,0)
224231
,fakeUid = Compat.toUnitId (Compat.stringToUnit "main")
232+
#endif
225233
}
226234

227235
-- | Find the cradle for a given 'hie.yaml' configuration.
@@ -494,7 +502,11 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} dir = do
494502
new_deps' <- forM new_deps $ \RawComponentInfo{..} -> do
495503
-- Remove all inplace dependencies from package flags for
496504
-- components in this HscEnv
505+
#if MIN_VERSION_ghc(9,3,0)
506+
let (df2, uids) = (rawComponentDynFlags, [])
507+
#else
497508
let (df2, uids) = removeInplacePackages fakeUid inplace rawComponentDynFlags
509+
#endif
498510
let prefix = show rawComponentUnitId
499511
-- See Note [Avoiding bad interface files]
500512
let hscComponents = sort $ map show uids
@@ -517,10 +529,14 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} dir = do
517529
-- that I do not fully understand
518530
log Info $ LogMakingNewHscEnv inplace
519531
hscEnv <- emptyHscEnv ideNc libDir
520-
newHscEnv <-
532+
!newHscEnv <-
521533
-- Add the options for the current component to the HscEnv
522534
evalGhcEnv hscEnv $ do
523-
_ <- setSessionDynFlags $ setHomeUnitId_ fakeUid df
535+
_ <- setSessionDynFlags
536+
#if !MIN_VERSION_ghc(9,3,0)
537+
$ setHomeUnitId_ fakeUid
538+
#endif
539+
df
524540
getSession
525541

526542
-- Modify the map so the hieYaml now maps to the newly created
@@ -718,7 +734,11 @@ cradleToOptsAndLibDir recorder cradle file = do
718734
logWith recorder Info $ LogNoneCradleFound file
719735
return (Left [])
720736

737+
#if MIN_VERSION_ghc(9,3,0)
738+
emptyHscEnv :: NameCache -> FilePath -> IO HscEnv
739+
#else
721740
emptyHscEnv :: IORef NameCache -> FilePath -> IO HscEnv
741+
#endif
722742
emptyHscEnv nc libDir = do
723743
env <- runGhc (Just libDir) getSession
724744
initDynLinker env
@@ -757,7 +777,11 @@ toFlagsMap TargetDetails{..} =
757777
[ (l, (targetEnv, targetDepends)) | l <- targetLocations]
758778

759779

780+
#if MIN_VERSION_ghc(9,3,0)
781+
setNameCache :: NameCache -> HscEnv -> HscEnv
782+
#else
760783
setNameCache :: IORef NameCache -> HscEnv -> HscEnv
784+
#endif
761785
setNameCache nc hsc = hsc { hsc_NC = nc }
762786

763787
-- | Create a mapping from FilePaths to HscEnvEqs
@@ -773,6 +797,11 @@ newComponentCache
773797
newComponentCache recorder exts cradlePath cfp hsc_env uids ci = do
774798
let df = componentDynFlags ci
775799
hscEnv' <-
800+
#if MIN_VERSION_ghc(9,3,0)
801+
-- Set up a multi component session with the other units on GHC 9.4
802+
Compat.initUnits (map snd uids) (hscSetFlags df hsc_env)
803+
#elif MIN_VERSION_ghc(9,2,0)
804+
-- This initializes the units for GHC 9.2
776805
-- Add the options for the current component to the HscEnv
777806
-- We want to call `setSessionDynFlags` instead of `hscSetFlags`
778807
-- because `setSessionDynFlags` also initializes the package database,
@@ -782,14 +811,18 @@ newComponentCache recorder exts cradlePath cfp hsc_env uids ci = do
782811
evalGhcEnv hsc_env $ do
783812
_ <- setSessionDynFlags $ df
784813
getSession
785-
814+
#else
815+
-- getOptions is enough to initialize units on GHC <9.2
816+
pure $ hscSetFlags df hsc_env { hsc_IC = (hsc_IC hsc_env) { ic_dflags = df } }
817+
#endif
786818

787819
let newFunc = maybe newHscEnvEqPreserveImportPaths newHscEnvEq cradlePath
788820
henv <- newFunc hscEnv' uids
789821
let targetEnv = ([], Just henv)
790822
targetDepends = componentDependencyInfo ci
791823
res = (targetEnv, targetDepends)
792824
logWith recorder Debug $ LogNewComponentCache res
825+
evaluate $ liftRnf rwhnf $ componentTargets ci
793826

794827
let mk t = fromTargetId (importPaths df) exts (targetId t) targetEnv targetDepends
795828
ctargets <- concatMapM mk (componentTargets ci)
@@ -998,9 +1031,11 @@ setOptions (ComponentOptions theOpts compRoot _) dflags = do
9981031
-- initPackages parses the -package flags and
9991032
-- sets up the visibility for each component.
10001033
-- Throws if a -package flag cannot be satisfied.
1001-
env <- hscSetFlags dflags'' <$> getSession
1002-
final_env' <- liftIO $ wrapPackageSetupException $ Compat.initUnits env
1003-
return (hsc_dflags final_env', targets)
1034+
-- This only works for GHC <9.2
1035+
-- For GHC >= 9.2, we need to modify the unit env in the hsc_dflags, which
1036+
-- is done later in newComponentCache
1037+
final_flags <- liftIO $ wrapPackageSetupException $ Compat.oldInitUnits dflags''
1038+
return (final_flags, targets)
10041039

10051040
setIgnoreInterfacePragmas :: DynFlags -> DynFlags
10061041
setIgnoreInterfacePragmas df =

0 commit comments

Comments
 (0)