Skip to content

Commit

Permalink
Add support for GHC 9.10 and drop support for GHC 9.4 (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
arybczak authored May 19, 2024
1 parent 5d7cee5 commit 62d7249
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 55 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.17.20240109
# version: 0.19.20240514
#
# REGENDATA ("0.17.20240109",["github","--config=cabal.haskell-ci","cabal.project"])
# REGENDATA ("0.19.20240514",["github","--config=cabal.haskell-ci","cabal.project"])
#
name: Haskell-CI
on:
Expand All @@ -27,24 +27,24 @@ jobs:
timeout-minutes:
60
container:
image: buildpack-deps:bionic
image: buildpack-deps:jammy
continue-on-error: ${{ matrix.allow-failure }}
strategy:
matrix:
include:
- compiler: ghc-9.8.1
- compiler: ghc-9.10.1
compilerKind: ghc
compilerVersion: 9.8.1
compilerVersion: 9.10.1
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.6.4
- compiler: ghc-9.8.2
compilerKind: ghc
compilerVersion: 9.6.4
compilerVersion: 9.8.2
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.4.8
- compiler: ghc-9.6.5
compilerKind: ghc
compilerVersion: 9.4.8
compilerVersion: 9.6.5
setup-method: ghcup
allow-failure: false
fail-fast: false
Expand Down Expand Up @@ -132,7 +132,7 @@ jobs:
chmod a+x $HOME/.cabal/bin/cabal-plan
cabal-plan --version
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: source
- name: initial cabal.project for sdist
Expand Down Expand Up @@ -167,7 +167,7 @@ jobs:
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
cabal-plan
- name: restore cache
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
path: ~/.cabal/store
Expand All @@ -194,7 +194,7 @@ jobs:
rm -f cabal.project.local
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
- name: save cache
uses: actions/cache/save@v3
uses: actions/cache/save@v4
if: always()
with:
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# ghc-tags-1.9 (2024-??-??)
* Add support for GHC 9.10 and drop support for GHC 9.4.

# ghc-tags-1.8 (2024-01-24)
* Add support for GHC 9.8 and drop support for GHC 9.2.

Expand Down
10 changes: 5 additions & 5 deletions ghc-tags.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: ghc-tags
version: 1.8
version: 1.9
synopsis: Utility for generating ctags and etags with GHC API.
description: Utility for generating etags (Emacs) and ctags (Vim and other
editors) with GHC API for efficient project navigation.
Expand All @@ -14,7 +14,7 @@ extra-source-files: CHANGELOG.md
README.md
homepage: https://github.com/arybczak/ghc-tags
bug-reports: https://github.com/arybczak/ghc-tags/issues
tested-with: GHC == { 9.4.8, 9.6.4, 9.8.1 }
tested-with: GHC == { 9.6.5, 9.8.2, 9.10.1 }

source-repository head
type: git
Expand All @@ -28,12 +28,12 @@ flag ghc-lib
executable ghc-tags
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-A4m

if !flag(ghc-lib) && impl(ghc == 9.8.*)
if !flag(ghc-lib) && impl(ghc == 9.10.*)
build-depends: ghc, ghc-boot
else
build-depends: ghc-lib == 9.8.*
build-depends: ghc-lib == 9.10.*

build-depends: base >=4.17 && <4.20
build-depends: base >=4.18 && <4.21
, aeson >= 2.0.0.0
, async
, attoparsec
Expand Down
24 changes: 12 additions & 12 deletions src/GhcTags/Ghc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ isMemberExported (Just ies) memberName className = any go ies
where
go :: IE GhcPs -> Bool

go (IEVar _ (L _ n)) = ieWrappedName n == unLoc memberName
go (IEVar _ (L _ n) _) = ieWrappedName n == unLoc memberName

go (IEThingAbs _ _) = False
go (IEThingAbs _ _ _) = False

go (IEThingAll _ (L _ n)) = ieWrappedName n == unLoc className
go (IEThingAll _ (L _ n) _) = ieWrappedName n == unLoc className

go (IEThingWith _ _ IEWildcard{} _) = True
go (IEThingWith _ _ IEWildcard{} _ _) = True

go (IEThingWith _ (L _ n) NoIEWildcard ns) =
go (IEThingWith _ (L _ n) NoIEWildcard ns _) =
ieWrappedName n == unLoc className
&& isInWrappedNames
where
Expand All @@ -117,19 +117,19 @@ mkGhcTag :: LocatedN RdrName
-> Bool
-- ^ is term exported
-> GhcTag
mkGhcTag (L SrcSpanAnn { locA = gtSrcSpan } rdrName) gtKind gtIsExported =
mkGhcTag (L loc rdrName) gtKind gtIsExported =
case rdrName of
Unqual occName ->
GhcTag { gtTag = bytesFS (occNameFS occName)
, gtSrcSpan
, gtSrcSpan = getHasLoc loc
, gtKind
, gtIsExported
, gtFFI = Nothing
}

Qual _ occName ->
GhcTag { gtTag = bytesFS (occNameFS occName)
, gtSrcSpan
, gtSrcSpan = getHasLoc loc
, gtKind
, gtIsExported
, gtFFI = Nothing
Expand All @@ -138,15 +138,15 @@ mkGhcTag (L SrcSpanAnn { locA = gtSrcSpan } rdrName) gtKind gtIsExported =
-- Orig is the only one we are interested in
Orig _ occName ->
GhcTag { gtTag = bytesFS (occNameFS occName)
, gtSrcSpan
, gtSrcSpan = getHasLoc loc
, gtKind
, gtIsExported
, gtFFI = Nothing
}

Exact eName ->
GhcTag { gtTag = bytesFS (occNameFS (nameOccName eName))
, gtSrcSpan
, gtSrcSpan = getHasLoc loc
, gtKind
, gtIsExported
, gtFFI = Nothing
Expand Down Expand Up @@ -225,7 +225,7 @@ hsDeclsToGhcTags mies = foldr go []
-- Main routine which traverse all top level declarations.
--
go :: LHsDecl GhcPs -> [GhcTag] -> [GhcTag]
go (L SrcSpanAnn { locA = decLoc } hsDecl) tags = case hsDecl of
go (L loc hsDecl) tags = let decLoc = getHasLoc loc in case hsDecl of

-- type or class declaration
TyClD _ tyClDecl ->
Expand Down Expand Up @@ -397,7 +397,7 @@ hsDeclsToGhcTags mies = foldr go []
-> LocatedN RdrName
-> HsConDeclGADTDetails GhcPs
-> [GhcTag]
mkHsConDeclGADTDetails decLoc tyName (RecConGADT (L _ fields) _) =
mkHsConDeclGADTDetails decLoc tyName (RecConGADT _ (L _ fields)) =
foldr f [] fields
where
f :: LConDeclField GhcPs -> [GhcTag] -> [GhcTag]
Expand Down
28 changes: 2 additions & 26 deletions src/GhcTags/GhcCompat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,14 @@ runGhc :: Ghc a -> IO a
runGhc m = do
env <- liftIO $ do
mySettings <- compatInitSettings libdir
dflags <- threadSafeInitDynFlags (defaultDynFlags mySettings)
newHscEnv libdir dflags
tmpdir <- liftIO getTemporaryDirectory
newHscEnv libdir $ (defaultDynFlags mySettings) { tmpDir = TempDir tmpdir }
ref <- newIORef env
unGhc (GHC.withCleanupSession m) (Session ref)

----------------------------------------
-- Internal

-- | Adjusted version of 'GHC.Driver.Session.initDynFlags' that doesn't check
-- for colors as it's not thread safe.
threadSafeInitDynFlags :: DynFlags -> IO DynFlags
threadSafeInitDynFlags dflags = do
refRtldInfo <- newIORef Nothing
refRtccInfo <- newIORef Nothing
tmpdir <- liftIO getTemporaryDirectory
pure dflags
{ rtldInfo = refRtldInfo
, rtccInfo = refRtccInfo
, tmpDir = TempDir tmpdir
}

-- | Stripped version of 'GHC.Settings.IO.initSettings' that ignores the
-- @platformConstants@ file as it's irrelevant for parsing.
compatInitSettings :: FilePath -> IO Settings
Expand Down Expand Up @@ -146,16 +133,10 @@ compatInitSettings top_dir = do
install_name_tool_path <- getToolSetting "install_name_tool command"
ranlib_path <- getToolSetting "ranlib command"

touch_path <- getToolSetting "touch command"

mkdll_prog <- getToolSetting "dllwrap command"
let mkdll_args = []

-- cpp is derived from gcc on all platforms
-- HACK, see setPgmP below. We keep 'words' here to remember to fix
-- Config.hs one day.


-- Other things being equal, as and ld are simply gcc
cc_link_args_str <- getSetting "C compiler link flags"
let as_prog = cc_prog
Expand All @@ -171,7 +152,6 @@ compatInitSettings top_dir = do
-- We just assume on command line
lc_prog <- getSetting "LLVM llc command"
lo_prog <- getSetting "LLVM opt command"
lcc_prog <- getSetting "LLVM clang command"

let iserv_prog = libexec "ghc-iserv"

Expand Down Expand Up @@ -202,16 +182,13 @@ compatInitSettings top_dir = do
, toolSettings_pgm_a = (as_prog, as_args)
, toolSettings_pgm_l = (ld_prog, ld_args)
, toolSettings_pgm_lm = ld_r
, toolSettings_pgm_dll = (mkdll_prog,mkdll_args)
, toolSettings_pgm_T = touch_path
, toolSettings_pgm_windres = windres_path
, toolSettings_pgm_ar = ar_path
, toolSettings_pgm_otool = otool_path
, toolSettings_pgm_install_name_tool = install_name_tool_path
, toolSettings_pgm_ranlib = ranlib_path
, toolSettings_pgm_lo = (lo_prog,[])
, toolSettings_pgm_lc = (lc_prog,[])
, toolSettings_pgm_lcc = (lcc_prog,[])
, toolSettings_pgm_i = iserv_prog
, toolSettings_opt_L = []
, toolSettings_opt_P = []
Expand All @@ -223,7 +200,6 @@ compatInitSettings top_dir = do
, toolSettings_opt_l = []
, toolSettings_opt_lm = []
, toolSettings_opt_windres = []
, toolSettings_opt_lcc = []
, toolSettings_opt_lo = []
, toolSettings_opt_lc = []
, toolSettings_opt_i = []
Expand Down

0 comments on commit 62d7249

Please sign in to comment.