Skip to content

Commit 7959f28

Browse files
committed
Make hiedb-indexer build with GHC 9.4.x
1 parent b562b0e commit 7959f28

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ jobs:
171171
- name: Build glean-clang
172172
run: make glean-clang
173173

174-
- if: matrix.ghc != '8.6.5' && matrix.ghc != '9.4.7'
174+
- if: matrix.ghc != '8.6.5'
175175
name: Build hiedb-indexer
176176
run: make glean-hiedb
177177

glean.cabal.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ executable hack-derive
10951095
-- Haskell indexer via hiedb
10961096
executable hiedb-indexer
10971097
import: deps, fb-haskell, exe
1098-
if impl(ghc >= 8.8 && < 9.4)
1098+
if impl(ghc >= 8.8)
10991099
buildable: True
11001100
else
11011101
buildable: False

glean/lang/haskell/HieDBIndexer/Builder.hs

+11-4
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@ import Database.SQLite.Simple (
4747
queryNamed,
4848
)
4949
#if __GLASGOW_HASKELL__ >= 902
50+
#if __GLASGOW_HASKELL__ < 904
5051
import Data.IORef
5152
import GHC.Plugins (mkSplitUniqSupply)
52-
import GHC.Iface.Ext.Binary (HieFileResult (hie_file_result), readHieFile,
53-
NameCacheUpdater(..))
54-
import GHC.Iface.Env (updNameCache)
53+
import GHC.Iface.Ext.Env (updNameCache)
54+
#endif
55+
import GHC.Iface.Ext.Binary
5556
import GHC.Iface.Ext.Types (HieFile (..))
5657
import GHC.Unit.Module.Name (moduleNameString)
5758
import GHC.Types.Name.Cache (NameCache, initNameCache)
@@ -166,8 +167,12 @@ mkFileLinesMap ::
166167
[Vertex] ->
167168
IO (FileLineMap, FileLineMap)
168169
mkFileLinesMap logger allVertices = traceMsg logger "mkFileLinesMap" $ do
170+
#if MIN_VERSION_ghc(9,4,0)
171+
nc <- initNameCache 'z' []
172+
#else
169173
uniqSupply <- mkSplitUniqSupply 'z'
170174
let nc = initNameCache uniqSupply []
175+
#endif
171176
bothLineMaps <-
172177
catMaybes <$> mapM (mkLineLengths logger nc) filepathsSet
173178
let fileLinesSumMap =
@@ -239,10 +244,12 @@ mkLineLengths logger nc (srcFp, hieFp) = handle exHandler $ do
239244
sourceFileLineLengths ::
240245
NameCache -> FilePath -> IO [Int]
241246
sourceFileLineLengths nc hieFp = do
242-
#if __GLASGOW_HASKELL__ >= 902
247+
#if __GLASGOW_HASKELL__ == 902
243248
ref <- newIORef nc
244249
let ncu = NCU (updNameCache ref)
245250
srcContent <- hie_hs_src . hie_file_result <$> readHieFile ncu hieFp
251+
#elif __GLASGOW_HASKELL__ >= 904
252+
srcContent <- hie_hs_src . hie_file_result <$> readHieFile nc hieFp
246253
#else
247254
srcContent <- hie_hs_src . hie_file_result . fst <$> readHieFile nc hieFp
248255
#endif

glean/lang/haskell/HieDBIndexer/HieDB.hs

+4
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,12 @@ mkHieDB pathsToIndex hiedbOptions =
6868
doIndex :: Foldable t => HieDb -> t FilePath -> IO ()
6969
doIndex db files =
7070
withTransaction (getConn db) $ do
71+
#if MIN_VERSION_ghc(9,4,0)
72+
nc <- newIORef =<< initNameCache 'c' []
73+
#else
7174
u <- mkSplitUniqSupply 'c'
7275
nc <- newIORef $ initNameCache u []
76+
#endif
7377
forM_ files $ \f -> do
7478
fc <- canonicalizePath f
7579
hash <- getFileHash f

0 commit comments

Comments
 (0)