Skip to content

Commit bf88ad8

Browse files
committed
9.6 support
1 parent 2b691b6 commit bf88ad8

File tree

19 files changed

+266
-93
lines changed

19 files changed

+266
-93
lines changed

cabal.project

Lines changed: 62 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
packages:
2-
./
2+
-- ./
33
./hie-compat
44
./shake-bench
55
./hls-graph
@@ -8,49 +8,60 @@ packages:
88
./ghcide/test
99
./hls-plugin-api
1010
./hls-test-utils
11-
./plugins/hls-cabal-plugin
12-
./plugins/hls-cabal-fmt-plugin
13-
./plugins/hls-tactics-plugin
14-
./plugins/hls-stylish-haskell-plugin
15-
./plugins/hls-fourmolu-plugin
16-
./plugins/hls-class-plugin
17-
./plugins/hls-eval-plugin
18-
./plugins/hls-explicit-imports-plugin
19-
./plugins/hls-refine-imports-plugin
20-
./plugins/hls-hlint-plugin
21-
./plugins/hls-rename-plugin
22-
./plugins/hls-retrie-plugin
23-
./plugins/hls-haddock-comments-plugin
24-
./plugins/hls-splice-plugin
25-
./plugins/hls-floskell-plugin
26-
./plugins/hls-pragmas-plugin
27-
./plugins/hls-module-name-plugin
28-
./plugins/hls-ormolu-plugin
29-
./plugins/hls-call-hierarchy-plugin
30-
./plugins/hls-alternate-number-format-plugin
31-
./plugins/hls-qualify-imported-names-plugin
32-
./plugins/hls-code-range-plugin
33-
./plugins/hls-change-type-signature-plugin
34-
./plugins/hls-stan-plugin
35-
./plugins/hls-gadt-plugin
36-
./plugins/hls-explicit-fixity-plugin
37-
./plugins/hls-explicit-record-fields-plugin
38-
./plugins/hls-refactor-plugin
11+
-- ./plugins/hls-cabal-plugin
12+
-- ./plugins/hls-cabal-fmt-plugin
13+
-- ./plugins/hls-tactics-plugin
14+
-- ./plugins/hls-stylish-haskell-plugin
15+
-- ./plugins/hls-fourmolu-plugin
16+
-- ./plugins/hls-class-plugin
17+
-- ./plugins/hls-eval-plugin
18+
-- ./plugins/hls-explicit-imports-plugin
19+
-- ./plugins/hls-refine-imports-plugin
20+
-- ./plugins/hls-hlint-plugin
21+
-- ./plugins/hls-rename-plugin
22+
-- ./plugins/hls-retrie-plugin
23+
-- ./plugins/hls-haddock-comments-plugin
24+
-- ./plugins/hls-splice-plugin
25+
-- ./plugins/hls-floskell-plugin
26+
-- ./plugins/hls-pragmas-plugin
27+
-- ./plugins/hls-module-name-plugin
28+
-- ./plugins/hls-ormolu-plugin
29+
-- ./plugins/hls-call-hierarchy-plugin
30+
-- ./plugins/hls-alternate-number-format-plugin
31+
-- ./plugins/hls-qualify-imported-names-plugin
32+
-- ./plugins/hls-code-range-plugin
33+
-- ./plugins/hls-change-type-signature-plugin
34+
-- ./plugins/hls-stan-plugin
35+
-- ./plugins/hls-gadt-plugin
36+
-- ./plugins/hls-explicit-fixity-plugin
37+
-- ./plugins/hls-explicit-record-fields-plugin
38+
-- ./plugins/hls-refactor-plugin
3939

