diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2017-02-02 14:37:24 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-02-02 22:13:53 -0500 |
commit | bbd3c399939311ec3e308721ab87ca6b9443f358 (patch) | |
tree | 1a398f3857502ab42f350008f83b7c67f0d9ff1e /compiler/main/DynFlags.hs | |
parent | 6128b2ffbe36ed2779583e05ee9d817eaafc1c9c (diff) | |
download | haskell-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 'compiler/main/DynFlags.hs')
-rw-r--r-- | compiler/main/DynFlags.hs | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 682480b44f..d7a5f1f92c 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -28,6 +28,7 @@ module DynFlags ( ProfAuto(..), glasgowExtsFlags, warningGroups, warningHierarchies, + hasPprDebug, hasNoDebugOutput, hasNoStateHack, hasNoOptCoercion, dopt, dopt_set, dopt_unset, gopt, gopt_set, gopt_unset, setGeneralFlag', unSetGeneralFlag', wopt, wopt_set, wopt_unset, @@ -381,7 +382,8 @@ data DumpFlag | Opt_D_verbose_core2core | Opt_D_dump_debug | Opt_D_dump_json - + | Opt_D_ppr_debug + | Opt_D_no_debug_output deriving (Eq, Show, Enum) -- | Enumerates the simple on-or-off dynamic flags @@ -561,6 +563,9 @@ data GeneralFlag -- safe haskell flags | Opt_DistrustAllPackages | Opt_PackageTrust + + | Opt_G_NoStateHack + | Opt_G_NoOptCoercion deriving (Eq, Show, Enum) -- | Used when outputting warnings: if a reason is given, it is @@ -1889,6 +1894,19 @@ languageExtensions (Just Haskell2010) LangExt.DoAndIfThenElse, LangExt.RelaxedPolyRec] +hasPprDebug :: DynFlags -> Bool +hasPprDebug = dopt Opt_D_ppr_debug + +hasNoDebugOutput :: DynFlags -> Bool +hasNoDebugOutput = dopt Opt_D_no_debug_output + +hasNoStateHack :: DynFlags -> Bool +hasNoStateHack = gopt Opt_G_NoStateHack + +hasNoOptCoercion :: DynFlags -> Bool +hasNoOptCoercion = gopt Opt_G_NoOptCoercion + + -- | Test whether a 'DumpFlag' is set dopt :: DumpFlag -> DynFlags -> Bool dopt f dflags = (fromEnum f `IntSet.member` dumpFlags dflags) @@ -2736,6 +2754,10 @@ dynamic_flags_deps = [ (NoArg (unSetGeneralFlag Opt_AutoLinkPackages)) , make_ord_flag defGhcFlag "no-hs-main" (NoArg (setGeneralFlag Opt_NoHsMain)) + , make_ord_flag defGhcFlag "fno-state-hack" + (NoArg (setGeneralFlag Opt_G_NoStateHack)) + , make_ord_flag defGhcFlag "fno-opt-coercion" + (NoArg (setGeneralFlag Opt_G_NoOptCoercion)) , make_ord_flag defGhcFlag "with-rtsopts" (HasArg setRtsOpts) , make_ord_flag defGhcFlag "rtsopts" @@ -2979,10 +3001,14 @@ dynamic_flags_deps = [ (NoArg (setGeneralFlag Opt_D_faststring_stats)) , make_ord_flag defGhcFlag "dno-llvm-mangler" (NoArg (setGeneralFlag Opt_NoLlvmMangler)) -- hidden flag - , make_ord_flag defGhcFlag "ddump-debug" (setDumpFlag Opt_D_dump_debug) - + , make_ord_flag defGhcFlag "ddump-debug" + (setDumpFlag Opt_D_dump_debug) , make_ord_flag defGhcFlag "ddump-json" (noArg (flip dopt_set Opt_D_dump_json . setJsonLogAction ) ) + , make_ord_flag defGhcFlag "dppr-debug" + (setDumpFlag Opt_D_ppr_debug) + , make_ord_flag defGhcFlag "dno-debug-output" + (setDumpFlag Opt_D_no_debug_output) ------ Machine dependent (-m<blah>) stuff --------------------------- @@ -4435,7 +4461,8 @@ setDumpFlag' dump_flag -- on during recompilation checking, so in those cases we -- don't want to turn it off. want_recomp = dump_flag `notElem` [Opt_D_dump_if_trace, - Opt_D_dump_hi_diffs] + Opt_D_dump_hi_diffs, + Opt_D_no_debug_output] forceRecompile :: DynP () -- Whenver we -ddump, force recompilation (by switching off the |