Commit bfa0c2ed authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Initialise Settings before DynFlags

Stops us having to temporarily have a panic in the DynFlags.
We still need a panic in the DynFlags used for the top-level
error handler, though.
parent e550494a
...@@ -43,7 +43,7 @@ module DynFlags ( ...@@ -43,7 +43,7 @@ module DynFlags (
-- ** Manipulating DynFlags -- ** Manipulating DynFlags
defaultDynFlags, -- DynFlags defaultDynFlags, -- Settings -> DynFlags
initDynFlags, -- DynFlags -> IO DynFlags initDynFlags, -- DynFlags -> IO DynFlags
getOpts, -- DynFlags -> (DynFlags -> [a]) -> [a] getOpts, -- DynFlags -> (DynFlags -> [a]) -> [a]
...@@ -697,8 +697,8 @@ initDynFlags dflags = do ...@@ -697,8 +697,8 @@ initDynFlags dflags = do
-- | The normal 'DynFlags'. Note that they is not suitable for use in this form -- | The normal 'DynFlags'. Note that they is not suitable for use in this form
-- and must be fully initialized by 'GHC.newSession' first. -- and must be fully initialized by 'GHC.newSession' first.
defaultDynFlags :: DynFlags defaultDynFlags :: Settings -> DynFlags
defaultDynFlags = defaultDynFlags mySettings =
DynFlags { DynFlags {
ghcMode = CompManager, ghcMode = CompManager,
ghcLink = LinkBinary, ghcLink = LinkBinary,
...@@ -774,8 +774,7 @@ defaultDynFlags = ...@@ -774,8 +774,7 @@ defaultDynFlags =
buildTag = panic "defaultDynFlags: No buildTag", buildTag = panic "defaultDynFlags: No buildTag",
rtsBuildTag = panic "defaultDynFlags: No rtsBuildTag", rtsBuildTag = panic "defaultDynFlags: No rtsBuildTag",
splitInfo = Nothing, splitInfo = Nothing,
-- initSysTools fills this in: settings = mySettings,
settings = panic "defaultDynFlags: No settings",
-- ghc -M values -- ghc -M values
depMakefile = "Makefile", depMakefile = "Makefile",
depIncludePkgDeps = False, depIncludePkgDeps = False,
......
...@@ -431,9 +431,8 @@ initGhcMonad mb_top_dir = do ...@@ -431,9 +431,8 @@ initGhcMonad mb_top_dir = do
liftIO $ StaticFlags.initStaticOpts liftIO $ StaticFlags.initStaticOpts
dflags0 <- liftIO $ initDynFlags defaultDynFlags
mySettings <- liftIO $ initSysTools mb_top_dir mySettings <- liftIO $ initSysTools mb_top_dir
let dflags = dflags0 { settings = mySettings } dflags <- liftIO $ initDynFlags (defaultDynFlags mySettings)
env <- liftIO $ newHscEnv dflags env <- liftIO $ newHscEnv dflags
setSession env setSession env
......
...@@ -78,7 +78,8 @@ import Data.Maybe ...@@ -78,7 +78,8 @@ import Data.Maybe
main :: IO () main :: IO ()
main = do main = do
hSetBuffering stdout NoBuffering hSetBuffering stdout NoBuffering
GHC.defaultErrorHandler defaultDynFlags $ do let defaultErrorHandlerDynFlags = defaultDynFlags (panic "No settings")
GHC.defaultErrorHandler defaultErrorHandlerDynFlags $ do
-- 1. extract the -B flag from the args -- 1. extract the -B flag from the args
argv0 <- getArgs argv0 <- getArgs
......
...@@ -10,6 +10,7 @@ import DriverPhases ( isHaskellSrcFilename ) ...@@ -10,6 +10,7 @@ import DriverPhases ( isHaskellSrcFilename )
import HscTypes ( msHsFilePath ) import HscTypes ( msHsFilePath )
import Name ( getOccString ) import Name ( getOccString )
--import ErrUtils ( printBagOfErrors ) --import ErrUtils ( printBagOfErrors )
import Panic ( panic )
import DynFlags ( defaultDynFlags ) import DynFlags ( defaultDynFlags )
import Bag import Bag
import Exception import Exception
...@@ -100,7 +101,7 @@ main = do ...@@ -100,7 +101,7 @@ main = do
then Just `liftM` openFile "TAGS" openFileMode then Just `liftM` openFile "TAGS" openFileMode
else return Nothing else return Nothing
GHC.defaultErrorHandler defaultDynFlags $ GHC.defaultErrorHandler (defaultDynFlags (panic "No settings")) $
runGhc (Just ghc_topdir) $ do runGhc (Just ghc_topdir) $ do
--liftIO $ print "starting up session" --liftIO $ print "starting up session"
dflags <- getSessionDynFlags dflags <- getSessionDynFlags
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment