Skip to content

Commit 6f8d388

Browse files
committed
9.6 support
Fixes hls-refactor-plugin 9.6 support hls-gadt-plugin Fix 9.4 build Fixes hls-gadt-plugin fixes WIP 9.6 patches fixes fixes fixes fixes fixes
1 parent f17707c commit 6f8d388

File tree

44 files changed

+583
-130
lines changed

Some content is hidden

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

44 files changed

+583
-130
lines changed

cabal.project

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,36 @@ packages:
4242
-- See https://github.com/haskell/haskell-language-server/blob/master/.gitlab-ci.yml
4343
optional-packages: vendored/*/*.cabal
4444

45-
tests: true
45+
tests: True
46+
47+
if impl(ghc >= 9.5)
48+
source-repository-package
49+
type:git
50+
location: https://github.com/wz1000/HieDb
51+
tag: 3efdab5ba67a9cea5bb8c97ed2c52a8929eabaaa
52+
53+
source-repository-package
54+
type:git
55+
location: https://github.com/wz1000/retrie
56+
tag: 3ad8ca0450ea4619bbc8007251582ffc828faa37
57+
58+
source-repository-package
59+
type:git
60+
location: https://github.com/haskell/hie-bios
61+
tag: 8519812ad7501cab31347cd46ad1312b8413b8ad
62+
63+
source-repository-package
64+
type:git
65+
location: https://github.com/wz1000/ghc-exactprint/
66+
tag: 58d88820399b66304f3bb18f0b2602c3a90d5bea
4667

4768
package *
4869
ghc-options: -haddock
4970
test-show-details: direct
5071

5172
write-ghc-environment-files: never
5273

53-
index-state: 2023-01-27T00:00:00Z
74+
index-state: 2023-02-19T00:00:01Z
5475

5576
constraints:
5677
-- For GHC 9.4, older versions of entropy fail to build on Windows
@@ -66,7 +87,9 @@ constraints:
6687
ghc-check -ghc-check-use-package-abis,
6788
ghc-lib-parser-ex -auto,
6889
stylish-haskell +ghc-lib,
69-
fourmolu -fixity-th
90+
fourmolu -fixity-th,
91+
setup.happy == 1.20.1.1,
92+
happy == 1.20.1.1
7093

7194
-- This is benign and won't affect our ability to release to Hackage,
7295
-- because we only depend on `ekg-json` when a non-default flag
@@ -75,14 +98,18 @@ constraints:
7598
-- centos7 has an old version of git which cabal doesn't
7699
-- support. We delete these lines in gitlab ci to workaround
77100
-- this issue, as this is not necessary to build our binaries.
78-
source-repository-package
79-
type:git
80-
location: https://github.com/pepeiborra/ekg-json
81-
tag: 7a0af7a8fd38045fd15fb13445bdcc7085325460
82-
-- https://github.com/tibbe/ekg-json/pull/12
83101
-- END DELETE
84102

85103
allow-newer:
104+
-- ghc-9.6
105+
template-haskell,
106+
base,
107+
ghc-prim,
108+
ghc,
109+
ghc-boot,
110+
mtl,
111+
transformers,
112+
Cabal,
86113
-- ghc-9.4
87114
Chart-diagrams:lens,
88115
Chart:lens,
@@ -105,3 +132,15 @@ allow-newer:
105132
uuid:time,
106133
vector-space:base,
107134
ekg-wai:time,
135+
136+
if impl(ghc >= 9.5)
137+
repository head.hackage.ghc.haskell.org
138+
url: https://ghc.gitlab.haskell.org/head.hackage/
139+
secure: True
140+
key-threshold: 3
141+
root-keys:
142+
f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89
143+
26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329
144+
7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d
145+
146+
active-repositories: hackage.haskell.org, head.hackage.ghc.haskell.org:override

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

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ module Development.IDE.Core.Compile
3636
, TypecheckHelpers(..)
3737
) where
3838

39+
import Control.Monad.IO.Class
3940
import Control.Concurrent.Extra
4041
import Control.Concurrent.STM.Stats hiding (orElse)
4142
import Control.DeepSeq (NFData (..), force, liftRnf,
@@ -133,6 +134,11 @@ import GHC.Hs (LEpaComment)
133134
import qualified GHC.Types.Error as Error
134135
#endif
135136

137+
#if MIN_VERSION_ghc(9,5,0)
138+
import GHC.Driver.Config.CoreToStg.Prep
139+
import GHC.Core.Lint.Interactive
140+
#endif
141+
136142
-- | Given a string buffer, return the string (after preprocessing) and the 'ParsedModule'.
137143
parseModule
138144
:: IdeOptions
@@ -467,7 +473,11 @@ mkHiFileResultNoCompile session tcm = do
467473
tcGblEnv = tmrTypechecked tcm
468474
details <- makeSimpleDetails hsc_env_tmp tcGblEnv
469475
sf <- finalSafeMode (ms_hspp_opts ms) tcGblEnv
470-
iface' <- mkIfaceTc hsc_env_tmp sf details ms tcGblEnv
476+
iface' <- mkIfaceTc hsc_env_tmp sf details ms
477+
#if MIN_VERSION_ghc(9,5,0)
478+
Nothing
479+
#endif
480+
tcGblEnv
471481
let iface = iface' { mi_globals = Nothing, mi_usages = filterUsages (mi_usages iface') } -- See Note [Clearing mi_globals after generating an iface]
472482
pure $! mkHiFileResult ms iface details (tmrRuntimeModules tcm) Nothing
473483

@@ -482,20 +492,19 @@ mkHiFileResultCompile se session' tcm simplified_guts = catchErrs $ do
482492
ms = pm_mod_summary $ tmrParsed tcm
483493
tcGblEnv = tmrTypechecked tcm
484494

485-
(details, mguts) <-
486-
if mg_hsc_src simplified_guts == HsBootFile
487-
then do
488-
details <- mkBootModDetailsTc session tcGblEnv
489-
pure (details, Nothing)
490-
else do
495+
(details, guts) <- do
491496
-- write core file
492497
-- give variables unique OccNames
493498
tidy_opts <- initTidyOpts session
494499
(guts, details) <- tidyProgram tidy_opts simplified_guts
495-
pure (details, Just guts)
500+
pure (details, guts)
496501

497502
#if MIN_VERSION_ghc(9,0,1)
498-
let !partial_iface = force $ mkPartialIface session details
503+
let !partial_iface = force $ mkPartialIface session
504+
#if MIN_VERSION_ghc(9,5,0)
505+
(cg_binds guts)
506+
#endif
507+
details
499508
#if MIN_VERSION_ghc(9,3,0)
500509
ms
501510
#endif
@@ -513,9 +522,7 @@ mkHiFileResultCompile se session' tcm simplified_guts = catchErrs $ do
513522
let final_iface = final_iface' {mi_globals = Nothing, mi_usages = filterUsages (mi_usages final_iface')} -- See Note [Clearing mi_globals after generating an iface]
514523

515524
-- Write the core file now
516-
core_file <- case mguts of
517-
Nothing -> pure Nothing -- no guts, likely boot file
518-
Just guts -> do
525+
core_file <- do
519526
let core_fp = ml_core_file $ ms_location ms
520527
core_file = codeGutsToCoreFile iface_hash guts
521528
iface_hash = getModuleHash final_iface
@@ -538,27 +545,37 @@ mkHiFileResultCompile se session' tcm simplified_guts = catchErrs $ do
538545
Just (core, _) | optVerifyCoreFile -> do
539546
let core_fp = ml_core_file $ ms_location ms
540547
traceIO $ "Verifying " ++ core_fp
541-
let CgGuts{cg_binds = unprep_binds, cg_tycons = tycons } = case mguts of
542-
Nothing -> error "invariant optVerifyCoreFile: guts must exist if linkable exists"
543-
Just g -> g
548+
let CgGuts{cg_binds = unprep_binds, cg_tycons = tycons } = guts
544549
mod = ms_mod ms
545550
data_tycons = filter isDataTyCon tycons
546551
CgGuts{cg_binds = unprep_binds'} <- coreFileToCgGuts session final_iface details core
547552

553+
#if MIN_VERSION_ghc(9,5,0)
554+
cp_cfg <- initCorePrepConfig session
555+
#endif
556+
557+
let corePrep = corePrepPgm
558+
#if MIN_VERSION_ghc(9,5,0)
559+
(hsc_logger session) cp_cfg (initCorePrepPgmConfig (hsc_dflags session) (interactiveInScope $ hsc_IC session))
560+
#else
561+
session
562+
#endif
563+
mod (ms_location ms)
564+
548565
-- Run corePrep first as we want to test the final version of the program that will
549566
-- get translated to STG/Bytecode
550567
#if MIN_VERSION_ghc(9,3,0)
551568
prepd_binds
552569
#else
553570
(prepd_binds , _)
554571
#endif
555-
<- corePrepPgm session mod (ms_location ms) unprep_binds data_tycons
572+
<- corePrep unprep_binds data_tycons
556573
#if MIN_VERSION_ghc(9,3,0)
557574
prepd_binds'
558575
#else
559576
(prepd_binds', _)
560577
#endif
561-
<- corePrepPgm session mod (ms_location ms) unprep_binds' data_tycons
578+
<- corePrep unprep_binds' data_tycons
562579
let binds = noUnfoldings $ (map flattenBinds . (:[])) $ prepd_binds
563580
binds' = noUnfoldings $ (map flattenBinds . (:[])) $ prepd_binds'
564581

@@ -683,7 +700,7 @@ generateByteCode (CoreFileTime time) hscEnv summary guts = do
683700
let session = _tweak (hscSetFlags (ms_hspp_opts summary) hscEnv)
684701
-- TODO: maybe settings ms_hspp_opts is unnecessary?
685702
summary' = summary { ms_hspp_opts = hsc_dflags session }
686-
hscInteractive session guts
703+
hscInteractive session (mkCgInteractiveGuts guts)
687704
(ms_location summary')
688705
let unlinked = BCOs bytecode sptEntries
689706
let linkable = LM time (ms_mod summary) [unlinked]
@@ -1220,7 +1237,9 @@ parseHeader
12201237
=> DynFlags -- ^ flags to use
12211238
-> FilePath -- ^ the filename (for source locations)
12221239
-> Util.StringBuffer -- ^ Haskell module source text (full Unicode is supported)
1223-
#if MIN_VERSION_ghc(9,0,1)
1240+
#if MIN_VERSION_ghc(9,5,0)
1241+
-> ExceptT [FileDiagnostic] m ([FileDiagnostic], Located(HsModule GhcPs))
1242+
#elif MIN_VERSION_ghc(9,0,1)
12241243
-> ExceptT [FileDiagnostic] m ([FileDiagnostic], Located(HsModule))
12251244
#else
12261245
-> ExceptT [FileDiagnostic] m ([FileDiagnostic], Located(HsModule GhcPs))
@@ -1552,13 +1571,13 @@ showReason (RecompBecause s) = s
15521571
mkDetailsFromIface :: HscEnv -> ModIface -> IO ModDetails
15531572
mkDetailsFromIface session iface = do
15541573
fixIO $ \details -> do
1555-
let !hsc' = hscUpdateHPT (\hpt -> addToHpt hpt (moduleName $ mi_module iface) (HomeModInfo iface details Nothing)) session
1574+
let !hsc' = hscUpdateHPT (\hpt -> addToHpt hpt (moduleName $ mi_module iface) (HomeModInfo iface details emptyHomeModInfoLinkable)) session
15561575
initIfaceLoad hsc' (typecheckIface iface)
15571576

15581577
coreFileToCgGuts :: HscEnv -> ModIface -> ModDetails -> CoreFile -> IO CgGuts
15591578
coreFileToCgGuts session iface details core_file = do
15601579
let act hpt = addToHpt hpt (moduleName this_mod)
1561-
(HomeModInfo iface details Nothing)
1580+
(HomeModInfo iface details emptyHomeModInfoLinkable)
15621581
this_mod = mi_module iface
15631582
types_var <- newIORef (md_types details)
15641583
let hsc_env' = hscUpdateHPT act (session {
@@ -1572,7 +1591,10 @@ coreFileToCgGuts session iface details core_file = do
15721591
-- Implicit binds aren't saved, so we need to regenerate them ourselves.
15731592
let implicit_binds = concatMap getImplicitBinds tyCons
15741593
tyCons = typeEnvTyCons (md_types details)
1575-
#if MIN_VERSION_ghc(9,3,0)
1594+
#if MIN_VERSION_ghc(9,5,0)
1595+
-- In GHC 9.6, the implicit binds are tidied and part of core_binds
1596+
pure $ CgGuts this_mod tyCons core_binds [] NoStubs [] mempty (emptyHpcInfo False) Nothing []
1597+
#elif MIN_VERSION_ghc(9,3,0)
15761598
pure $ CgGuts this_mod tyCons (implicit_binds ++ core_binds) [] NoStubs [] mempty (emptyHpcInfo False) Nothing []
15771599
#else
15781600
pure $ CgGuts this_mod tyCons (implicit_binds ++ core_binds) NoStubs [] [] (emptyHpcInfo False) Nothing []
@@ -1582,9 +1604,9 @@ coreFileToLinkable :: LinkableType -> HscEnv -> ModSummary -> ModIface -> ModDet
15821604
coreFileToLinkable linkableType session ms iface details core_file t = do
15831605
cgi_guts <- coreFileToCgGuts session iface details core_file
15841606
(warns, lb) <- case linkableType of
1585-
BCOLinkable -> generateByteCode (CoreFileTime t) session ms cgi_guts
1586-
ObjectLinkable -> generateObjectCode session ms cgi_guts
1587-
pure (warns, HomeModInfo iface details . Just <$> lb)
1607+
BCOLinkable -> fmap (maybe emptyHomeModInfoLinkable justBytecode) <$> generateByteCode (CoreFileTime t) session ms cgi_guts
1608+
ObjectLinkable -> fmap (maybe emptyHomeModInfoLinkable justObjects) <$> generateObjectCode session ms cgi_guts
1609+
pure (warns, Just $ HomeModInfo iface details lb) -- TODO wz1000 handle emptyHomeModInfoLinkable
15881610

15891611
-- | Non-interactive, batch version of 'InteractiveEval.getDocs'.
15901612
-- The interactive paths create problems in ghc-lib builds

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ module Development.IDE.Core.Rules(
6363
DisplayTHWarning(..),
6464
) where
6565

66+
import Control.Applicative
6667
import Control.Concurrent.Async (concurrently)
6768
import Control.Concurrent.Strict
6869
import Control.DeepSeq
@@ -161,6 +162,9 @@ import Control.Monad.IO.Unlift
161162
import GHC.Unit.Module.Graph
162163
import GHC.Unit.Env
163164
#endif
165+
#if MIN_VERSION_ghc(9,5,0)
166+
import GHC.Unit.Home.ModInfo
167+
#endif
164168

165169
data Log
166170
= LogShake Shake.Log
@@ -776,7 +780,7 @@ ghcSessionDepsDefinition fullModSummary GhcSessionDepsConfig{..} env file = do
776780

777781
depSessions <- map hscEnv <$> uses_ (GhcSessionDeps_ fullModSummary) deps
778782
ifaces <- uses_ GetModIface deps
779-
let inLoadOrder = map (\HiFileResult{..} -> HomeModInfo hirModIface hirModDetails Nothing) ifaces
783+
let inLoadOrder = map (\HiFileResult{..} -> HomeModInfo hirModIface hirModDetails emptyHomeModInfoLinkable) ifaces
780784
#if MIN_VERSION_ghc(9,3,0)
781785
-- On GHC 9.4+, the module graph contains not only ModSummary's but each `ModuleNode` in the graph
782786
-- also points to all the direct descendants of the current module. To get the keys for the descendants
@@ -1100,10 +1104,10 @@ getLinkableRule recorder =
11001104
else pure Nothing
11011105
case mobj_time of
11021106
Just obj_t
1103-
| obj_t >= core_t -> pure ([], Just $ HomeModInfo hirModIface hirModDetails (Just $ LM (posixSecondsToUTCTime obj_t) (ms_mod ms) [DotO obj_file]))
1107+
| obj_t >= core_t -> pure ([], Just $ HomeModInfo hirModIface hirModDetails (justObjects $ LM (posixSecondsToUTCTime obj_t) (ms_mod ms) [DotO obj_file]))
11041108
_ -> liftIO $ coreFileToLinkable linkableType (hscEnv session) ms hirModIface hirModDetails bin_core (error "object doesn't have time")
11051109
-- Record the linkable so we know not to unload it, and unload old versions
1106-
whenJust (hm_linkable =<< hmi) $ \(LM time mod _) -> do
1110+
whenJust ((homeModInfoByteCode =<< hmi) <|> (homeModInfoObject =<< hmi)) $ \(LM time mod _) -> do
11071111
compiledLinkables <- getCompiledLinkables <$> getIdeGlobalAction
11081112
liftIO $ modifyVar compiledLinkables $ \old -> do
11091113
let !to_keep = extendModuleEnv old mod time

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
module Development.IDE.GHC.CPP(doCpp, addOptP)
1616
where
1717

18+
import Control.Monad
1819
import Development.IDE.GHC.Compat as Compat
1920
import Development.IDE.GHC.Compat.Util
2021
import GHC
@@ -41,7 +42,9 @@ addOptP f = alterToolSettings $ \s -> s
4142

4243
doCpp :: HscEnv -> Bool -> FilePath -> FilePath -> IO ()
4344
doCpp env raw input_fn output_fn =
44-
#if MIN_VERSION_ghc (9,2,0)
45+
#if MIN_VERSION_ghc(9,5,0)
46+
void $ Pipeline.runCppPhase env input_fn output_fn -- TODO wz1000
47+
#elif MIN_VERSION_ghc(9,2,0)
4548
Pipeline.doCpp (hsc_logger env) (hsc_tmpfs env) (hsc_dflags env) (hsc_unit_env env) raw input_fn output_fn
4649
#else
4750
Pipeline.doCpp (hsc_dflags env) raw input_fn output_fn

0 commit comments

Comments
 (0)