Skip to content

GHC 9.8 support #3727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/supported-ghc-versions.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[ "9.6", "9.4" , "9.2" , "9.0" ]
[ "9.8", "9.6", "9.4" , "9.2" , "9.0" ]
22 changes: 11 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ jobs:
HLS_WRAPPER_TEST_EXE: hls-wrapper
run: cabal test wrapper-test --test-options="$TEST_OPTS --rerun-log-file .tasty-rerun-log-wrapper"

- if: matrix.test
- if: matrix.test && !startsWith(matrix.ghc,'9.8')
name: Test hls-refactor-plugin
run: cabal test hls-refactor-plugin --test-options="$TEST_OPTS" || cabal test hls-refactor-plugin --test-options="$TEST_OPTS"

- if: matrix.test && matrix.ghc != '9.6'
- if: matrix.test && matrix.ghc != '9.6' && !startsWith(matrix.ghc,'9.8')
name: Test hls-floskell-plugin
run: cabal test hls-floskell-plugin --test-options="$TEST_OPTS" || cabal test hls-floskell-plugin --test-options="$TEST_OPTS"

- if: matrix.test
- if: matrix.test && !startsWith(matrix.ghc,'9.8')
name: Test hls-class-plugin
run: cabal test hls-class-plugin --test-options="$TEST_OPTS" || cabal test hls-class-plugin --test-options="$TEST_OPTS"

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

- if: matrix.test
- if: matrix.test && !startsWith(matrix.ghc,'9.8')
name: Test hls-splice-plugin
run: cabal test hls-splice-plugin --test-options="$TEST_OPTS" || cabal test hls-splice-plugin --test-options="$TEST_OPTS"

- if: matrix.test
- if: matrix.test && !startsWith(matrix.ghc,'9.8')
name: Test hls-stylish-haskell-plugin
run: cabal test hls-stylish-haskell-plugin --test-options="$TEST_OPTS" || cabal test hls-stylish-haskell-plugin --test-options="$TEST_OPTS"

- if: matrix.test
- if: matrix.test && !startsWith(matrix.ghc,'9.8')
name: Test hls-ormolu-plugin
run: cabal test hls-ormolu-plugin --test-options="$TEST_OPTS" || cabal test hls-ormolu-plugin --test-options="$TEST_OPTS"

- if: matrix.test
- if: matrix.test && !startsWith(matrix.ghc,'9.8')
name: Test hls-fourmolu-plugin
run: cabal test hls-fourmolu-plugin --test-options="$TEST_OPTS" || cabal test hls-fourmolu-plugin --test-options="$TEST_OPTS"

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

- if: matrix.test && matrix.os != 'windows-latest'
- if: matrix.test && matrix.os != 'windows-latest' && !startsWith(matrix.ghc,'9.8')
name: Test hls-rename-plugin test suite
run: cabal test hls-rename-plugin --test-options="$TEST_OPTS" || cabal test hls-rename-plugin --test-options="$TEST_OPTS"

- if: matrix.test
- if: matrix.test && !startsWith(matrix.ghc,'9.8')
name: Test hls-hlint-plugin test suite
run: cabal test hls-hlint-plugin --test-options="$TEST_OPTS" || cabal test hls-hlint-plugin --test-options="$TEST_OPTS"

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

- if: matrix.test
- if: matrix.test && !startsWith(matrix.ghc,'9.8')
name: Test hls-gadt-plugin test suit
run: cabal test hls-gadt-plugin --test-options="$TEST_OPTS" || cabal test hls-gadt-plugin --test-options="$TEST_OPTS"

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

- if: matrix.test
- if: matrix.test && !startsWith(matrix.ghc,'9.8')
name: Test hls-retrie-plugin test suite
run: cabal test hls-retrie-plugin --test-options="$TEST_OPTS" || cabal test hls-retrie-plugin --test-options="$TEST_OPTS"

Expand Down
31 changes: 30 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ package *

write-ghc-environment-files: never

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

