From 9bc6af6ca4e246a7bf6119633c251cf31e6bc1ab Mon Sep 17 00:00:00 2001
From: Sylvain Henry <sylvain@haskus.fr>
Date: Mon, 21 Jun 2021 09:59:49 +0200
Subject: [PATCH 1/2] Fix build with 9.2

---
 ghc-api-compat.cabal | 45 ++++++++++++++++++++++++++++++--------------
 src/CoreMap.hs       |  8 ++++++++
 src/HscTypes.hs      | 32 +++++++++++++++++++++++++++++++
 src/Outputable.hs    |  9 ++++++++-
 4 files changed, 79 insertions(+), 15 deletions(-)
 create mode 100644 src/CoreMap.hs
 create mode 100644 src/HscTypes.hs

diff --git a/ghc-api-compat.cabal b/ghc-api-compat.cabal
index 636f938..f24cd2a 100644
--- a/ghc-api-compat.cabal
+++ b/ghc-api-compat.cabal
@@ -87,6 +87,37 @@ library
          , GHC.HsToCore.PmCheck.Ppr       as PmPpr
          , GHC.HsToCore.PmCheck.Types     as PmTypes
 
+   if impl(ghc >= 9.0) && impl (ghc < 9.2)
+      reexported-modules:
+           GHC.Rename.Doc                 as RnHsDoc
+         , GHC.Utils.Encoding             as Encoding
+         , GHC.Core.Map                   as CoreMap
+         , GHC.Core.Ppr.TyThing           as PprTyThing
+         , GHC.Driver.Types               as HscTypes
+         , GHC.Driver.Finder              as Finder
+         , GHC.CoreToByteCode             as ByteCodeGen
+         , GHC.Runtime.Linker.Types       as LinkerTypes
+         , GHC.Runtime.Linker             as Linker
+         , GHC.SysTools.FileCleanup       as FileCleanup
+         , GHC.SysTools.ExtraObj          as SysTools.ExtraObj
+         , GHC.Cmm.Monad                  as CmmMonad
+         , GHC.Builtin.RebindableNames
+
+   if impl(ghc >= 9.2)
+      hs-source-dirs:   src
+      exposed-modules:
+           CoreMap
+           HscTypes
+      reexported-modules:
+           GHC.Types.TyThing.Ppr          as PprTyThing
+         , GHC.Unit.Finder                as Finder
+         , GHC.StgToByteCode              as ByteCodeGen
+         , GHC.Linker.Types               as LinkerTypes
+         , GHC.Linker                     as Linker
+         , GHC.Utils.TmpFs                as FileCleanup
+         , GHC.Linker.ExtraObj            as SysTools.ExtraObj
+         , GHC.Cmm.Parser.Monad           as CmmMonad
+
    if impl(ghc >= 9.0)
       hs-source-dirs:   src
       exposed-modules:  Outputable
@@ -95,7 +126,6 @@ library
          , GHC.Rename.Env                 as RnEnv
          , GHC.Rename.Expr                as RnExpr
          , GHC.Rename.Fixity              as RnFixity
-         , GHC.Rename.Doc                 as RnHsDoc
          , GHC.Rename.Names               as RnNames
          , GHC.Rename.Pat                 as RnPat
          , GHC.Rename.Module              as RnSource
@@ -107,7 +137,6 @@ library
          , GHC.Builtin.Names              as PrelNames
          , GHC.Builtin.Names.TH           as THNames
          , GHC.Builtin.PrimOps            as PrimOp
-         , GHC.Builtin.RebindableNames
          , GHC.Builtin.Types              as TysWiredIn
          , GHC.Builtin.Types.Literals     as TcTypeNats
          , GHC.Builtin.Types.Prim         as TysPrims
@@ -162,7 +191,6 @@ library
          , GHC.Cmm.Lint                   as CmmLint
          , GHC.Cmm.Liveness               as CmmLive
          , GHC.Cmm.MachOp                 as CmmMachOp
-         , GHC.Cmm.Monad                  as CmmMonad
          , GHC.Cmm.Node                   as CmmNode
          , GHC.Cmm.Opt                    as CmmOpt
          , GHC.Cmm.Pipeline               as CmmPipeline
@@ -256,8 +284,6 @@ library
          , GHC.SysTools.Ar                as Ar
          , GHC.SysTools.BaseDir           as SysTools.BaseDir
          , GHC.SysTools.Elf               as Elf
-         , GHC.SysTools.ExtraObj          as SysTools.ExtraObj
-         , GHC.SysTools.FileCleanup       as FileCleanup
          , GHC.SysTools.Info              as SysTools.Info
          , GHC.SysTools.Process           as SysTools.Process
          , GHC.SysTools.Tasks             as SysTools.Tasks
@@ -289,8 +315,6 @@ library
 
          , GHC.Runtime.Debugger           as Debugger
          , GHC.Runtime.Interpreter        as GHCi
-         , GHC.Runtime.Linker             as Linker
-         , GHC.Runtime.Linker.Types       as LinkerTypes
          , GHC.Runtime.Loader             as DynamicLoading
          , GHC.Runtime.Eval               as InteractiveEval
          , GHC.Runtime.Eval.Types         as InteractiveEvalTypes
@@ -303,8 +327,6 @@ library
          , GHC.ByteCode.Linker            as ByteCodeLink
          , GHC.ByteCode.Types             as ByteCodeTypes
 
-         , GHC.CoreToByteCode             as ByteCodeGen
-
          , GHC.Llvm.MetaData              as Llvm.MetaData
          , GHC.Llvm.Ppr                   as Llvm.PpLlvm
          , GHC.Llvm.Types                 as Llvm.Types
