Skip to content

Commit 04dafc5

Browse files
committed
lose the ghc-lib flag
1 parent ad0a154 commit 04dafc5

File tree

5 files changed

+15
-77
lines changed

5 files changed

+15
-77
lines changed

ghcide/ghcide.cabal

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ source-repository head
2727
type: git
2828
location: https://github.com/haskell/ghcide.git
2929

30-
flag ghc-lib
31-
description: build against ghc-lib instead of the ghc package
32-
default: False
33-
manual: True
34-
3530
library
3631
default-language: Haskell2010
3732
build-depends:
@@ -93,18 +88,9 @@ library
9388
heapsize ==0.3.*,
9489
unliftio,
9590
unliftio-core
96-
if flag(ghc-lib)
97-
build-depends:
98-
ghc-lib >= 8.8,
99-
ghc-lib-parser >= 8.8
100-
cpp-options: -DGHC_LIB
101-
else
102-
build-depends:
10391
ghc-boot-th,
10492
ghc-boot,
10593
ghc >= 8.6,
106-
-- These dependencies are used by Development.IDE.Session and are
107-
-- Haskell specific. So don't use them when building with -fghc-lib!
10894
ghc-check >=0.5.0.1,
10995
ghc-paths,
11096
cryptohash-sha1 >=0.11.100 && <0.12,
@@ -141,6 +127,7 @@ library
141127

142128
hs-source-dirs:
143129
src
130+
session-loader
144131
include-dirs:
145132
include
146133
exposed-modules:
@@ -168,6 +155,7 @@ library
168155
Development.IDE.LSP.LanguageServer
169156
Development.IDE.LSP.Outline
170157
Development.IDE.LSP.Server
158+
Development.IDE.Session
171159
Development.IDE.Spans.Common
172160
Development.IDE.Spans.Documentation
173161
Development.IDE.Spans.AtPoint
@@ -190,19 +178,6 @@ library
190178
Development.IDE.Plugin.Test
191179
Development.IDE.Plugin.TypeLenses
192180

193-
-- Unfortunately, we cannot use loadSession with ghc-lib since hie-bios uses
194-
-- the real GHC library and the types are incompatible. Furthermore, when
195-
-- building with ghc-lib we need to make this Haskell agnostic, so no
196-
-- hie-bios!
197-
-- We also put these modules into a separate hs-source-dirs so we can avoid
198-
-- compiling them at all if ghc-lib is not set
199-
if !flag(ghc-lib)
200-
hs-source-dirs:
201-
session-loader
202-
exposed-modules:
203-
Development.IDE.Session
204-
other-modules:
205-
Development.IDE.Session.VersionCheck
206181
other-modules:
207182
Development.IDE.Core.FileExists
208183
Development.IDE.GHC.CPP
@@ -261,8 +236,6 @@ benchmark benchHist
261236
yaml
262237

263238
executable ghcide
264-
if flag(ghc-lib)
265-
buildable: False
266239
default-language: Haskell2010
267240
include-dirs:
268241
include
@@ -322,8 +295,6 @@ executable ghcide
322295
ViewPatterns
323296

324297
test-suite ghcide-tests
325-
if flag(ghc-lib)
326-
buildable: False
327298
type: exitcode-stdio-1.0
328299
default-language: Haskell2010
329300
build-tool-depends:

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

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -636,17 +636,7 @@ getDocMapRule =
636636
(hscEnv -> hsc, _) <- useWithStale_ GhcSessionDeps file
637637
(HAR{refMap=rf}, _) <- useWithStale_ GetHieAst file
638638

639-
-- When possible, rely on the haddocks embedded in our interface files
640-
-- This creates problems on ghc-lib, see comment on 'getDocumentationTryGhc'
641-
#if !defined(GHC_LIB)
642-
let parsedDeps = []
643-
#else
644-
deps <- fromMaybe (TransitiveDependencies [] [] []) <$> use GetDependencies file
645-
let tdeps = transitiveModuleDeps deps
646-
parsedDeps <- uses_ GetParsedModule tdeps
647-
#endif
648-
649-
dkMap <- liftIO $ mkDocMap hsc parsedDeps rf tc
639+
dkMap <- liftIO $ mkDocMap hsc rf tc
650640
return ([],Just dkMap)
651641

