summaryrefslogtreecommitdiff
path: root/ghc/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'ghc/Main.hs')
-rw-r--r--ghc/Main.hs18
1 files changed, 16 insertions, 2 deletions
diff --git a/ghc/Main.hs b/ghc/Main.hs
index ae862a7014..5f854b6565 100644
--- a/ghc/Main.hs
+++ b/ghc/Main.hs
@@ -32,6 +32,7 @@ import GHC.Driver.Backpack ( doBackpack )
import GHC.Driver.Plugins
import GHC.Driver.Config.Logger (initLogFlags)
import GHC.Driver.Config.Diagnostic
+import GHC.Driver.Monad
import GHC.Platform
import GHC.Platform.Ways
@@ -99,6 +100,10 @@ import Data.Bifunctor
import GHC.Data.Graph.Directed
import qualified Data.List.NonEmpty as NE
+#if defined(GHC_DEBUG)
+import GHC.Debug.Stub
+#endif
+
-----------------------------------------------------------------------------
-- ToDo:
@@ -111,6 +116,13 @@ import qualified Data.List.NonEmpty as NE
-----------------------------------------------------------------------------
-- GHC's command-line interface
+debugWrapper :: IO a -> IO a
+#if defined(GHC_DEBUG)
+debugWrapper = withGhcDebug
+#else
+debugWrapper = id
+#endif
+
main :: IO ()
main = do
hSetBuffering stdout LineBuffering
@@ -159,8 +171,10 @@ main = do
ShowGhcUsage -> showGhcUsage dflags
ShowGhciUsage -> showGhciUsage dflags
PrintWithDynFlags f -> putStrLn (f dflags)
- Right postLoadMode ->
- main' postLoadMode units dflags argv3 flagWarnings
+ Right postLoadMode -> do
+ reifyGhc $ \session -> debugWrapper $
+ reflectGhc (main' postLoadMode units dflags argv3 flagWarnings) session
+
main' :: PostLoadMode -> [String] -> DynFlags -> [Located String] -> [Warn]
-> Ghc ()