4040
-- Standard location for temporary packages needed for particular environments
4141
-- For example it is used in the project gitlab mirror to help in the MAcOS M1 build script
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: false
46+
47+
48+
source-repository-package
49+
type:git
50+
location: https://github.com/wz1000/HieDb
51+
tag: e9edc2e1e2ffdd73ff33f51fad468df5237ea1b5
52+
53+
source-repository-package
54+
type:git
55+
location: https://github.com/haskell/hie-bios
56+
tag: 8519812ad7501cab31347cd46ad1312b8413b8ad
4657

4758
package *
4859
ghc-options: -haddock
4960
test-show-details: direct
5061

5162
write-ghc-environment-files: never
5263

53-
index-state: 2023-01-10T00:00:00Z
64+
index-state: 2023-01-31T00:00:00Z
5465

5566
constraints:
5667
-- For GHC 9.4, older versions of entropy fail to build on Windows
@@ -74,14 +85,18 @@ constraints:
7485
-- centos7 has an old version of git which cabal doesn't
7586
-- support. We delete these lines in gitlab ci to workaround
7687
-- this issue, as this is not necessary to build our binaries.
77-
source-repository-package
78-
type:git
79-
location: https://github.com/pepeiborra/ekg-json
80-
tag: 7a0af7a8fd38045fd15fb13445bdcc7085325460
81-
-- https://github.com/tibbe/ekg-json/pull/12
8288
-- END DELETE
8389

8490
allow-newer:
91+
-- ghc-9.6
92+
template-haskell,
93+
base,
94+
ghc-prim,
95+
ghc,
96+
ghc-boot,
97+
mtl,
98+
transformers,
99+
Cabal,
85100
-- ghc-9.4
86101
Chart-diagrams:lens,
87102
Chart:lens,
@@ -104,3 +119,14 @@ allow-newer:
104119
uuid:time,
105120
vector-space:base,
106121
ekg-wai:time,
122+
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:override

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

Lines changed: 45 additions & 24 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,13 @@ 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+
import GHC.Driver.Main (mkCgInteractiveGuts)
141+
import GHC.Unit.Home.ModInfo
142+
#endif
143+
136144
-- | Given a string buffer, return the string (after preprocessing) and the 'ParsedModule'.
137145
parseModule
138146
:: IdeOptions
@@ -467,7 +475,11 @@ mkHiFileResultNoCompile session tcm = do
467475
tcGblEnv = tmrTypechecked tcm
468476
details <- makeSimpleDetails hsc_env_tmp tcGblEnv
469477
sf <- finalSafeMode (ms_hspp_opts ms) tcGblEnv
470-
iface' <- mkIfaceTc hsc_env_tmp sf details ms tcGblEnv
478+
iface' <- mkIfaceTc hsc_env_tmp sf details ms
479+
#if MIN_VERSION_ghc(9,5,0)
480+
Nothing
481+
#endif
482+
tcGblEnv
471483
let iface = iface' { mi_globals = Nothing, mi_usages = filterUsages (mi_usages iface') } -- See Note [Clearing mi_globals after generating an iface]
472484
pure $! mkHiFileResult ms iface details (tmrRuntimeModules tcm) Nothing
473485

@@ -482,20 +494,19 @@ mkHiFileResultCompile se session' tcm simplified_guts = catchErrs $ do
482494
ms = pm_mod_summary $ tmrParsed tcm
483495
tcGblEnv = tmrTypechecked tcm
484496

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
497+
(details, guts) <- do
491498
-- write core file
492499
-- give variables unique OccNames
493500
tidy_opts <- initTidyOpts session
494501
(guts, details) <- tidyProgram tidy_opts simplified_guts
495-
pure (details, Just guts)
502+
pure (details, guts)
496503

497504
#if MIN_VERSION_ghc(9,0,1)
498-
let !partial_iface = force $ mkPartialIface session details
505+
let !partial_iface = force $ mkPartialIface session
506+
#if MIN_VERSION_ghc(9,5,0)
507+
(cg_binds guts)
508+
#endif
509+
details
499510
#if MIN_VERSION_ghc(9,3,0)
500511
ms
501512
#endif
@@ -513,9 +524,7 @@ mkHiFileResultCompile se session' tcm simplified_guts = catchErrs $ do
513524
let final_iface = final_iface' {mi_globals = Nothing, mi_usages = filterUsages (mi_usages final_iface')} -- See Note [Clearing mi_globals after generating an iface]
514525

