From 8c3bb99fbc6b984b5b7a8db3110558d5dda59e9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= Date: Mon, 29 Apr 2024 18:50:58 -0300 Subject: [PATCH] Upgrade build to GHC 9.6 --- .github/workflows/ci.yml | 2 +- flake.lock | 6 +-- flake.nix | 48 ++++++++++++----- lib/Echidna/UI.hs | 15 +++--- package.yaml | 108 +++++++++++++++++++-------------------- stack.yaml | 14 ++--- 6 files changed, 104 insertions(+), 89 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7cee2c1d6..550362b8d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,7 +65,7 @@ jobs: id: stack if: matrix.container == '' with: - ghc-version: '9.4' + ghc-version: '9.6' enable-stack: true stack-version: 'latest' diff --git a/flake.lock b/flake.lock index 6f81b13f4..27cbdfd65 100644 --- a/flake.lock +++ b/flake.lock @@ -52,11 +52,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1703499205, - "narHash": "sha256-lF9rK5mSUfIZJgZxC3ge40tp1gmyyOXZ+lRY3P8bfbg=", + "lastModified": 1713284584, + "narHash": "sha256-rRuPBJD9+yjz7tY3xC/BvFUwloutynR9piiVE6fhGqo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e1fa12d4f6c6fe19ccb59cac54b5b3f25e160870", + "rev": "2b6ee326ad047870526d9a3ae88dfd0197da898d", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 2b3bcd043..2ea1f1cb0 100644 --- a/flake.nix +++ b/flake.nix @@ -47,22 +47,37 @@ ncurses-static = pkgsStatic.ncurses.override { enableStatic = true; }; - hevm = pkgs: pkgs.haskell.lib.dontCheck ( - pkgs.haskellPackages.callCabal2nix "hevm" (pkgs.fetchFromGitHub { - owner = "trail-of-forks"; + cc-workaround-nix-23138 = + pkgs.writeScriptBin "cc-workaround-nix-23138" '' + if [ "$1" = "--print-file-name" ] && [ "$2" = "c++" ]; then + echo c++ + else + exec cc "$@" + fi + ''; + + hevm = pkgs: pkgs.lib.pipe (pkgs.haskellPackages.callCabal2nix "hevm" (pkgs.fetchFromGitHub { + owner = "elopez"; repo = "hevm"; - rev = "4605dd0f2ed958f2cabe055bd4d5dac8c0e2b77e"; - sha256 = "sha256-NLdqY3DIb9G2JJRZrXBBh9LxxylZM8Mnr7rqSJdrPUg="; - }) { secp256k1 = pkgs.secp256k1; }); + rev = "3065046b2a3d2ac0ea23347ba2699a0f008d26c7"; + sha256 = "sha256-tTgtOgNzmjaLQjJj1/bYvEp0DXabswpl47usTmfqLP8="; + }) { secp256k1 = pkgs.secp256k1; }) + ([ + pkgs.haskell.lib.compose.dontCheck + ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ + (pkgs.haskell.lib.compose.appendConfigureFlag "--ghc-options=-pgml=${cc-workaround-nix-23138}/bin/cc-workaround-nix-23138") + ]); - # FIXME: figure out solc situation, it conflicts with the one from - # solc-select that is installed with slither, disable tests in the meantime - echidna = pkgs: pkgs.haskell.lib.dontCheck ( - with pkgs; lib.pipe + echidna = pkgs: with pkgs; lib.pipe (haskellPackages.callCabal2nix "echidna" ./. { hevm = hevm pkgs; }) - [ + ([ + # FIXME: figure out solc situation, it conflicts with the one from + # solc-select that is installed with slither, disable tests in the meantime + haskell.lib.compose.dontCheck (haskell.lib.compose.addTestToolDepends [ haskellPackages.hpack slither-analyzer solc ]) (haskell.lib.compose.disableCabalFlag "static") + ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ + (pkgs.haskell.lib.compose.appendConfigureFlag "--ghc-options=-pgml=${cc-workaround-nix-23138}/bin/cc-workaround-nix-23138") ]); echidna-static = with pkgsStatic; lib.pipe @@ -78,7 +93,6 @@ "--extra-lib-dirs=${stripDylib (ncurses-static)}/lib" ] ++ (if stdenv.hostPlatform.isDarwin then [ "--extra-lib-dirs=${stripDylib (libiconv.override { enableStatic = true; })}/lib" - "--extra-lib-dirs=${stripDylib (libcxxabi)}/lib" ] else []))) (haskell.lib.compose.enableCabalFlag "static") ]; @@ -108,10 +122,12 @@ # get the list of dynamic libs from otool and tidy the output libs=$(${otool} -L $out/bin/echidna | tail -n +2 | sed 's/^[[:space:]]*//' | cut -d' ' -f1) # get the path for libcxx - cxx=$(echo "$libs" | ${grep} '^/nix/store/.*-libcxx-') + cxx=$(echo "$libs" | ${grep} '^/nix/store/.*/libc++\.') + cxxabi=$(echo "$libs" | ${grep} '^/nix/store/.*/libc++abi\.') # rewrite /nix/... library paths to point to /usr/lib chmod 777 $out/bin/echidna ${install_name_tool} -change "$cxx" /usr/lib/libc++.1.dylib $out/bin/echidna + ${install_name_tool} -change "$cxxabi" /usr/lib/libc++abi.dylib $out/bin/echidna # fix TERMINFO path in ncurses ${perl} -i -pe 's#(${ncurses-static}/share/terminfo)#"/usr/share/terminfo" . "\x0" x (length($1) - 19)#e' $out/bin/echidna # check that no nix deps remain @@ -145,7 +161,11 @@ devShell = with pkgs; haskellPackages.shellFor { packages = _: [ (echidna pkgs) ]; - shellHook = "hpack"; + shellHook = '' + hpack + '' + (if pkgs.stdenv.isDarwin then '' + cabal configure --ghc-options=-pgml=${cc-workaround-nix-23138}/bin/cc-workaround-nix-23138 + '' else ""); buildInputs = [ solc slither-analyzer diff --git a/lib/Echidna/UI.hs b/lib/Echidna/UI.hs index 257aaee9e..f489cd6f7 100644 --- a/lib/Echidna/UI.hs +++ b/lib/Echidna/UI.hs @@ -8,7 +8,10 @@ import Brick import Brick.BChan import Brick.Widgets.Dialog qualified as B import Data.Sequence ((|>)) -import Graphics.Vty (Config, Event(..), Key(..), Modifier(..), defaultConfig, inputMap, mkVty) +import Graphics.Vty.Config (VtyUserConfig, defaultConfig, configInputMap) +import Graphics.Vty.CrossPlatform (mkVty) +import Graphics.Vty.Input.Events +import Graphics.Vty (Event(..), Key(..), Modifier(..)) import Graphics.Vty qualified as Vty import System.Posix import Echidna.UI.Widgets @@ -245,12 +248,12 @@ stopWorkers :: MonadIO m => [(ThreadId, a)] -> m () stopWorkers workers = forM_ workers $ \(threadId, _) -> liftIO $ killThread threadId -vtyConfig :: IO Config +vtyConfig :: IO VtyUserConfig vtyConfig = do - config <- Vty.standardIOConfig - pure config { inputMap = (Nothing, "\ESC[6;2~", EvKey KPageDown [MShift]) : - (Nothing, "\ESC[5;2~", EvKey KPageUp [MShift]) : - inputMap defaultConfig } + pure defaultConfig { configInputMap = [ + (Nothing, "\ESC[6;2~", EvKey KPageDown [MShift]), + (Nothing, "\ESC[5;2~", EvKey KPageUp [MShift]) + ] } -- | Check if we should stop drawing (or updating) the dashboard, then do the right thing. monitor :: MonadReader Env m => m (App UIState UIEvent Name) diff --git a/package.yaml b/package.yaml index 926c6b8ec..e343f9320 100644 --- a/package.yaml +++ b/package.yaml @@ -13,51 +13,17 @@ ghc-options: - -optP-Wno-nonportable-include-path - -fspecialize-aggressively - -fexpose-all-unfoldings + - -Wunused-packages dependencies: - - base - aeson - - base16-bytestring - - binary - - bytestring - - code-page + - base - containers - - data-bword - - data-dword - - deepseq - - extra - directory - - exceptions - - filepath - - hashable - - hevm - - html-entities - - ListLike + - hevm >= 0 - MonadRandom - mtl - - optparse-applicative - - optics - - optics-core - - process - - random - - rosezipper - - semver - - split - text - - transformers - - time - - unliftio - - utf8-string - - vector - - with-utf8 - - word-wrap - - yaml - - http-conduit - - html-conduit - - warp - - wai-extra - - xml-conduit - - strip-ansi-escape language: GHC2021 @@ -73,20 +39,60 @@ default-extensions: library: source-dirs: lib/ - -when: - - condition: "!os(windows)" - cpp-options: -DINTERACTIVE_UI - dependencies: - - brick - - unix - - vty + dependencies: + - base16-bytestring + - binary + - bytestring + - data-bword + - data-dword + - deepseq + - exceptions + - extra + - filepath + - hashable + - html-conduit + - html-entities + - http-conduit + - ListLike + - optics + - optics-core + - process + - random + - rosezipper + - semver + - split + - strip-ansi-escape + - time + - unliftio + - utf8-string + - vector + - wai-extra + - warp + - word-wrap + - xml-conduit + - yaml + when: + - condition: "!os(windows)" + cpp-options: -DINTERACTIVE_UI + dependencies: + - brick + - unix + - vty + - vty-crossplatform executables: echidna: main: Main.hs source-dirs: src/ - dependencies: echidna + dependencies: + - base + - code-page + - echidna + - filepath + - hashable + - optparse-applicative + - time + - with-utf8 ghc-options: - -threaded - '"-with-rtsopts=-A64m -N"' @@ -99,13 +105,8 @@ executables: - -O2 - -optl-pthread - condition: os(darwin) - extra-libraries: c++ ld-options: -Wl,-keep_dwarf_unwind ghc-options: -fcompact-unwind - - condition: os(windows) && impl(ghc >= 9.4) - dependencies: system-cxx-std-lib - - condition: os(windows) && impl(ghc < 9.4) - extra-libraries: stdc++ tests: echidna-testsuite: @@ -125,13 +126,8 @@ tests: - -O2 - -optl-pthread - condition: os(darwin) - extra-libraries: c++ ld-options: -Wl,-keep_dwarf_unwind ghc-options: -fcompact-unwind - - condition: os(windows) && impl(ghc >= 9.4) - dependencies: system-cxx-std-lib - - condition: os(windows) && impl(ghc < 9.4) - extra-libraries: stdc++ flags: static: diff --git a/stack.yaml b/stack.yaml index 932acff27..0df4fb922 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,17 +1,13 @@ -resolver: lts-21.17 +resolver: lts-22.19 packages: - '.' extra-deps: -- git: https://github.com/trail-of-forks/hevm.git - commit: 4605dd0f2ed958f2cabe055bd4d5dac8c0e2b77e +- git: https://github.com/elopez/hevm.git + commit: 3065046b2a3d2ac0ea23347ba2699a0f008d26c7 -- restless-git-0.7@sha256:346a5775a586f07ecb291036a8d3016c3484ccdc188b574bcdec0a82c12db293,968 -- s-cargot-0.1.4.0@sha256:61ea1833fbb4c80d93577144870e449d2007d311c34d74252850bb48aa8c31fb,3525 -- semver-range-0.2.8@sha256:44918080c220cf67b6e7c8ad16f01f3cfe1ac69d4f72e528e84d566348bb23c3,1941 -- HSH-2.1.3@sha256:71ded11b224f5066373ce985ec63b10c87129850b33916736dd64fa2bea9ea0a,1705 -- spool-0.1@sha256:77780cbfc2c0be23ff2ea9e474062f3df97fcd9db946ee0b3508280a923b83e2,1461 - smt2-parser-0.1.0.1@sha256:1e1a4565915ed851c13d1e6b8bb5185cf5d454da3b43170825d53e221f753d77,1421 - spawn-0.3@sha256:b91e01d8f2b076841410ae284b32046f91471943dc799c1af77d666c72101f02,1162 -- strip-ansi-escape-0.1.0.0@sha256:08f2ed93b16086a837ec46eab7ce8d27cf39d47783caaeb818878ea33c2ff75f,1628 +- spool-0.1@sha256:77780cbfc2c0be23ff2ea9e474062f3df97fcd9db946ee0b3508280a923b83e2,1461 +- strip-ansi-escape-0.1.0.0@sha256:08f2ed93b16086a837ec46eab7ce8d27cf39d47783caaeb818878ea33c2ff75f,1628 \ No newline at end of file