Skip to content

Commit 366ecb1

Browse files
committed
WIP: GHC 9.8 support
Requires head.hackage to build Will add tests to CI once 9.8 alpha 1 is released rebase ci: Test against 9.8-rc1 cabal.project fixes wip
1 parent c941dac commit 366ecb1

File tree

40 files changed

+261
-67
lines changed

40 files changed

+261
-67
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ runs:
3636
with:
3737
ghc-version : ${{ inputs.ghc }}
3838
cabal-version: ${{ inputs.cabal }}
39+
ghcup-release-channel: "https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml"
3940
enable-stack: false
4041

4142
- if: inputs.os == 'Windows'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[ "9.6", "9.4" , "9.2" , "9.0" ]
1+
[ "9.8.0.20230929", "9.6", "9.4" , "9.2" , "9.0" ]

.github/workflows/test.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@ jobs:
135135
HLS_WRAPPER_TEST_EXE: hls-wrapper
136136
run: cabal test wrapper-test --test-options="$TEST_OPTS --rerun-log-file .tasty-rerun-log-wrapper"
137137

138-
- if: matrix.test
138+
- if: matrix.test && matrix.ghc != '9.8'
139139
name: Test hls-refactor-plugin
140140
run: cabal test hls-refactor-plugin --test-options="$TEST_OPTS" || cabal test hls-refactor-plugin --test-options="$TEST_OPTS"
141141

142-
- if: matrix.test && matrix.ghc != '9.6'
142+
- if: matrix.test && matrix.ghc != '9.6' && matrix.ghc != '9.8'
143143
name: Test hls-floskell-plugin
144144
run: cabal test hls-floskell-plugin --test-options="$TEST_OPTS" || cabal test hls-floskell-plugin --test-options="$TEST_OPTS"
145145

146-
- if: matrix.test
146+
- if: matrix.test && matrix.ghc != '9.8'
147147
name: Test hls-class-plugin
148148
run: cabal test hls-class-plugin --test-options="$TEST_OPTS" || cabal test hls-class-plugin --test-options="$TEST_OPTS"
149149

@@ -155,19 +155,19 @@ jobs:
155155
name: Test hls-eval-plugin
156156
run: cabal test hls-eval-plugin --test-options="$TEST_OPTS" || cabal test hls-eval-plugin --test-options="$TEST_OPTS"
157157

158-
- if: matrix.test
158+
- if: matrix.test && matrix.ghc != '9.8'
159159
name: Test hls-splice-plugin
160160
run: cabal test hls-splice-plugin --test-options="$TEST_OPTS" || cabal test hls-splice-plugin --test-options="$TEST_OPTS"
161161

162-
- if: matrix.test
162+
- if: matrix.test && matrix.ghc != '9.8'
163163
name: Test hls-stylish-haskell-plugin
164164
run: cabal test hls-stylish-haskell-plugin --test-options="$TEST_OPTS" || cabal test hls-stylish-haskell-plugin --test-options="$TEST_OPTS"
165165

166-
- if: matrix.test
166+
- if: matrix.test && matrix.ghc != '9.8'
167167
name: Test hls-ormolu-plugin
168168
run: cabal test hls-ormolu-plugin --test-options="$TEST_OPTS" || cabal test hls-ormolu-plugin --test-options="$TEST_OPTS"
169169

170-
- if: matrix.test
170+
- if: matrix.test && matrix.ghc != '9.8'
171171
name: Test hls-fourmolu-plugin
172172
run: cabal test hls-fourmolu-plugin --test-options="$TEST_OPTS" || cabal test hls-fourmolu-plugin --test-options="$TEST_OPTS"
173173

@@ -179,11 +179,11 @@ jobs:
179179
name: Test hls-call-hierarchy-plugin test suite
180180
run: cabal test hls-call-hierarchy-plugin --test-options="$TEST_OPTS" || cabal test hls-call-hierarchy-plugin --test-options="$TEST_OPTS"
181181