515526
-- Write the core file now
516-
core_file <- case mguts of
517-
Nothing -> pure Nothing -- no guts, likely boot file
518-
Just guts -> do
527+
core_file <- do
519528
let core_fp = ml_core_file $ ms_location ms
520529
core_file = codeGutsToCoreFile iface_hash guts
521530
iface_hash = getModuleHash final_iface
@@ -538,27 +547,37 @@ mkHiFileResultCompile se session' tcm simplified_guts = catchErrs $ do
538547
Just (core, _) | optVerifyCoreFile -> do
539548
let core_fp = ml_core_file $ ms_location ms
540549
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
550+
let CgGuts{cg_binds = unprep_binds, cg_tycons = tycons } = guts
544551
mod = ms_mod ms
545552
data_tycons = filter isDataTyCon tycons
546553
CgGuts{cg_binds = unprep_binds'} <- coreFileToCgGuts session final_iface details core
547554

555+
#if MIN_VERSION_ghc(9,5,0)
556+
cp_cfg <- initCorePrepConfig session
557+
#endif
558+
559+
let corePrep = corePrepPgm
560+
#if MIN_VERSION_ghc(9,5,0)
561+
(hsc_logger session) cp_cfg (initCorePrepPgmConfig (hsc_dflags session) (interactiveInScope $ hsc_IC session))
562+
#else
563+
session
564+
#endif
565+
mod (ms_location ms)
566+
548567
-- Run corePrep first as we want to test the final version of the program that will
549568
-- get translated to STG/Bytecode
550569
#if MIN_VERSION_ghc(9,3,0)
551570
prepd_binds
552571
#else
553572
(prepd_binds , _)
554573
#endif
555-
<- corePrepPgm session mod (ms_location ms) unprep_binds data_tycons
574+
<- corePrep unprep_binds data_tycons
556575
#if MIN_VERSION_ghc(9,3,0)
557576
prepd_binds'
558577
#else
559578
(prepd_binds', _)
560579
#endif
561-
<- corePrepPgm session mod (ms_location ms) unprep_binds' data_tycons
580+
<- corePrep unprep_binds' data_tycons
562581
let binds = noUnfoldings $ (map flattenBinds . (:[])) $ prepd_binds
563582
binds' = noUnfoldings $ (map flattenBinds . (:[])) $ prepd_binds'
564583

@@ -683,7 +702,7 @@ generateByteCode (CoreFileTime time) hscEnv summary guts = do
683702
let session = _tweak (hscSetFlags (ms_hspp_opts summary) hscEnv)
684703
-- TODO: maybe settings ms_hspp_opts is unnecessary?
685704
summary' = summary { ms_hspp_opts = hsc_dflags session }
686-
hscInteractive session guts
705+
hscInteractive session (mkCgInteractiveGuts guts)
687706
(ms_location summary')
688707
let unlinked = BCOs bytecode sptEntries
689708
let linkable = LM time (ms_mod summary) [unlinked]
@@ -1242,7 +1261,9 @@ parseHeader
12421261
=> DynFlags -- ^ flags to use
12431262
-> FilePath -- ^ the filename (for source locations)
12441263
-> Util.StringBuffer -- ^ Haskell module source text (full Unicode is supported)
1245-
#if MIN_VERSION_ghc(9,0,1)
1264+
#if MIN_VERSION_ghc(9,5,0)
1265+
-> ExceptT [FileDiagnostic] m ([FileDiagnostic], Located(HsModule GhcPs))
1266+
#elif MIN_VERSION_ghc(9,0,1)
12461267
-> ExceptT [FileDiagnostic] m ([FileDiagnostic], Located(HsModule))
12471268
#else
12481269
-> ExceptT [FileDiagnostic] m ([FileDiagnostic], Located(HsModule GhcPs))
@@ -1574,13 +1595,13 @@ showReason (RecompBecause s) = s
15741595
mkDetailsFromIface :: HscEnv -> ModIface -> IO ModDetails
15751596
mkDetailsFromIface session iface = do
15761597
fixIO $ \details -> do
1577-
let !hsc' = hscUpdateHPT (\hpt -> addToHpt hpt (moduleName $ mi_module iface) (HomeModInfo iface details Nothing)) session
1598+
let !hsc' = hscUpdateHPT (\hpt -> addToHpt hpt (moduleName $ mi_module iface) (HomeModInfo iface details emptyHomeModInfoLinkable)) session
15781599
initIfaceLoad hsc' (typecheckIface iface)
15791600

15801601
coreFileToCgGuts :: HscEnv -> ModIface -> ModDetails -> CoreFile -> IO CgGuts
15811602
coreFileToCgGuts session iface details core_file = do
15821603
let act hpt = addToHpt hpt (moduleName this_mod)
1583-
(HomeModInfo iface details Nothing)
1604+
(HomeModInfo iface details emptyHomeModInfoLinkable)
15841605
this_mod = mi_module iface
15851606
types_var <- newIORef (md_types details)
15861607
let hsc_env' = hscUpdateHPT act (session {
@@ -1604,9 +1625,9 @@ coreFileToLinkable :: LinkableType -> HscEnv -> ModSummary -> ModIface -> ModDet
16041625
coreFileToLinkable linkableType session ms iface details core_file t = do
16051626
cgi_guts <- coreFileToCgGuts session iface details core_file
16061627
(warns, lb) <- case linkableType of
1607-
BCOLinkable -> generateByteCode (CoreFileTime t) session ms cgi_guts
1608-
ObjectLinkable -> generateObjectCode session ms cgi_guts
1609-
pure (warns, HomeModInfo iface details . Just <$> lb)
1628+
BCOLinkable -> fmap (maybe emptyHomeModInfoLinkable justBytecode) <$> generateByteCode (CoreFileTime t) session ms cgi_guts
1629+
ObjectLinkable -> fmap (maybe emptyHomeModInfoLinkable justObjects) <$> generateObjectCode session ms cgi_guts
1630+
pure (warns, Just $ HomeModInfo iface details lb) -- TODO wz1000 handle emptyHomeModInfoLinkable
16101631

16111632
-- | Non-interactive, batch version of 'InteractiveEval.getDocs'.
16121633
-- 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
@@ -62,6 +62,7 @@ module Development.IDE.Core.Rules(
6262
DisplayTHWarning(..),
6363
) where
6464

65+
import Control.Applicative
6566
import Control.Concurrent.Async (concurrently)
6667
import Control.Concurrent.Strict
6768
import Control.DeepSeq
@@ -160,6 +161,9 @@ import Control.Monad.IO.Unlift
160161
import GHC.Unit.Module.Graph
161162
import GHC.Unit.Env
162163
#endif
164+
#if MIN_VERSION_ghc(9,5,0)
165+
import GHC.Unit.Home.ModInfo
166+
#endif
163167

164168
data Log
165169
= LogShake Shake.Log
@@ -775,7 +779,7 @@ ghcSessionDepsDefinition fullModSummary GhcSessionDepsConfig{..} env file = do
775779

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

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

Lines changed: 3 additions & 0 deletions
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
@@ -42,6 +43,8 @@ addOptP f = alterToolSettings $ \s -> s
4243
doCpp :: HscEnv -> Bool -> FilePath -> FilePath -> IO ()
4344
doCpp env raw input_fn output_fn =
4445
#if MIN_VERSION_ghc (9,2,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)