constraints:
-- For GHC 9.4, older versions of entropy fail to build on Windows
Expand Down Expand Up @@ -101,3 +101,32 @@ if impl(ghc >= 9.5)
-- ghc-9.6
ekg-core:ghc-prim,
stm-hamt:transformers,

if impl(ghc >= 9.7)
allow-newer:
-- ghc-9.8
base,
template-haskell,
ghc,
ghc-prim,
integer-gmp,
ghc-bignum,
template-haskell,
text,
binary,
bytestring,
Cabal,
unix,
deepseq,

if impl(ghc >= 9.7)
repository head.hackage.ghc.haskell.org
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can't really avoid this at the moment? I'm unsure how I feel about the prospect of us e.g. releasing binaries based on using packages from head.hackage 🤔 maybe it's fine

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I could use git dependencies instead by pushing head.hackage patches to forks, but I don't think it earns us much.

url: https://ghc.gitlab.haskell.org/head.hackage/
secure: True
key-threshold: 3
root-keys:
f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89
26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329
7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d

active-repositories: hackage.haskell.org, head.hackage.ghc.haskell.org
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you don't need this

2 changes: 1 addition & 1 deletion ghcide/ghcide.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ library
dependent-sum,
dlist,
exceptions,
extra >= 1.7.4,
extra >= 1.7.14,
enummapset,
filepath,
fingertree,
Expand Down
8 changes: 5 additions & 3 deletions ghcide/session-loader/Development/IDE/Session.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ import Data.Function
import Data.Hashable hiding (hash)
import qualified Data.HashMap.Strict as HM
import Data.List
import qualified Data.List.NonEmpty as NE
import Data.List.NonEmpty (NonEmpty(..))
import qualified Data.Map.Strict as Map
import Data.Maybe
import Data.Proxy
Expand Down Expand Up @@ -520,9 +522,9 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} dir = do
-- information.

new_deps = RawComponentInfo (homeUnitId_ df) df targets cfp opts dep_info
: maybe [] snd oldDeps
:| maybe [] snd oldDeps
-- Get all the unit-ids for things in this component
inplace = map rawComponentUnitId new_deps
inplace = map rawComponentUnitId $ NE.toList new_deps

new_deps' <- forM new_deps $ \RawComponentInfo{..} -> do
-- Remove all inplace dependencies from package flags for
Expand Down Expand Up @@ -572,7 +574,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} dir = do
-- . The information for the new component which caused this cache miss
-- . The modified information (without -inplace flags) for
-- existing packages
pure (Map.insert hieYaml (newHscEnv, new_deps) m, (newHscEnv, head new_deps', tail new_deps'))
pure (Map.insert hieYaml (newHscEnv, NE.toList new_deps) m, (newHscEnv, NE.head new_deps', NE.tail new_deps'))


let session :: (Maybe FilePath, NormalizedFilePath, ComponentOptions, FilePath)
Expand Down
55 changes: 49 additions & 6 deletions ghcide/src/Development/IDE/Core/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import Data.Time (UTCTime (..))
import Data.Tuple.Extra (dupe)
import Data.Unique as Unique
import Debug.Trace
import Development.IDE.Core.FileStore (resetInterfaceStore, shareFilePath)
import Development.IDE.Core.FileStore (resetInterfaceStore)
import Development.IDE.Core.Preprocessor
import Development.IDE.Core.RuleTypes
import Development.IDE.Core.Shake
Expand Down Expand Up @@ -147,6 +147,13 @@ import GHC.Driver.Config.CoreToStg.Prep
import GHC.Core.Lint.Interactive
#endif

#if MIN_VERSION_ghc(9,7,0)
import Data.Foldable (toList)
import GHC.Unit.Module.Warnings
#else
import Development.IDE.Core.FileStore (shareFilePath)
#endif