182-
- if: matrix.test && matrix.os != 'windows-latest'
182+
- if: matrix.test && matrix.os != 'windows-latest' && matrix.ghc != '9.8'
183183
name: Test hls-rename-plugin test suite
184184
run: cabal test hls-rename-plugin --test-options="$TEST_OPTS" || cabal test hls-rename-plugin --test-options="$TEST_OPTS"
185185

186-
- if: matrix.test
186+
- if: matrix.test && matrix.ghc != '9.8'
187187
name: Test hls-hlint-plugin test suite
188188
run: cabal test hls-hlint-plugin --test-options="$TEST_OPTS" || cabal test hls-hlint-plugin --test-options="$TEST_OPTS"
189189

@@ -207,7 +207,7 @@ jobs:
207207
name: Test hls-change-type-signature test suite
208208
run: cabal test hls-change-type-signature-plugin --test-options="$TEST_OPTS" || cabal test hls-change-type-signature-plugin --test-options="$TEST_OPTS"
209209

210-
- if: matrix.test
210+
- if: matrix.test && matrix.ghc != '9.8'
211211
name: Test hls-gadt-plugin test suit
212212
run: cabal test hls-gadt-plugin --test-options="$TEST_OPTS" || cabal test hls-gadt-plugin --test-options="$TEST_OPTS"
213213

@@ -228,7 +228,7 @@ jobs:
228228
name: Test hls-cabal-plugin test suite
229229
run: cabal test hls-cabal-plugin --test-options="$TEST_OPTS" || cabal test hls-cabal-plugin --test-options="$TEST_OPTS"
230230

231-
- if: matrix.test
231+
- if: matrix.test && matrix.ghc != '9.8'
232232
name: Test hls-retrie-plugin test suite
233233
run: cabal test hls-retrie-plugin --test-options="$TEST_OPTS" || cabal test hls-retrie-plugin --test-options="$TEST_OPTS"
234234

cabal.project

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ package *
5252

5353
write-ghc-environment-files: never
5454

55-
index-state: 2023-09-08T00:00:00Z
55+
index-state: 2023-10-06T06:12:29Z
5656

5757
constraints:
5858
-- For GHC 9.4, older versions of entropy fail to build on Windows
@@ -72,8 +72,6 @@ constraints:
7272
setup.happy == 1.20.1.1,
7373
happy == 1.20.1.1,
7474
filepath installed,
75-
-- for ghc 8.10, stm-hamt 1.2.0.10 doesn't build
76-
stm-hamt < 1.2.0.10,
7775
-- Centos 7 comes with an old gcc version that doesn't know about
7876
-- the flag '-fopen-simd', which blocked the release 2.2.0.0.
7977
-- We want to be able to benefit from the performance optimisations
@@ -103,3 +101,32 @@ if impl(ghc >= 9.5)
103101
-- ghc-9.6
104102
ekg-core:ghc-prim,
105103
stm-hamt:transformers,
104+
105+
if impl(ghc >= 9.7)
106+
allow-newer:
107+
-- ghc-9.8
108+
base,
109+
template-haskell,
110+
ghc,
111+
ghc-prim,
112+
integer-gmp,
113+
ghc-bignum,
114+
template-haskell,
115+
text,
116+
binary,
117+
bytestring,
118+
Cabal,
119+
unix,
120+
deepseq,
121+
122+
if impl(ghc >= 9.7)
123+
repository head.hackage.ghc.haskell.org
124+
url: https://ghc.gitlab.haskell.org/head.hackage/
125+
secure: True
126+
key-threshold: 3
127+
root-keys:
128+
f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89
129+
26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329
130+
7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d
131+
132+
active-repositories: hackage.haskell.org, head.hackage.ghc.haskell.org

ghcide/ghcide.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ library
5959
dependent-sum,
6060
dlist,
6161
exceptions,
62-
extra >= 1.7.4,
62+
extra >= 1.7.14,
6363
enummapset,
6464
filepath,
6565
fingertree,

