From 1a19fd952ecbb40b681851228aaf4b113f6ed2fa Mon Sep 17 00:00:00 2001 From: Ryan Scott Date: Sat, 1 Apr 2023 11:57:46 -0400 Subject: [PATCH] Support building with GHC 9.4 This contains a variety of tweaks needed to make the libraries in the `macaw` repo build with GHC 9.4: * `ST` no longer has a `MonadFail` instance. See [this section](https://gitlab.haskell.org/ghc/ghc/-/wikis/migration/9.4?version_id=b60e52482a666d25638d59cd7e86851ddf971dc1#st-is-no-longer-an-instance-of-monadfail) of the GHC 9.4 Migration Guide. To adapt to this change, I had to change some uses of `fail` to `panic`, and I also had to avoid some partial pattern matches in `do`-notation to avoid incurring `MonadFail (ST s)` constraints. * GHC 9.4 is pickier about undecidable superclass checking. As such, I needed to explicitly enable `UndecidableSuperClasses` in a handful of places. * The following submodule changes were brought in to support building with GHC 9.4: * `asl-translator`: GaloisInc/asl-translator#51 * `bv-sized`: GaloisInc/bv-sized#27 * `bv-sized-float`: GaloisInc/bv-sized-float#4 * `crucible`: GaloisInc/crucible#1073 (This also requires bumping the `llvm-pretty`, `llvm-pretty-bc-parser`, and `what4` submodules as a side effect) * `dismantle`: GaloisInc/dismantle#40 * `grift`: GaloisInc/grift#8 * `macaw-loader`: GaloisInc/macaw-loader#17 * `semmc`: GaloisInc/semmc#79 --- base/src/Data/Macaw/CFG/Core.hs | 1 + base/src/Data/Macaw/CFG/Rewriter.hs | 7 +++++-- base/src/Data/Macaw/Memory.hs | 1 + deps/asl-translator | 2 +- deps/bv-sized | 2 +- deps/bv-sized-float | 2 +- deps/crucible | 2 +- deps/dismantle | 2 +- deps/grift | 2 +- deps/llvm-pretty | 2 +- deps/llvm-pretty-bc-parser | 2 +- deps/macaw-loader | 2 +- deps/semmc | 2 +- deps/what4 | 2 +- macaw-semmc/src/Data/Macaw/SemMC/Operands.hs | 1 + 15 files changed, 19 insertions(+), 13 deletions(-) diff --git a/base/src/Data/Macaw/CFG/Core.hs b/base/src/Data/Macaw/CFG/Core.hs index ef3265c1..c7bf63ec 100644 --- a/base/src/Data/Macaw/CFG/Core.hs +++ b/base/src/Data/Macaw/CFG/Core.hs @@ -23,6 +23,7 @@ single CFG. {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE UndecidableSuperClasses #-} module Data.Macaw.CFG.Core ( -- * Stmt level declarations Stmt(..) diff --git a/base/src/Data/Macaw/CFG/Rewriter.hs b/base/src/Data/Macaw/CFG/Rewriter.hs index fb388416..3b7e3690 100644 --- a/base/src/Data/Macaw/CFG/Rewriter.hs +++ b/base/src/Data/Macaw/CFG/Rewriter.hs @@ -52,6 +52,7 @@ import Data.STRef import Data.Macaw.CFG.App import Data.Macaw.CFG.Core import Data.Macaw.Memory +import qualified Data.Macaw.Panic as P import Data.Macaw.Types import Data.Macaw.CFG.Block (TermStmt) @@ -185,7 +186,8 @@ addBinding srcId val = Rewriter $ do lift $ do m <- readSTRef ref when (MapF.member srcId m) $ do - fail $ "Assignment " ++ show srcId ++ " is already bound." + P.panic P.Base "addBinding" + ["Assignment " ++ show srcId ++ " is already bound."] writeSTRef ref $! MapF.insert srcId val m -- | Return true if values are identical @@ -716,7 +718,8 @@ rewriteValue v = srcMap <- lift $ readSTRef ref case MapF.lookup aid srcMap of Just tgtVal -> pure tgtVal - Nothing -> fail $ "Could not resolve source assignment " ++ show aid ++ "." + Nothing -> P.panic P.Base "rewriteValue" + ["Could not resolve source assignment " ++ show aid ++ "."] Initial r -> pure (Initial r) -- | Apply optimizations to a statement. diff --git a/base/src/Data/Macaw/Memory.hs b/base/src/Data/Macaw/Memory.hs index 4864cdea..8b9ba5e9 100644 --- a/base/src/Data/Macaw/Memory.hs +++ b/base/src/Data/Macaw/Memory.hs @@ -15,6 +15,7 @@ Declares 'Memory', a type for representing segmented memory with permissions. {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeOperators #-} +{-# LANGUAGE UndecidableSuperClasses #-} module Data.Macaw.Memory ( Memory -- * Inspecting memory diff --git a/deps/asl-translator b/deps/asl-translator index 83e498bb..b1d3c6b8 160000 --- a/deps/asl-translator +++ b/deps/asl-translator @@ -1 +1 @@ -Subproject commit 83e498bb687b518784504da6db3e6c1b09f64db3 +Subproject commit b1d3c6b816ff90a12f31429f65f99866215ad1b1 diff --git a/deps/bv-sized b/deps/bv-sized index 57c5a039..d8b0e400 160000 --- a/deps/bv-sized +++ b/deps/bv-sized @@ -1 +1 @@ -Subproject commit 57c5a0399e3e2ebeaddc754e9b721056606c9b6e +Subproject commit d8b0e400101d4491859d5060cf491153ae09ab86 diff --git a/deps/bv-sized-float b/deps/bv-sized-float index f18e76f2..f6ba3b21 160000 --- a/deps/bv-sized-float +++ b/deps/bv-sized-float @@ -1 +1 @@ -Subproject commit f18e76f244a0f49f043873de650ebb92d1546d07 +Subproject commit f6ba3b21379e7c09bc379a32610989b20666b0ef diff --git a/deps/crucible b/deps/crucible index f4145fbe..ad4a5534 160000 --- a/deps/crucible +++ b/deps/crucible @@ -1 +1 @@ -Subproject commit f4145fbed96245f385a91ef3a32e6737df1075ff +Subproject commit ad4a553487eeb5c6bbb5abf4bde26af905bf0254 diff --git a/deps/dismantle b/deps/dismantle index 48433e7c..82849d4a 160000 --- a/deps/dismantle +++ b/deps/dismantle @@ -1 +1 @@ -Subproject commit 48433e7ccb02924b2f4695c8c9f09fb9cfccdfc4 +Subproject commit 82849d4aa097e7e802953286339ef9ea5e0e4bf4 diff --git a/deps/grift b/deps/grift index 819a1fed..3fe3056a 160000 --- a/deps/grift +++ b/deps/grift @@ -1 +1 @@ -Subproject commit 819a1fedf33501a79ad5fbd6e7ae03dfc7219234 +Subproject commit 3fe3056a1d79f27bc8e828bc667653c6595517ca diff --git a/deps/llvm-pretty b/deps/llvm-pretty index 64d43d93..b13493fd 160000 --- a/deps/llvm-pretty +++ b/deps/llvm-pretty @@ -1 +1 @@ -Subproject commit 64d43d9375a819dc2a2df99fb98df24f049dcfaa +Subproject commit b13493fda7276835a4e19bf13a9fb1b3e08083a9 diff --git a/deps/llvm-pretty-bc-parser b/deps/llvm-pretty-bc-parser index cbcf0954..d541adf5 160000 --- a/deps/llvm-pretty-bc-parser +++ b/deps/llvm-pretty-bc-parser @@ -1 +1 @@ -Subproject commit cbcf0954c23da0018df3cc6aae77290ae2efe53b +Subproject commit d541adf5c12e86058cbc1f211456b4ad4a7011a1 diff --git a/deps/macaw-loader b/deps/macaw-loader index f69f3a83..47d19084 160000 --- a/deps/macaw-loader +++ b/deps/macaw-loader @@ -1 +1 @@ -Subproject commit f69f3a835aeaa532206a0e5595b9f89fa1449fb8 +Subproject commit 47d19084a5924f7ebe23f7bc3a89f0f8b314142f diff --git a/deps/semmc b/deps/semmc index 5e774245..1c6ad57c 160000 --- a/deps/semmc +++ b/deps/semmc @@ -1 +1 @@ -Subproject commit 5e77424525e4a6907c83b3ded93a8063679e14a7 +Subproject commit 1c6ad57c36c5dd153335d419b7123af48a95b2b4 diff --git a/deps/what4 b/deps/what4 index 6c462cd4..ffbad75b 160000 --- a/deps/what4 +++ b/deps/what4 @@ -1 +1 @@ -Subproject commit 6c462cd46e0ea9ebbfbd6b6ea237984eeb3dc72a +Subproject commit ffbad75b1ce65577422a19a30a39a5059be8b95f diff --git a/macaw-semmc/src/Data/Macaw/SemMC/Operands.hs b/macaw-semmc/src/Data/Macaw/SemMC/Operands.hs index 57f28893..721568ca 100644 --- a/macaw-semmc/src/Data/Macaw/SemMC/Operands.hs +++ b/macaw-semmc/src/Data/Macaw/SemMC/Operands.hs @@ -6,6 +6,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeSynonymInstances #-} +{-# LANGUAGE UndecidableInstances #-} module Data.Macaw.SemMC.Operands ( ExtractValue(..),