summaryrefslogtreecommitdiff
path: root/ghc/Main.hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2017-02-02 14:37:24 -0500
committerBen Gamari <ben@smart-cactus.org>2017-02-02 22:13:53 -0500
commitbbd3c399939311ec3e308721ab87ca6b9443f358 (patch)
tree1a398f3857502ab42f350008f83b7c67f0d9ff1e /ghc/Main.hs
parent6128b2ffbe36ed2779583e05ee9d817eaafc1c9c (diff)
downloadhaskell-bbd3c399939311ec3e308721ab87ca6b9443f358.tar.gz
Ditch static flags
This patch converts the 4 lasting static flags (read from the command line and unsafely stored in immutable global variables) into dynamic flags. Most use cases have been converted into reading them from a DynFlags. In cases for which we don't have easy access to a DynFlags, we read from 'unsafeGlobalDynFlags' that is set at the beginning of each 'runGhc'. It's not perfect (not thread-safe) but it is still better as we can set/unset these 4 flags before each run when using GHC API. Updates haddock submodule. Rebased and finished by: bgamari Test Plan: validate Reviewers: goldfire, erikd, hvr, austin, simonmar, bgamari Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2839 GHC Trac Issues: #8440
Diffstat (limited to 'ghc/Main.hs')
-rw-r--r--ghc/Main.hs22
1 files changed, 3 insertions, 19 deletions
diff --git a/ghc/Main.hs b/ghc/Main.hs
index a650d35a62..0984bf7935 100644
--- a/ghc/Main.hs
+++ b/ghc/Main.hs
@@ -46,7 +46,6 @@ import HscTypes
import Packages ( pprPackages, pprPackagesSimple )
import DriverPhases
import BasicTypes ( failed )
-import StaticFlags
import DynFlags
import ErrUtils
import FastString
@@ -113,13 +112,10 @@ main = do
mbMinusB | null minusB_args = Nothing
| otherwise = Just (drop 2 (last minusB_args))
- let argv1' = map (mkGeneralLocated "on the commandline") argv1
- (argv2, staticFlagWarnings) <- parseStaticFlags argv1'
+ let argv2 = map (mkGeneralLocated "on the commandline") argv1
-- 2. Parse the "mode" flags (--make, --interactive etc.)
- (mode, argv3, modeFlagWarnings) <- parseModeFlags argv2
-
- let flagWarnings = staticFlagWarnings ++ modeFlagWarnings
+ (mode, argv3, flagWarnings) <- parseModeFlags argv2
-- If all we want to do is something like showing the version number
-- then do it now, before we start a GHC session etc. This makes
@@ -239,10 +235,6 @@ main' postLoadMode dflags0 args flagWarnings = do
| v >= 5 -> liftIO $ dumpPackages dflags6
| otherwise -> return ()
- when (verbosity dflags6 >= 3) $ do
- liftIO $ hPutStrLn stderr ("Hsc static flags: " ++ unwords staticFlags)
-
-
liftIO $ initUniqSupply (initialUnique dflags6) (uniqueIncrement dflags6)
---------------- Final sanity checking -----------
liftIO $ checkOptions postLoadMode dflags6 srcs objs
@@ -775,17 +767,9 @@ showOptions isInteractive = putStr (unlines availableOptions)
where
availableOptions = concat [
flagsForCompletion isInteractive,
- map ('-':) (concat [
- getFlagNames mode_flags
- , (filterUnwantedStatic . getFlagNames $ flagsStatic)
- , flagsStaticNames
- ])
+ map ('-':) (getFlagNames mode_flags)
]
getFlagNames opts = map flagName opts
- -- this is a hack to get rid of two unwanted entries that get listed
- -- as static flags. Hopefully this hack will disappear one day together
- -- with static flags
- filterUnwantedStatic = filter (`notElem`["f", "fno-"])
showGhcUsage :: DynFlags -> IO ()
showGhcUsage = showUsage False