652642
-- | Persistent rule to ensure that hover doesn't block on startup
@@ -924,7 +914,6 @@ generateCoreRule =
924914

925915
getModIfaceRule :: Rules ()
926916
getModIfaceRule = defineEarlyCutoff $ \GetModIface f -> do
927-
#if !defined(GHC_LIB)
928917
fileOfInterest <- use_ IsFileOfInterest f
929918
res@(_,(_,mhmi)) <- case fileOfInterest of
930919
IsFOI status -> do
@@ -951,13 +940,6 @@ getModIfaceRule = defineEarlyCutoff $ \GetModIface f -> do
951940
compiledLinkables <- getCompiledLinkables <$> getIdeGlobalAction
952941
liftIO $ modifyVar_ compiledLinkables $ \old -> pure $ extendModuleEnv old mod time
953942
pure res
954-
#else
955-
tm <- use_ TypeCheck f
956-
hsc <- hscEnv <$> use_ GhcSessionDeps f
957-
(diags, !hiFile) <- liftIO $ compileToObjCodeIfNeeded hsc Nothing (error "can't compile with ghc-lib") tm
958-
let fp = hiFileFingerPrint <$> hiFile
959-
return (fp, (diags, hiFile))
960-
#endif
961943

962944
getModIfaceWithoutLinkableRule :: Rules ()
963945
getModIfaceWithoutLinkableRule = defineEarlyCutoff $ \GetModIfaceWithoutLinkable f -> do

ghcide/src/Development/IDE/Plugin/Completions.hs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ import Ide.PluginUtils (getClientConfig)
3838
import Ide.Types
3939
import TcRnDriver (tcRnImportDecls)
4040
import Control.Concurrent.Async (concurrently)
41-
#if defined(GHC_LIB)
42-
import Development.IDE.Import.DependencyInformation
43-
#endif
4441

4542
descriptor :: PluginId -> PluginDescriptor IdeState
4643
descriptor plId = (defaultPluginDescriptor plId)
@@ -66,15 +63,6 @@ produceCompletions = do
6663
ms <- fmap fst <$> useWithStale GetModSummaryWithoutTimestamps file
6764
sess <- fmap fst <$> useWithStale GhcSessionDeps file
6865

69-
-- When possible, rely on the haddocks embedded in our interface files
70-
-- This creates problems on ghc-lib, see comment on 'getDocumentationTryGhc'
71-
#if !defined(GHC_LIB)
72-
let parsedDeps = []
73-
#else
74-
deps <- maybe (TransitiveDependencies [] [] []) fst <$> useWithStale GetDependencies file
75-
parsedDeps <- mapMaybe (fmap fst) <$> usesWithStale GetParsedModule (transitiveModuleDeps deps)
76-
#endif
77-
7866
case (ms, sess) of
7967
(Just (ms,imps), Just sess) -> do
8068
let env = hscEnv sess
@@ -83,7 +71,7 @@ produceCompletions = do
8371
case (global, inScope) of
8472
((_, Just globalEnv), (_, Just inScopeEnv)) -> do
8573
let uri = fromNormalizedUri $ normalizedFilePathToUri file
86-
cdata <- liftIO $ cacheDataProducer uri env (ms_mod ms) globalEnv inScopeEnv imps parsedDeps
74+
cdata <- liftIO $ cacheDataProducer uri env (ms_mod ms) globalEnv inScopeEnv imps
8775
return ([], Just cdata)
8876
(_diag, _) ->
8977
return ([], Nothing)

ghcide/src/Development/IDE/Plugin/Completions/Logic.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ mkPragmaCompl label insertText =
294294
Nothing Nothing Nothing Nothing Nothing
295295

296296

297-
cacheDataProducer :: Uri -> HscEnv -> Module -> GlobalRdrEnv-> GlobalRdrEnv -> [LImportDecl GhcPs] -> [ParsedModule] -> IO CachedCompletions
298-
cacheDataProducer uri packageState curMod globalEnv inScopeEnv limports deps = do
297+
cacheDataProducer :: Uri -> HscEnv -> Module -> GlobalRdrEnv-> GlobalRdrEnv -> [LImportDecl GhcPs] -> IO CachedCompletions
298+
cacheDataProducer uri packageState curMod globalEnv inScopeEnv limports = do
299299
let dflags = hsc_dflags packageState
300300
curModName = moduleName curMod
301301