ghcide/src/Development/IDE/Core/Compile.hs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,15 @@ filterUsages = id
479479
-- Important to do this immediately after reading the unit before
480480
-- anything else has a chance to read `mi_usages`
481481
shareUsages :: ModIface -> ModIface
482-
shareUsages iface = iface {mi_usages = usages}
482+
shareUsages iface
483+
= iface
484+
#if !MIN_VERSION_ghc(9,7,0)
485+
{mi_usages = usages}
483486
where usages = map go (mi_usages iface)
484487
go usg@UsageFile{} = usg {usg_file_path = fp}
485488
where !fp = shareFilePath (usg_file_path usg)
486489
go usg = usg
490+
#endif
487491

488492

489493
mkHiFileResultNoCompile :: HscEnv -> TcModuleResult -> IO HiFileResult
@@ -779,7 +783,9 @@ unnecessaryDeprecationWarningFlags
779783
, Opt_WarnUnusedForalls
780784
, Opt_WarnUnusedRecordWildcards
781785
, Opt_WarnInaccessibleCode
786+
#if !MIN_VERSION_ghc(9,7,0)
782787
, Opt_WarnWarningsDeprecations
788+
#endif
783789
]
784790

785791
-- | Add a unnecessary/deprecated tag to the required diagnostics.
@@ -794,8 +800,11 @@ tagDiag (w@(Reason warning), (nfp, sh, fd))
794800
= (w, (nfp, sh, fd { _tags = Just $ tag : concat (_tags fd) }))
795801
where
796802
requiresTag :: WarningFlag -> Maybe DiagnosticTag
803+
#if !MIN_VERSION_ghc(9,7,0)
804+
-- TODO wz1000: handle deprecations in 9.7+
797805
requiresTag Opt_WarnWarningsDeprecations
798806
= Just DiagnosticTag_Deprecated
807+
#endif
799808
requiresTag wflag -- deprecation was already considered above
800809
| wflag `elem` unnecessaryDeprecationWarningFlags
801810
= Just DiagnosticTag_Unnecessary

ghcide/src/Development/IDE/GHC/CPP.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ doCpp env input_fn output_fn =
5252