--Simple constants to make sure the source is consistently named
sourceTypecheck :: T.Text
sourceTypecheck = "typecheck"
Expand Down Expand Up @@ -479,11 +486,16 @@ filterUsages = id
-- Important to do this immediately after reading the unit before
-- anything else has a chance to read `mi_usages`
shareUsages :: ModIface -> ModIface
shareUsages iface = iface {mi_usages = usages}
shareUsages iface
= iface
-- Fixed upstream in GHC 9.8
#if !MIN_VERSION_ghc(9,7,0)
{mi_usages = usages}
where usages = map go (mi_usages iface)
go usg@UsageFile{} = usg {usg_file_path = fp}
where !fp = shareFilePath (usg_file_path usg)
go usg = usg
#endif


mkHiFileResultNoCompile :: HscEnv -> TcModuleResult -> IO HiFileResult
Expand Down Expand Up @@ -646,11 +658,24 @@ compileModule (RunSimplifier simplify) session ms tcg =
fmap (either (, Nothing) (second Just)) $
catchSrcErrors (hsc_dflags session) "compile" $ do
(warnings,desugared_guts) <- withWarnings "compile" $ \tweak -> do
let session' = tweak (hscSetFlags (ms_hspp_opts ms) session)
-- Breakpoints don't survive roundtripping from disk
-- and this trips up the verify-core-files check
-- They may also lead to other problems.
-- We have to setBackend ghciBackend in 9.8 as otherwise
-- non-exported definitions are stripped out.
-- However, setting this means breakpoints are generated.
-- Solution: prevent breakpoing generation by unsetting
-- Opt_InsertBreakpoints
let session' = tweak $ flip hscSetFlags session
#if MIN_VERSION_ghc(9,7,0)
$ flip gopt_unset Opt_InsertBreakpoints
$ setBackend ghciBackend
#endif
$ ms_hspp_opts ms
-- TODO: maybe settings ms_hspp_opts is unnecessary?
-- MP: the flags in ModSummary should be right, if they are wrong then
-- the correct place to fix this is when the ModSummary is created.
desugar <- hscDesugar session' (ms { ms_hspp_opts = hsc_dflags session' }) tcg
desugar <- hscDesugar session' (ms { ms_hspp_opts = hsc_dflags session' }) tcg
if simplify
then do
plugins <- readIORef (tcg_th_coreplugins tcg)
Expand Down Expand Up @@ -779,23 +804,41 @@ unnecessaryDeprecationWarningFlags
, Opt_WarnUnusedForalls
, Opt_WarnUnusedRecordWildcards
, Opt_WarnInaccessibleCode
#if !MIN_VERSION_ghc(9,7,0)
, Opt_WarnWarningsDeprecations
#endif
]

-- | Add a unnecessary/deprecated tag to the required diagnostics.
#if MIN_VERSION_ghc(9,3,0)
tagDiag :: (Maybe DiagnosticReason, FileDiagnostic) -> (Maybe DiagnosticReason, FileDiagnostic)
tagDiag (w@(Just (WarningWithFlag warning)), (nfp, sh, fd))
#else
tagDiag :: (WarnReason, FileDiagnostic) -> (WarnReason, FileDiagnostic)
tagDiag (w@(Reason warning), (nfp, sh, fd))
#endif

#if MIN_VERSION_ghc(9,7,0)
tagDiag (w@(Just (WarningWithCategory cat)), (nfp, sh, fd))
| cat == defaultWarningCategory -- default warning category is for deprecations
= (w, (nfp, sh, fd { _tags = Just $ DiagnosticTag_Deprecated : concat (_tags fd) }))
tagDiag (w@(Just (WarningWithFlags warnings)), (nfp, sh, fd))
| tags <- mapMaybe requiresTag (toList warnings)
= (w, (nfp, sh, fd { _tags = Just $ tags ++ concat (_tags fd) }))
#elif MIN_VERSION_ghc(9,3,0)
tagDiag (w@(Just (WarningWithFlag warning)), (nfp, sh, fd))
| Just tag <- requiresTag warning
= (w, (nfp, sh, fd { _tags = Just $ tag : concat (_tags fd) }))
#else
tagDiag (w@(Reason warning), (nfp, sh, fd))
| Just tag <- requiresTag warning
= (w, (nfp, sh, fd { _tags = Just $ tag : concat (_tags fd) }))
#endif
where
requiresTag :: WarningFlag -> Maybe DiagnosticTag
#if !MIN_VERSION_ghc(9,7,0)
-- doesn't exist on 9.8, we use WarningWithCategory instead
requiresTag Opt_WarnWarningsDeprecations
= Just DiagnosticTag_Deprecated
#endif
requiresTag wflag -- deprecation was already considered above
| wflag `elem` unnecessaryDeprecationWarningFlags
= Just DiagnosticTag_Unnecessary
Expand Down
8 changes: 6 additions & 2 deletions ghcide/src/Development/IDE/GHC/CPP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ doCpp env input_fn output_fn =