@@ -344,7 +344,7 @@ cacheDataProducer uri packageState curMod globalEnv inScopeEnv limports deps = d
344344

345345
toCompItem :: Parent -> Module -> ModuleName -> Name -> Maybe (LImportDecl GhcPs) -> IO [CompItem]
346346
toCompItem par m mn n imp' = do
347-
docs <- getDocumentationTryGhc packageState curMod deps n
347+
docs <- getDocumentationTryGhc packageState curMod n
348348
let (mbParent, originName) = case par of
349349
NoParent -> (Nothing, nameOccName n)
350350
ParentIs n' -> (Just $ showNameWithoutUniques n', nameOccName n)

ghcide/src/Development/IDE/Spans/Documentation.hs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,10 @@ import HscTypes (HscEnv(hsc_dflags))
4343

4444
mkDocMap
4545
:: HscEnv
46-
-> [ParsedModule]
4746
-> RefMap a
4847
-> TcGblEnv
4948
-> IO DocAndKindMap
50-
mkDocMap env sources rm this_mod =
49+
mkDocMap env rm this_mod =
5150
do let (_ , DeclDocMap this_docs, _) = extractDocs this_mod
5251
d <- foldrM getDocs (mkNameEnv $ M.toList $ fmap (`SpanDocString` SpanDocUris Nothing Nothing) this_docs) names
5352
k <- foldrM getType (tcg_type_env this_mod) names
@@ -56,7 +55,7 @@ mkDocMap env sources rm this_mod =
5655
getDocs n map
5756
| maybe True (mod ==) $ nameModule_maybe n = pure map -- we already have the docs in this_docs, or they do not exist
5857
| otherwise = do
59-
doc <- getDocumentationTryGhc env mod sources n
58+
doc <- getDocumentationTryGhc env mod n
6059
pure $ extendNameEnv map n doc
6160
getType n map
6261
| isTcOcc $ occName n = do
@@ -71,23 +70,21 @@ lookupKind :: HscEnv -> Module -> Name -> IO (Maybe TyThing)
7170
lookupKind env mod =
7271
fmap (fromRight Nothing) . catchSrcErrors (hsc_dflags env) "span" . lookupName env mod
7372

74-
getDocumentationTryGhc :: HscEnv -> Module -> [ParsedModule] -> Name -> IO SpanDoc
75-
getDocumentationTryGhc env mod deps n = head <$> getDocumentationsTryGhc env mod deps [n]
73+
getDocumentationTryGhc :: HscEnv -> Module -> Name -> IO SpanDoc
74+
getDocumentationTryGhc env mod n = head <$> getDocumentationsTryGhc env mod [n]
7675

77-
getDocumentationsTryGhc :: HscEnv -> Module -> [ParsedModule] -> [Name] -> IO [SpanDoc]
78-
-- Interfaces are only generated for GHC >= 8.6.
79-
-- In older versions, interface files do not embed Haddocks anyway
80-
getDocumentationsTryGhc env mod sources names = do
76+
getDocumentationsTryGhc :: HscEnv -> Module -> [Name] -> IO [SpanDoc]
77+
getDocumentationsTryGhc env mod names = do
8178
res <- catchSrcErrors (hsc_dflags env) "docs" $ getDocsBatch env mod names
8279
case res of
83-
Left _ -> mapM mkSpanDocText names
80+
Left _ -> return []
8481
Right res -> zipWithM unwrap res names
8582
where
8683
unwrap (Right (Just docs, _)) n = SpanDocString docs <$> getUris n
8784
unwrap _ n = mkSpanDocText n
8885

8986
mkSpanDocText name =
90-
SpanDocText (getDocumentation sources name) <$> getUris name
87+
SpanDocText [] <$> getUris name
9188

9289
-- Get the uris to the documentation and source html pages if they exist
9390
getUris name = do

0 commit comments

Comments
 (0)