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 /testsuite | |
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 'testsuite')
-rw-r--r-- | testsuite/tests/ghc-api/T10052/T10052.hs | 5 | ||||
-rw-r--r-- | testsuite/tests/plugins/LinkerTicklingPlugin.hs | 10 |
2 files changed, 7 insertions, 8 deletions
diff --git a/testsuite/tests/ghc-api/T10052/T10052.hs b/testsuite/tests/ghc-api/T10052/T10052.hs index c2df4ae983..a2e50a6bc6 100644 --- a/testsuite/tests/ghc-api/T10052/T10052.hs +++ b/testsuite/tests/ghc-api/T10052/T10052.hs @@ -16,11 +16,10 @@ main = do runGhc' :: [String] -> Ghc a -> IO a runGhc' args act = do let libdir = head args - flags = tail args - (dynFlags, _warns) <- parseStaticFlags (map noLoc flags) + flags = map noLoc (tail args) runGhc (Just libdir) $ do dflags0 <- getSessionDynFlags - (dflags1, _leftover, _warns) <- parseDynamicFlags dflags0 dynFlags + (dflags1, _leftover, _warns) <- parseDynamicFlags dflags0 flags let dflags2 = dflags1 { hscTarget = HscInterpreted , ghcLink = LinkInMemory diff --git a/testsuite/tests/plugins/LinkerTicklingPlugin.hs b/testsuite/tests/plugins/LinkerTicklingPlugin.hs index 52d5e177bb..260d4c1228 100644 --- a/testsuite/tests/plugins/LinkerTicklingPlugin.hs +++ b/testsuite/tests/plugins/LinkerTicklingPlugin.hs @@ -1,15 +1,15 @@ module LinkerTicklingPlugin where import GhcPlugins -import StaticFlags +import DynFlags plugin :: Plugin plugin = defaultPlugin { installCoreToDos = install } --- This tests whether plugins are linking against the *running* GHC --- or a new instance of it. If it is a new instance the staticFlags --- won't have been initialised, so we'll get a GHC panic here: +-- This tests whether plugins are linking against the *running* GHC or a new +-- instance of it. If it is a new instance (settings unsafeGlobalDynFlags) won't +-- have been initialised, so we'll get a GHC panic here: install :: [CommandLineOption] -> [CoreToDo] -> CoreM [CoreToDo] -install _options todos = length staticFlags `seq` return todos +install _options todos = settings unsafeGlobalDynFlags `seq` return todos |