#if MIN_VERSION_ghc(9,5,0)
let cpp_opts = Pipeline.CppOpts
{ cppUseCc = False
, cppLinePragmas = True
{ cppLinePragmas = True
# if MIN_VERSION_ghc(9,9,0)
, useHsCpp = True
# else
, cppUseCc = False
# endif
} in
#else
let cpp_opts = True in
Expand Down
25 changes: 23 additions & 2 deletions ghcide/src/Development/IDE/GHC/Compat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ module Development.IDE.GHC.Compat(

Usage(..),

liftZonkM,

FastStringCompat,
bytesFS,
mkFastStringByteString,
Expand All @@ -55,6 +57,7 @@ module Development.IDE.GHC.Compat(
combineRealSrcSpans,

nonDetOccEnvElts,
nonDetFoldOccEnv,

isQualifiedImport,
GhcVersion(..),
Expand Down Expand Up @@ -93,6 +96,7 @@ module Development.IDE.GHC.Compat(
simplifyExpr,
tidyExpr,
emptyTidyEnv,
tcInitTidyEnv,
corePrepExpr,
corePrepPgm,
lintInteractiveExpr,
Expand Down Expand Up @@ -165,6 +169,9 @@ import qualified Data.Set as S

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

#if MIN_VERSION_ghc(9,7,0)
import GHC.Tc.Zonk.TcType (tcInitTidyEnv)
#endif
import qualified GHC.Core.Opt.Pipeline as GHC
import GHC.Core.Tidy (tidyExpr)
import GHC.CoreToStg.Prep (corePrepPgm)
Expand Down Expand Up @@ -247,6 +254,15 @@ import GHC.Driver.Config.CoreToStg (initCoreTo
import GHC.Driver.Config.CoreToStg.Prep (initCorePrepConfig)
#endif

#if !MIN_VERSION_ghc(9,7,0)
liftZonkM :: a -> a
liftZonkM = id
#endif

#if !MIN_VERSION_ghc(9,7,0)
nonDetFoldOccEnv :: (a -> b -> b) -> b -> OccEnv a -> b
nonDetFoldOccEnv = foldOccEnv
#endif

#if !MIN_VERSION_ghc(9,3,0)
nonDetOccEnvElts :: OccEnv a -> [a]
Expand Down Expand Up @@ -328,7 +344,9 @@ myCoreToStg logger dflags ictxt
#endif
this_mod ml prepd_binds

#if MIN_VERSION_ghc(9,4,2)
#if MIN_VERSION_ghc(9,8,0)
(unzip -> (stg_binds2,_),_)
#elif MIN_VERSION_ghc(9,4,2)
(stg_binds2,_)
#else
stg_binds2
Expand Down Expand Up @@ -537,13 +555,16 @@ data GhcVersion
| GHC92
| GHC94
| GHC96
| GHC98
deriving (Eq, Ord, Show)

ghcVersionStr :: String
ghcVersionStr = VERSION_ghc

ghcVersion :: GhcVersion
#if MIN_VERSION_GLASGOW_HASKELL(9,6,0,0)
#if MIN_VERSION_GLASGOW_HASKELL(9,8,0,0)
ghcVersion = GHC98
#elif MIN_VERSION_GLASGOW_HASKELL(9,6,0,0)
ghcVersion = GHC96
#elif MIN_VERSION_GLASGOW_HASKELL(9,4,0,0)
ghcVersion = GHC94
Expand Down
Loading