5353
#if MIN_VERSION_ghc(9,5,0)
5454
let cpp_opts = Pipeline.CppOpts
55-
{ cppUseCc = False
56-
, cppLinePragmas = True
55+
{ cppLinePragmas = True
56+
# if MIN_VERSION_ghc(9,9,0)
57+
, useHsCpp = True
58+
# else
59+
, cppUseCc = False
60+
# endif
5761
} in
5862
#else
5963
let cpp_opts = True in

ghcide/src/Development/IDE/GHC/Compat.hs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ module Development.IDE.GHC.Compat(
4141

4242
Usage(..),
4343

44+
liftZonkM,
45+
4446
FastStringCompat,
4547
bytesFS,
4648
mkFastStringByteString,
@@ -55,6 +57,7 @@ module Development.IDE.GHC.Compat(
5557
combineRealSrcSpans,
5658

5759
nonDetOccEnvElts,
60+
nonDetFoldOccEnv,
5861

5962
isQualifiedImport,
6063
GhcVersion(..),
@@ -93,6 +96,7 @@ module Development.IDE.GHC.Compat(
9396
simplifyExpr,
9497
tidyExpr,
9598
emptyTidyEnv,
99+
tcInitTidyEnv,
96100
corePrepExpr,
97101
corePrepPgm,
98102
lintInteractiveExpr,
@@ -165,6 +169,9 @@ import qualified Data.Set as S
165169

166170
-- See Note [Guidelines For Using CPP In GHCIDE Import Statements]
167171

172+
#if MIN_VERSION_ghc(9,7,0)
173+
import GHC.Tc.Zonk.TcType (tcInitTidyEnv)
174+
#endif
168175
import qualified GHC.Core.Opt.Pipeline as GHC
169176
import GHC.Core.Tidy (tidyExpr)
170177
import GHC.CoreToStg.Prep (corePrepPgm)
@@ -247,6 +254,15 @@ import GHC.Driver.Config.CoreToStg (initCoreTo
247254
import GHC.Driver.Config.CoreToStg.Prep (initCorePrepConfig)
248255
#endif
249256

257+
#if !MIN_VERSION_ghc(9,7,0)
258+
liftZonkM :: a -> a
259+
liftZonkM = id
260+
#endif
261+
262+
#if !MIN_VERSION_ghc(9,7,0)
263+
nonDetFoldOccEnv :: (a -> b -> b) -> b -> OccEnv a -> b
264+
nonDetFoldOccEnv = foldOccEnv
265+
#endif
250266

251267
#if !MIN_VERSION_ghc(9,3,0)
252268
nonDetOccEnvElts :: OccEnv a -> [a]
@@ -328,7 +344,9 @@ myCoreToStg logger dflags ictxt
328344
#endif
329345
this_mod ml prepd_binds
330346

331-
#if MIN_VERSION_ghc(9,4,2)
347+
#if MIN_VERSION_ghc(9,8,0)
348+
(unzip -> (stg_binds2,_),_)
349+
#elif MIN_VERSION_ghc(9,4,2)
332350
(stg_binds2,_)
333351
#else
334352
stg_binds2

ghcide/src/Development/IDE/GHC/Compat/Core.hs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ module Development.IDE.GHC.Compat.Core (
152152
pattern AvailTC,
153153
Avail.availName,
154154
Avail.availNames,
155+
#if !MIN_VERSION_ghc(9,7,0)
155156
Avail.availNamesWithSelectors,
157+
#endif
156158
Avail.availsToNameSet,
157159
-- * TcGblEnv
158160
TcGblEnv(..),
@@ -376,7 +378,9 @@ module Development.IDE.GHC.Compat.Core (
376378
module GHC.Types.Name.Reader,
377379
module GHC.Utils.Error,
378380
#if MIN_VERSION_ghc(9,2,0)
381+
#if !MIN_VERSION_ghc(9,7,0)
379382
module GHC.Types.Avail,
383+
#endif
380384
module GHC.Types.SourceFile,
381385
module GHC.Types.SourceText,
382386
module GHC.Types.TyThing,
@@ -556,7 +560,9 @@ import GHC.Parser.Lexer hiding (initParserState, getPsMess
556560
import GHC.Parser.Annotation (EpAnn (..))
557561
import GHC.Platform.Ways
558562
import GHC.Runtime.Context (InteractiveImport (..))
563+
#if !MIN_VERSION_ghc(9,7,0)
559564
import GHC.Types.Avail (greNamePrintableName)
565+
#endif
560566
import GHC.Types.Fixity (LexicalFixity (..), Fixity (..), defaultFixity)
561567
import GHC.Types.Meta
562568
import GHC.Types.Name.Set
@@ -631,7 +637,9 @@ pattern RealSrcLoc x y = SrcLoc.RealSrcLoc x y
631637

632638

633639
pattern AvailTC :: Name -> [Name] -> [FieldLabel] -> Avail.AvailInfo
634-
#if __GLASGOW_HASKELL__ >= 902
640+
#if __GLASGOW_HASKELL__ >= 907
641+
pattern AvailTC n names pieces <- Avail.AvailTC n ((,[]) -> (names,pieces))
642+
#elif __GLASGOW_HASKELL__ >= 902
635643
pattern AvailTC n names pieces <- Avail.AvailTC n ((\gres -> foldr (\gre (names, pieces) -> case gre of
636644
Avail.NormalGreName name -> (name: names, pieces)
637645
Avail.FieldGreName label -> (names, label:pieces)) ([], []) gres) -> (names, pieces))
@@ -640,14 +648,18 @@ pattern AvailTC n names pieces <- Avail.AvailTC n names pieces
640648
#endif
641649

642650
pattern AvailName :: Name -> Avail.AvailInfo
643-
#if __GLASGOW_HASKELL__ >= 902
651+
#if __GLASGOW_HASKELL__ >= 907
652+
pattern AvailName n <- Avail.Avail n
653+
#elif __GLASGOW_HASKELL__ >= 902
644654
pattern AvailName n <- Avail.Avail (Avail.NormalGreName n)
645655
#else
646656
pattern AvailName n <- Avail.Avail n
647657
#endif
648658

649659
pattern AvailFL :: FieldLabel -> Avail.AvailInfo
650-
#if __GLASGOW_HASKELL__ >= 902
660+
#if __GLASGOW_HASKELL__ >= 907
661+
pattern AvailFL fl <- (const Nothing -> Just fl) -- this pattern always fails as this field was removed in 9.7
662+
#elif __GLASGOW_HASKELL__ >= 902
651663
pattern AvailFL fl <- Avail.Avail (Avail.FieldGreName fl)
652664
#else
653665
-- pattern synonym that is never populated
@@ -835,7 +847,11 @@ pattern GRE :: Name -> Parent -> Bool -> [ImportSpec] -> RdrName.GlobalRdrElt
835847
{-# COMPLETE GRE #-}
836848
#if MIN_VERSION_ghc(9,2,0)
837849
pattern GRE{gre_name, gre_par, gre_lcl, gre_imp} <- RdrName.GRE
850+
#if MIN_VERSION_ghc(9,7,0)
851+
{gre_name = gre_name
852+
#else
838853
{gre_name = (greNamePrintableName -> gre_name)
854+
#endif
839855
,gre_par, gre_lcl, gre_imp = (toList -> gre_imp)}
840856
#else
841857
pattern GRE{gre_name, gre_par, gre_lcl, gre_imp} = RdrName.GRE{..}

ghcide/src/Development/IDE/GHC/Compat/Iface.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ import GHC
1212

1313
-- See Note [Guidelines For Using CPP In GHCIDE Import Statements]
1414

15+
#if MIN_VERSION_ghc(9,7,0)
16+
import GHC.Iface.Errors.Ppr (missingInterfaceErrorDiagnostic)
17+
import GHC.Iface.Errors.Types (IfaceMessage)
18+
#endif
19+
1520
#if !MIN_VERSION_ghc(9,2,0)
1621
import qualified GHC.Driver.Finder as Finder
1722
import GHC.Driver.Types (FindResult)
@@ -38,7 +43,9 @@ writeIfaceFile env = Iface.writeIface (hsc_dflags env)
3843

3944
cannotFindModule :: HscEnv -> ModuleName -> FindResult -> SDoc
4045
cannotFindModule env modname fr =
41-
#if MIN_VERSION_ghc(9,2,0)
46+
#if MIN_VERSION_ghc(9,7,0)
47+
missingInterfaceErrorDiagnostic (defaultDiagnosticOpts @IfaceMessage) $ Iface.cannotFindModule env modname fr
48+
#elif MIN_VERSION_ghc(9,2,0)
4249
Iface.cannotFindModule env modname fr
4350
#else
4451
Finder.cannotFindModule (hsc_dflags env) modname fr

ghcide/src/Development/IDE/GHC/Compat/Logger.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ type LogActionCompat = LogFlags -> Maybe DiagnosticReason -> Maybe Severity -> S
5151

5252
-- alwaysQualify seems to still do the right thing here, according to the "unqualified warnings" test.
5353
logActionCompat :: LogActionCompat -> LogAction
54-
#if MIN_VERSION_ghc(9,5,0)
54+
#if MIN_VERSION_ghc(9,7,0)
55+
logActionCompat logAction logFlags (MCDiagnostic severity (ResolvedDiagnosticReason wr) _) loc = logAction logFlags (Just wr) (Just severity) loc alwaysQualify
56+
#elif MIN_VERSION_ghc(9,5,0)
5557
logActionCompat logAction logFlags (MCDiagnostic severity wr _) loc = logAction logFlags (Just wr) (Just severity) loc alwaysQualify
5658
#else
5759
logActionCompat logAction logFlags (MCDiagnostic severity wr) loc = logAction logFlags (Just wr) (Just severity) loc alwaysQualify

0 commit comments

Comments
 (0)