[commit: ghc] wip/eventlog-heap-profile: DynFlags: Initialize unsafeGlobalDynFlags enough to be useful (4e98b4f)

git at git.haskell.org git at git.haskell.org
Sat Mar 26 00:58:01 UTC 2016


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

On branch  : wip/eventlog-heap-profile
Link       : http://ghc.haskell.org/trac/ghc/changeset/4e98b4ff98e127aa9ef4fa1e85bdf0efa41f0902/ghc

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

commit 4e98b4ff98e127aa9ef4fa1e85bdf0efa41f0902
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


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

4e98b4ff98e127aa9ef4fa1e85bdf0efa41f0902
 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 99d80d6..9c67045 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -4855,7 +4855,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