[commit: ghc] wip/generalized-arrow: DynFlags: Initialize unsafeGlobalDynFlags enough to be useful (49879ce)
git at git.haskell.org
git at git.haskell.org
Fri Mar 25 23:24:20 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/generalized-arrow
Link : http://ghc.haskell.org/trac/ghc/changeset/49879ceaa043530eb1ade11de30fbca2fe98fcea/ghc
>---------------------------------------------------------------
commit 49879ceaa043530eb1ade11de30fbca2fe98fcea
Author: Ben Gamari <ben at smart-cactus.org>
Date: Fri Mar 25 16:43:41 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.
>---------------------------------------------------------------
49879ceaa043530eb1ade11de30fbca2fe98fcea
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