summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2016-03-26 00:42:11 +0100
committerBen Gamari <ben@smart-cactus.org>2016-03-26 00:42:12 +0100
commit4e98b4ff98e127aa9ef4fa1e85bdf0efa41f0902 (patch)
tree9b98d9243dd3c5b4c63291977c9cf5ba09a54e84 /compiler
parent454585c6802f0de4d23f9f16de591596533503b7 (diff)
downloadhaskell-4e98b4ff98e127aa9ef4fa1e85bdf0efa41f0902.tar.gz
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
Diffstat (limited to 'compiler')
-rw-r--r--compiler/main/DynFlags.hs10
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 99d80d63bf..9c6704581d 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