From 4298fd39bdab9673b6024eb18e30c41dd671d2f1 Mon Sep 17 00:00:00 2001 From: Shayne Fletcher Date: Mon, 14 Oct 2024 05:42:46 -0400 Subject: [PATCH] initial support for ghc-9.12.1 (#560) --- .github/workflows/hlint-check.yml | 2 +- CI.hs | 7 ++++- .../ghc-lib-test-mini-compile/src/Main.hs | 8 +++-- examples/ghc-lib-test-mini-hlint/src/Main.hs | 19 +++++++----- examples/ghc-lib-test-utils/src/TestUtils.hs | 4 +++ ghc-lib-gen/ghc-lib-parser/ghc-9.14/Main.hs | 29 +++++++++++++++++++ ghc-lib-gen/ghc-lib/ghc-9.14/Main.hs | 1 + ghc-lib-gen/src/Ghclibgen.hs | 7 +++-- ghc-lib-gen/src/GhclibgenFlavor.hs | 9 ++++-- ghc-lib-gen/src/GhclibgenOpts.hs | 2 ++ 10 files changed, 71 insertions(+), 17 deletions(-) create mode 100644 ghc-lib-gen/ghc-lib-parser/ghc-9.14/Main.hs create mode 100644 ghc-lib-gen/ghc-lib/ghc-9.14/Main.hs diff --git a/.github/workflows/hlint-check.yml b/.github/workflows/hlint-check.yml index 351f335c..57c62bbb 100644 --- a/.github/workflows/hlint-check.yml +++ b/.github/workflows/hlint-check.yml @@ -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 diff --git a/CI.hs b/CI.hs index e25a40f5..c3d89c15 100755 --- a/CI.hs +++ b/CI.hs @@ -45,6 +45,7 @@ data Options = Options data GhcFlavor = Da DaFlavor | GhcMaster String + | Ghc9121 | Ghc9101 | Ghc982 | Ghc981 @@ -96,10 +97,11 @@ data DaFlavor = DaFlavor -- Last tested gitlab.haskell.org/ghc/ghc.git at current :: String -current = "1deba6b25f9b5bc4bc0bdb17431998cfcb47bac4" -- 2024-08-18 +current = "c08b68bc7ab947843d20621eb483a0fc3c42703a" -- 2024-10-12 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" @@ -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" @@ -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 @@ -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" diff --git a/examples/ghc-lib-test-mini-compile/src/Main.hs b/examples/ghc-lib-test-mini-compile/src/Main.hs index 40310264..3b1d7bc3 100644 --- a/examples/ghc-lib-test-mini-compile/src/Main.hs +++ b/examples/ghc-lib-test-mini-compile/src/Main.hs @@ -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" @@ -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 @@ -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 diff --git a/examples/ghc-lib-test-mini-hlint/src/Main.hs b/examples/ghc-lib-test-mini-hlint/src/Main.hs index 5e50b034..40de391a 100644 --- a/examples/ghc-lib-test-mini-hlint/src/Main.hs +++ b/examples/ghc-lib-test-mini-hlint/src/Main.hs @@ -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) @@ -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 @@ -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) @@ -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 @@ -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 @@ -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] @@ -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 @@ -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 @@ -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 diff --git a/examples/ghc-lib-test-utils/src/TestUtils.hs b/examples/ghc-lib-test-utils/src/TestUtils.hs index 515d2155..0425c8e5 100644 --- a/examples/ghc-lib-test-utils/src/TestUtils.hs +++ b/examples/ghc-lib-test-utils/src/TestUtils.hs @@ -58,6 +58,7 @@ data GhcVersion | Ghc981 | Ghc982 | Ghc9101 + | Ghc9121 | GhcMaster deriving (Eq, Ord, Typeable) @@ -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" @@ -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 diff --git a/ghc-lib-gen/ghc-lib-parser/ghc-9.14/Main.hs b/ghc-lib-gen/ghc-lib-parser/ghc-9.14/Main.hs new file mode 100644 index 00000000..2f974888 --- /dev/null +++ b/ghc-lib-gen/ghc-lib-parser/ghc-9.14/Main.hs @@ -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 diff --git a/ghc-lib-gen/ghc-lib/ghc-9.14/Main.hs b/ghc-lib-gen/ghc-lib/ghc-9.14/Main.hs new file mode 100644 index 00000000..800944a5 --- /dev/null +++ b/ghc-lib-gen/ghc-lib/ghc-9.14/Main.hs @@ -0,0 +1 @@ +import GHC diff --git a/ghc-lib-gen/src/Ghclibgen.hs b/ghc-lib-gen/src/Ghclibgen.hs index b1fc4b74..a4bd4c7a 100644 --- a/ghc-lib-gen/src/Ghclibgen.hs +++ b/ghc-lib-gen/src/Ghclibgen.hs @@ -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. @@ -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') @@ -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" ] diff --git a/ghc-lib-gen/src/GhclibgenFlavor.hs b/ghc-lib-gen/src/GhclibgenFlavor.hs index 8717b3da..392f3ebd 100644 --- a/ghc-lib-gen/src/GhclibgenFlavor.hs +++ b/ghc-lib-gen/src/GhclibgenFlavor.hs @@ -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" @@ -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" diff --git a/ghc-lib-gen/src/GhclibgenOpts.hs b/ghc-lib-gen/src/GhclibgenOpts.hs index a9ec77cc..58171d56 100644 --- a/ghc-lib-gen/src/GhclibgenOpts.hs +++ b/ghc-lib-gen/src/GhclibgenOpts.hs @@ -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