Skip to content

Commit

Permalink
initial support for ghc-9.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
shayne-fletcher committed Oct 11, 2024
1 parent ad20856 commit 5dbcf78
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/hlint-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: [GHC_8_8, GHC_8_10, GHC_9_0, GHC_9_2, GHC_9_4, GHC_9_6, GHC_9_8, GHC_9_10, GHC_9_12]
version: [GHC_8_8, GHC_8_10, GHC_9_0, GHC_9_2, GHC_9_4, GHC_9_6, GHC_9_8, GHC_9_10, GHC_9_12, GHC_9_14]
steps:
- uses: actions/checkout@v4
- uses: haskell-actions/hlint-setup@v2
Expand Down
7 changes: 6 additions & 1 deletion CI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ data Options = Options
data GhcFlavor
= Da DaFlavor
| GhcMaster String
| Ghc9121
| Ghc9101
| Ghc982
| Ghc981
Expand Down Expand Up @@ -96,10 +97,11 @@ data DaFlavor = DaFlavor

-- Last tested gitlab.haskell.org/ghc/ghc.git at
current :: String
current = "1deba6b25f9b5bc4bc0bdb17431998cfcb47bac4" -- 2024-08-18
current = "ef481813719c5f6d9d97b60ffef4617307d24c80" -- 2024-10-10

ghcFlavorOpt :: GhcFlavor -> String
ghcFlavorOpt = \case
Ghc9121 -> "--ghc-flavor ghc-9.12.1"
Ghc9101 -> "--ghc-flavor ghc-9.10.1"
Ghc982 -> "--ghc-flavor ghc-9.8.2"
Ghc981 -> "--ghc-flavor ghc-9.8.1"
Expand Down Expand Up @@ -162,6 +164,7 @@ genVersionStr flavor suffix =
base = case flavor of
Da {} -> "8.8.1"
GhcMaster _ -> "0"
Ghc9121 -> "9.12.1"
Ghc9101 -> "9.10.1"
Ghc982 -> "9.8.2"
Ghc981 -> "9.8.1"
Expand Down Expand Up @@ -228,6 +231,7 @@ parseOptions =
where
readFlavor :: Opts.ReadM GhcFlavor
readFlavor = Opts.eitherReader $ \case
"ghc-9.12.1" -> Right Ghc9121
"ghc-9.10.1" -> Right Ghc9101
"ghc-9.8.2" -> Right Ghc982
"ghc-9.8.1" -> Right Ghc981
Expand Down Expand Up @@ -486,6 +490,7 @@ buildDists ghcFlavor noGhcCheckout noBuilds versionSuffix = do

branch :: GhcFlavor -> String
branch = \case
Ghc9121 -> "ghc-9.12"
Ghc9101 -> "ghc-9.10.1-release"
Ghc982 -> "ghc-9.8.2-release"
Ghc981 -> "ghc-9.8.1-release"
Expand Down
8 changes: 6 additions & 2 deletions examples/ghc-lib-test-mini-compile/src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ module Main (main) where

-- We use 0.x for HEAD
#if !MIN_VERSION_ghc_lib(1,0,0)
# define GHC_9_14
# include "ghc-lib-parser/ghc-9.14/Main.hs"
# include "ghc-lib/ghc-9.14/Main.hs"
#elif MIN_VERSION_ghc_lib(9,12,0)
# define GHC_9_12
# include "ghc-lib-parser/ghc-9.12/Main.hs"
# include "ghc-lib/ghc-9.12/Main.hs"
Expand Down Expand Up @@ -219,7 +223,7 @@ fakeLlvmConfig :: LlvmConfig
fakeLlvmConfig = LlvmConfig [] []

#else
{- defined (GHC_9_6) || defined (GHC_9_8) || defined (GHC_9_10) || defined (GHC_9_12) -}
{- defined (GHC_9_6) || defined (GHC_9_8) || defined (GHC_9_10) || defined (GHC_9_12) || defined (GHC_9_14) -}

#endif

