summaryrefslogtreecommitdiff
path: root/compiler/GHC/Iface/Binary.hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-05-27 19:12:58 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-06-27 11:57:11 -0400
commita04020b88d4935d675f989806aff251f459561e9 (patch)
tree716aa06689f45af4fa922d89024062df60d65423 /compiler/GHC/Iface/Binary.hs
parenta74ec37c9d7679a5563ab86a8759c79c3c5de6f0 (diff)
downloadhaskell-a04020b88d4935d675f989806aff251f459561e9.tar.gz
DynFlags: don't store buildTag
`DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field.
Diffstat (limited to 'compiler/GHC/Iface/Binary.hs')
-rw-r--r--compiler/GHC/Iface/Binary.hs16
1 files changed, 9 insertions, 7 deletions
diff --git a/compiler/GHC/Iface/Binary.hs b/compiler/GHC/Iface/Binary.hs
index 4c676c4d11..d92aa742af 100644
--- a/compiler/GHC/Iface/Binary.hs
+++ b/compiler/GHC/Iface/Binary.hs
@@ -43,6 +43,7 @@ import GHC.Driver.Types
import GHC.Unit
import GHC.Types.Name
import GHC.Driver.Session
+import GHC.Driver.Ways
import GHC.Types.Unique.FM
import GHC.Types.Unique.Supply
import GHC.Utils.Panic
@@ -58,6 +59,7 @@ import GHC.Data.FastString
import GHC.Settings.Constants
import GHC.Utils.Misc
+import Data.Set (Set)
import Data.Array
import Data.Array.ST
import Data.Array.Unsafe
@@ -136,7 +138,7 @@ readBinIface_ dflags checkHiWay traceBinIFaceReading hi_path ncu = do
errorOnMismatch "mismatched interface file versions" our_ver check_ver
check_way <- get bh
- let way_descr = getWayDescr dflags
+ let way_descr = getWayDescr platform (ways dflags)
wantedGot "Way" way_descr check_way ppr
when (checkHiWay == CheckHiWay) $
errorOnMismatch "mismatched interface file ways" way_descr check_way
@@ -191,7 +193,7 @@ writeBinIface dflags hi_path mod_iface = do
-- The version and way descriptor go next
put_ bh (show hiVersion)
- let way_descr = getWayDescr dflags
+ let way_descr = getWayDescr platform (ways dflags)
put_ bh way_descr
extFields_p_p <- tellBin bh
@@ -428,10 +430,10 @@ data BinDictionary = BinDictionary {
-- indexed by FastString
}
-getWayDescr :: DynFlags -> String
-getWayDescr dflags
- | platformUnregisterised (targetPlatform dflags) = 'u':tag
- | otherwise = tag
- where tag = buildTag dflags
+getWayDescr :: Platform -> Set Way -> String
+getWayDescr platform ws
+ | platformUnregisterised platform = 'u':tag
+ | otherwise = tag
+ where tag = waysBuildTag ws
-- if this is an unregisterised build, make sure our interfaces
-- can't be used by a registerised build.