diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2020-09-07 19:48:03 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-11-06 03:46:08 -0500 |
commit | c85f4928d4dbb2eb2cf906d08bfe7620d6f04ca5 (patch) | |
tree | a61f2361be48b9878df3f1033cec2b2cb8f01c40 /compiler/GHC/Tc/Utils | |
parent | e07e383a3250cb27a9128ad8d5c68def5c3df336 (diff) | |
download | haskell-c85f4928d4dbb2eb2cf906d08bfe7620d6f04ca5.tar.gz |
Refactor -dynamic-too handling
1) Don't modify DynFlags (too much) for -dynamic-too: now when we
generate dynamic outputs for "-dynamic-too", we only set "dynamicNow"
boolean field in DynFlags instead of modifying several other fields.
These fields now have accessors that take dynamicNow into account.
2) Use DynamicTooState ADT to represent -dynamic-too state. It's much
clearer than the undocumented "DynamicTooConditional" that was used
before.
As a result, we can finally remove the hscs_iface_dflags field in
HscRecomp. There was a comment on this field saying:
"FIXME (osa): I don't understand why this is necessary, but I spent
almost two days trying to figure this out and I couldn't .. perhaps
someone who understands this code better will remove this later."
I don't fully understand the details, but it was needed because of the
changes made to the DynFlags for -dynamic-too.
There is still something very dubious in GHC.Iface.Recomp: we have to
disable the "dynamicNow" flag at some point for some Backpack's "heinous
hack" to continue to work. It may be because interfaces for indefinite
units are always non-dynamic, or because we mix and match dynamic and
non-dynamic interfaces (#9176), or something else, who knows?
Diffstat (limited to 'compiler/GHC/Tc/Utils')
-rw-r--r-- | compiler/GHC/Tc/Utils/Monad.hs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/compiler/GHC/Tc/Utils/Monad.hs b/compiler/GHC/Tc/Utils/Monad.hs index de3c4aeb01..6b66c32ccc 100644 --- a/compiler/GHC/Tc/Utils/Monad.hs +++ b/compiler/GHC/Tc/Utils/Monad.hs @@ -28,7 +28,7 @@ module GHC.Tc.Utils.Monad( whenDOptM, whenGOptM, whenWOptM, whenXOptM, unlessXOptM, getGhcMode, - withDoDynamicToo, + withDynamicNow, withoutDynamicNow, getEpsVar, getEps, updateEps, updateEps_, @@ -546,10 +546,15 @@ unlessXOptM flag thing_inside = do b <- xoptM flag getGhcMode :: TcRnIf gbl lcl GhcMode getGhcMode = do { env <- getTopEnv; return (ghcMode (hsc_dflags env)) } -withDoDynamicToo :: TcRnIf gbl lcl a -> TcRnIf gbl lcl a -withDoDynamicToo = +withDynamicNow :: TcRnIf gbl lcl a -> TcRnIf gbl lcl a +withDynamicNow = updTopEnv (\top@(HscEnv { hsc_dflags = dflags }) -> - top { hsc_dflags = dynamicTooMkDynamicDynFlags dflags }) + top { hsc_dflags = setDynamicNow dflags }) + +withoutDynamicNow :: TcRnIf gbl lcl a -> TcRnIf gbl lcl a +withoutDynamicNow = + updTopEnv (\top@(HscEnv { hsc_dflags = dflags }) -> + top { hsc_dflags = dflags { dynamicNow = False} }) getEpsVar :: TcRnIf gbl lcl (TcRef ExternalPackageState) getEpsVar = do { env <- getTopEnv; return (hsc_EPS env) } |