Expand Down Expand Up @@ -391,7 +395,7 @@ fakeSettings = Settings {
platform = genericPlatform

#else
{- defined (GHC_9_4) || defined (GHC_9_6) || defined (GHC_9_8) || defined (GHC_9_10) || defined (GHC_9_12) -}
{- defined (GHC_9_4) || defined (GHC_9_6) || defined (GHC_9_8) || defined (GHC_9_10) || defined (GHC_9_12) || defined (GHC_9_14) -}

sGhcNameVersion=ghcNameVersion
, sFileSettings=fileSettings
Expand Down
19 changes: 11 additions & 8 deletions examples/ghc-lib-test-mini-hlint/src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ module Main (main) where

-- We use 0.x for HEAD
#if !MIN_VERSION_ghc_lib_parser(1,0,0)
# define GHC_9_14
# include "ghc-9.14/Main.hs"
#elif MIN_VERSION_ghc_lib_parser(9,12,0)
# define GHC_9_12
# include "ghc-9.12/Main.hs"
#elif MIN_VERSION_ghc_lib_parser(9,10,0)
Expand Down Expand Up @@ -83,7 +86,7 @@ parse filename flags str = unP GHC.Parser.parseModule parseState
parseState = initParserState (initParserOpts flags) buffer location

#else
{- defined (GHC_9_6) || defined (GHC_9_8) || defined (GHC_9_10) || defined (GHC_9_12) -}
{- defined (GHC_9_6) || defined (GHC_9_8) || defined (GHC_9_10) || defined (GHC_9_12) || defined (GHC_9_14) -}

parse :: String -> DynFlags -> String -> ParseResult (Located (HsModule GhcPs))
parse filename flags str = unP GHC.Parser.parseModule parseState
Expand Down Expand Up @@ -179,7 +182,7 @@ parsePragmasIntoDynFlags flags filepath str =
where
sDocs = [ showSDoc flags msg | msg <- pprMsgEnvelopeBagWithLocDefault . getMessages $ srcErrorMessages msgs ]
#else
{- defined (GHC_9_8) || defined (GHC_9_10) || defined (GHC_9_12) -}
{- defined (GHC_9_8) || defined (GHC_9_10) || defined (GHC_9_12) || defined (GHC_9_14) -}

catchErrors $ do
let (_, opts) = getOptions (initParserOpts flags)
Expand Down Expand Up @@ -218,7 +221,7 @@ isNegated (HsPar _ _ (L _ e) _ ) = isNegated e
isNegated _ = False

#else
{- defined (GHC_9_10) || defined (GHC_9_12) -}
{- defined (GHC_9_10) || defined (GHC_9_12) || defined (GHC_9_14) -}

isNegated (HsApp _ (L _ (HsVar _ (L _ id))) _) = id == idNot
isNegated (HsPar _ (L _ e)) = isNegated e
Expand All @@ -239,7 +242,7 @@ analyzeExpr flags (L loc expr) = do
_ -> return ()

#else
{- defined (GHC_9_2) || defined (GHC_9_4) || defined (GHC_9_6) || defined (GHC_9_8) || defined (GHC_9_10) || defined (GHC_9_12) -}
{- defined (GHC_9_2) || defined (GHC_9_4) || defined (GHC_9_6) || defined (GHC_9_8) || defined (GHC_9_10) || defined (GHC_9_12) || defined (GHC_9_14) -}

analyzeExpr :: DynFlags -> LocatedA (HsExpr GhcPs) -> IO ()
analyzeExpr flags (L loc expr) = do
Expand Down Expand Up @@ -268,7 +271,7 @@ analyzeModule :: DynFlags -> Located HsModule -> IO ()
analyzeModule flags (L _ modu) = sequence_ [analyzeExpr flags e | e <- universeBi modu]

#else
{- defined (GHC_9_6) || defined (GHC_9_8) || defined (GHC_9_10 ) || defined (GHC_9_12) -}
{- defined (GHC_9_6) || defined (GHC_9_8) || defined (GHC_9_10 ) || defined (GHC_9_12) || defined (GHC_9_14) -}

analyzeModule :: DynFlags -> Located (HsModule GhcPs) -> IO ()
analyzeModule flags (L _ modu) = sequence_ [analyzeExpr flags e | e <- universeBi modu]
Expand Down Expand Up @@ -428,7 +431,7 @@ main = do
printMessages logger opts msgs

#else
{- defined (GHC_9_6) || defined (GHC_9_8) || defined (GHC_9_10) || defined (GHC_9_12) -}
{- defined (GHC_9_6) || defined (GHC_9_8) || defined (GHC_9_10) || defined (GHC_9_12) || defined (GHC_9_14) -}

main :: IO ()
main = do
Expand Down Expand Up @@ -467,7 +470,7 @@ fakeLlvmConfig :: LlvmConfig
fakeLlvmConfig = LlvmConfig [] []

#else
{- defined (GHC_9_6) || defined (GHC_9_8) || defined (GHC_9_10 ) || defined (GHC_9_12) -}
{- defined (GHC_9_6) || defined (GHC_9_8) || defined (GHC_9_10 ) || defined (GHC_9_12) || defined (GHC_9_14) -}

#endif

Expand Down Expand Up @@ -629,7 +632,7 @@ fakeSettings = Settings {
platform=genericPlatform

#else
{- defined (GHC_9_4) || defined (GHC_9_6) || defined (GHC_9_8) || defined (GHC_9_10) || defined (GHC_9_12) -}
{- defined (GHC_9_4) || defined (GHC_9_6) || defined (GHC_9_8) || defined (GHC_9_10) || defined (GHC_9_12) || defined (GHC_9_14) -}

sGhcNameVersion=ghcNameVersion
, sFileSettings=fileSettings
Expand Down
4 changes: 4 additions & 0 deletions examples/ghc-lib-test-utils/src/TestUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ data GhcVersion
| Ghc981
| Ghc982
| Ghc9101
| Ghc9121
| GhcMaster
deriving (Eq, Ord, Typeable)

Expand All @@ -66,6 +67,7 @@ instance Show GhcVersion where

showGhcVersion :: GhcVersion -> String
showGhcVersion = \case
Ghc9121 -> "ghc-9.12.1"
Ghc9101 -> "ghc-9.10.1"
Ghc982 -> "ghc-9.8.2"
Ghc981 -> "ghc-9.8.1"
Expand Down Expand Up @@ -105,6 +107,8 @@ readFlavor =
(GhcFlavor <$>) . \case
-- HEAD
"ghc-master" -> Just GhcMaster
-- ghc-9.12
"ghc-9.12.1" -> Just Ghc9121
-- ghc-9.10
"ghc-9.10.1" -> Just Ghc9101
-- ghc-9.8
Expand Down
29 changes: 29 additions & 0 deletions ghc-lib-gen/ghc-lib-parser/ghc-9.14/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import GHC.Data.FastString
import GHC.Data.StringBuffer
import GHC.Driver.Config
import GHC.Driver.Config.Diagnostic
import GHC.Driver.Config.Parser
import GHC.Driver.Errors
import GHC.Driver.Errors.Types
import GHC.Driver.Ppr
import GHC.Driver.Session
import GHC.Hs
import GHC.Hs.Dump
import GHC.Parser
import GHC.Parser.Annotation
import GHC.Parser.Errors.Ppr
import GHC.Parser.Header
import GHC.Parser.Lexer
import GHC.Platform
import GHC.Settings
import GHC.Settings.Config
import GHC.Types.Error
import GHC.Types.Name.Reader
import GHC.Types.SourceError
import GHC.Types.SrcLoc
import GHC.Unit.Types
import GHC.Utils.Error
import GHC.Utils.Fingerprint
import GHC.Utils.Logger
import GHC.Utils.Outputable
import GHC.Utils.Panic
1 change: 1 addition & 0 deletions ghc-lib-gen/ghc-lib/ghc-9.14/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import GHC
7 changes: 5 additions & 2 deletions ghc-lib-gen/src/Ghclibgen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ ghcLibHsSrcDirs forDepends ghcFlavor lib =
GHC_9_8 -> ["libraries/template-haskell", "libraries/ghc-boot-th", "libraries/ghc-boot", "libraries/ghc-heap", "libraries/ghc-platform/src", "libraries/ghc-platform"]
GHC_9_10 -> ["libraries/template-haskell", "libraries/ghc-boot-th", "libraries/ghc-boot", "libraries/ghc-heap", "libraries/ghc-platform/src", "libraries/ghc-platform", "libraries/ghci"]
GHC_9_12 -> ["libraries/template-haskell", "libraries/ghc-boot-th", "libraries/ghc-boot", "libraries/ghc-heap", "libraries/ghc-platform/src", "libraries/ghc-platform", "libraries/ghci", "libraries/ghc-internal/src"]
GHC_9_14 -> ["libraries/template-haskell", "libraries/ghc-boot-th", "libraries/ghc-boot", "libraries/ghc-heap", "libraries/ghc-platform/src", "libraries/ghc-platform", "libraries/ghci", "libraries/ghc-internal/src"]
in sortDiffListByLength all $ Set.fromList [dir | not forDepends, dir <- exclusions]

-- File path constants.
Expand Down Expand Up @@ -1166,6 +1167,8 @@ baseBounds = \case
Ghc982 -> "base >= 4.17 && < 4.20" -- [ghc-9.4.1, ghc-9.10.1)
-- base-4.20.0.0
Ghc9101 -> "base >= 4.18 && < 4.21" -- [ghc-9.6.1, ghc-9.12.1)
-- base-4.20.0.0 TODO bump
Ghc9121 -> "base >= 4.18 && < 4.21" -- [ghc-9.6.1, ghc-9.12.1)
GhcMaster ->
-- e.g. "9.11.20230119"
-- (c.f. 'rts/include/ghcversion.h')
Expand All @@ -1179,11 +1182,11 @@ commonBuildDepends ghcFlavor =
-- base
base = [baseBounds ghcFlavor]
specific
| ghcSeries ghcFlavor > GHC_9_10 =
| ghcSeries ghcFlavor >= GHC_9_12 =
[ "ghc-prim > 0.2 && < 0.12",
"containers >= 0.6.2.1 && < 0.8",
"bytestring >= 0.11.4 && < 0.13",
"time >= 1.4 && < 1.13",
"time >= 1.4 && < 1.15",
"filepath >= 1.5 && < 1.6",
"os-string >= 2.0.1 && < 2.1"
]
Expand Down
9 changes: 6 additions & 3 deletions ghc-lib-gen/src/GhclibgenFlavor.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ data GhcFlavor
| Ghc981
| Ghc982
| Ghc9101
| Ghc9121
| GhcMaster
deriving (Show, Eq, Ord)

data GhcSeries = GHC_8_8 | GHC_8_10 | GHC_9_0 | GHC_9_2 | GHC_9_4 | GHC_9_6 | GHC_9_8 | GHC_9_10 | GHC_9_12
data GhcSeries = GHC_8_8 | GHC_8_10 | GHC_9_0 | GHC_9_2 | GHC_9_4 | GHC_9_6 | GHC_9_8 | GHC_9_10 | GHC_9_12 | GHC_9_14
deriving (Eq, Ord)

instance Show GhcSeries where
show = \case
GHC_9_14 -> "ghc-9.14"
GHC_9_12 -> "ghc-9.12"
GHC_9_10 -> "ghc-9.10"
GHC_9_8 -> "ghc-9.8"
Expand All @@ -77,6 +79,7 @@ ghcSeries = \case
f | Ghc941 <= f && f < Ghc961 -> GHC_9_4
f | Ghc961 <= f && f < Ghc981 -> GHC_9_6
f | Ghc981 <= f && f < Ghc9101 -> GHC_9_8
f | Ghc9101 <= f && f < GhcMaster -> GHC_9_10
GhcMaster -> GHC_9_12
f | Ghc9101 <= f && f < Ghc9121 -> GHC_9_10
f | Ghc9121 <= f && f < GhcMaster -> GHC_9_12
GhcMaster -> GHC_9_14
_ -> error "ghcSeries: impossible case"
2 changes: 2 additions & 0 deletions ghc-lib-gen/src/GhclibgenOpts.hs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ readFlavor :: ReadM GhcFlavor
readFlavor = eitherReader $ \case
-- HEAD
"ghc-master" -> Right GhcMaster
-- ghc-9.12
"ghc-9.12.1" -> Right Ghc9121
-- ghc-9.10
"ghc-9.10.1" -> Right Ghc9101
-- ghc-9.8
Expand Down

0 comments on commit 5dbcf78

Please sign in to comment.