@@ -321,7 +343,6 @@ library
          , GHC.Driver.Backpack            as DriverBkp
          , GHC.Driver.CmdLine             as CmdLineParser
          , GHC.Driver.CodeOutput          as CodeOutput
-         , GHC.Driver.Finder              as Finder
          , GHC.Driver.MakeFile            as DriverMkDepend
          , GHC.Driver.Main                as HscMain
          , GHC.Driver.Make                as GhcMake
@@ -332,7 +353,6 @@ library
          , GHC.Driver.Pipeline.Monad      as PipelineMonad
          , GHC.Driver.Plugins             as Plugins
          , GHC.Driver.Monad               as GhcMonad
-         , GHC.Driver.Types               as HscTypes
          , GHC.Prelude                    as GhcPrelude
          , GHC.Plugins                    as GhcPlugins
          , GHC                            as GHC
@@ -415,7 +435,6 @@ library
          , GHC.Core.InstEnv                      as InstEnv
          , GHC.Core.Lint                         as CoreLint
          , GHC.Core.Make                         as MkCore
-         , GHC.Core.Map                          as CoreMap
          , GHC.Core.Multiplicity
 
          , GHC.Core.Opt.Arity                    as CoreArity
@@ -423,7 +442,6 @@ library
 
          , GHC.Core.PatSyn                       as PatSyn
          , GHC.Core.Ppr                          as PprCore
-         , GHC.Core.Ppr.TyThing                  as PprTyThing
          , GHC.Core.Predicate                    as Predicate
          , GHC.Core.Rules                        as Rules
          , GHC.Core.Seq                          as CoreSeq
@@ -449,7 +467,6 @@ library
          , GHC.Utils.Binary                      as Binary
          , GHC.Utils.BufHandle                   as BufWrite
          , GHC.Utils.CliOption                   as CliOption
-         , GHC.Utils.Encoding                    as Encoding
          , GHC.Utils.Error                       as ErrUtils
          , GHC.Utils.Exception                   as Exception
          , GHC.Utils.FV                          as FV
diff --git a/src/CoreMap.hs b/src/CoreMap.hs
new file mode 100644
index 0000000..c4c55be
--- /dev/null
+++ b/src/CoreMap.hs
@@ -0,0 +1,8 @@
+module CoreMap
+  ( module GHC.Core.Map.Expr
+  , module GHC.Core.Map.Type
+  )
+where
+
+import GHC.Core.Map.Expr
+import GHC.Core.Map.Type
diff --git a/src/HscTypes.hs b/src/HscTypes.hs
new file mode 100644
index 0000000..1a3d158
--- /dev/null
+++ b/src/HscTypes.hs
@@ -0,0 +1,32 @@
+module HscTypes
+  ( module X
+  )
+where
+
+import GHC.Driver.Env.Types           as X
+import GHC.Unit.Finder.Types          as X
+import GHC.Unit.Module.Status         as X
+import GHC.Unit.Module.Graph          as X
+import GHC.Unit.Module.ModDetails     as X
+import GHC.Unit.Module.ModGuts        as X
+import GHC.Unit.Module.ModSummary     as X
+import GHC.Unit.Home.ModInfo          as X
+import GHC.Unit.Module.ModIface       as X
+import GHC.Unit.Module.Warnings       as X
+import GHC.Unit.Types                 as X
+import GHC.Types.SourceFile           as X
+import GHC.Types.Fixity.Env           as X
+import GHC.Types.Target               as X
+import GHC.Types.Meta                 as X
+import GHC.Types.TyThing              as X
+import GHC.Types.TypeEnv              as X
+import GHC.Types.HpcInfo              as X
+import GHC.Types.SourceError          as X
+import GHC.Driver.Env                 as X
+import GHC.Runtime.Context            as X
+import GHC.Linker.Types               as X
+import GHC.ByteCode.Types             as X
+import GHC.Types.SafeHaskell          as X
+import GHC.Types.CompleteMatch        as X
+import GHC.Hs                         as X
+import GHC.Iface.Ext.Fields           as X
diff --git a/src/Outputable.hs b/src/Outputable.hs
index eede817..25b9c85 100644
--- a/src/Outputable.hs
+++ b/src/Outputable.hs
@@ -1,7 +1,14 @@
+{-# LANGUAGE CPP #-}
+
 module Outputable
     ( module GHC.Utils.Outputable
+#if !MIN_VERSION_GLASGOW_HASKELL(9,0,0,0)
+    -- now exported again from Outputable
     , initSDocContext
+#endif
     ) where
 
 import GHC.Utils.Outputable
-import GHC.Driver.Session (initSDocContext)
\ No newline at end of file
+#if !MIN_VERSION_GLASGOW_HASKELL(9,0,0,0)
+import GHC.Driver.Session (initSDocContext)
+#endif
-- 
GitLab


From 5c86e14514ccc1c23beb60e77ec45109a61a50a0 Mon Sep 17 00:00:00 2001
From: Sylvain Henry <sylvain@haskus.fr>
Date: Mon, 21 Jun 2021 10:00:19 +0200
Subject: [PATCH 2/2] Fix old style command

---
 README.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.rst b/README.rst
index 6b33b91..6befc89 100644
--- a/README.rst
+++ b/README.rst
@@ -12,4 +12,4 @@ Build with:
 
 .. code::
 
-   cabal new-build -w /path/to/ghc/HEAD/_build/stage1/bin/ghc
+   cabal build -w /path/to/ghc/HEAD/_build/stage1/bin/ghc
-- 
GitLab