[commit: ghc] ghc-8.0: DynFlags: Initialize unsafeGlobalDynFlags enough to be useful (0f289b9)

git at git.haskell.org git at git.haskell.org
Mon Mar 28 18:24:54 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/0f289b93ef4993f2df922dc490799414d73c7b2e/ghc

>---------------------------------------------------------------

commit 0f289b93ef4993f2df922dc490799414d73c7b2e
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Sat Mar 26 00:42:11 2016 +0100

    DynFlags: Initialize unsafeGlobalDynFlags enough to be useful
    
    Previously unsafeGlobalDynFlags would bottom if used prior to
    initialization. This meant that any attempt to use the pretty-printer
    early in the initialization process of the compiler would fail. This is
    quite inconvenient.
    
    Here we initialize unsafeGlobalDynFlags with defaultDynFlags, bottoming
    only if settings is accessed.
    
    See #11755.
    
    Test Plan: Validate
    
    Reviewers: austin
    
    Reviewed By: austin
    
    Subscribers: thomie, gridaphobe
    
    Differential Revision: https://phabricator.haskell.org/D2036
    
    GHC Trac Issues: #11755


>---------------------------------------------------------------

0f289b93ef4993f2df922dc490799414d73c7b2e
 compiler/main/DynFlags.hs | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 6060244..bff0348 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -4813,7 +4813,15 @@ makeDynFlagsConsistent dflags
 -- Do not use it if you can help it. You may get the wrong value, or this
 -- panic!
 
-GLOBAL_VAR(v_unsafeGlobalDynFlags, panic "v_unsafeGlobalDynFlags: not initialised", DynFlags)
+-- | This is the value that 'unsafeGlobalDynFlags' takes before it is
+-- initialized.
+defaultGlobalDynFlags :: DynFlags
+defaultGlobalDynFlags =
+    (defaultDynFlags settings) { verbosity = 2 }
+  where
+    settings = panic "v_unsafeGlobalDynFlags: not initialised"
+
+GLOBAL_VAR(v_unsafeGlobalDynFlags, defaultGlobalDynFlags, DynFlags)
 
 unsafeGlobalDynFlags :: DynFlags
 unsafeGlobalDynFlags = unsafePerformIO $ readIORef v_unsafeGlobalDynFlags



More information about the ghc-commits mailing list