Skip to content

Commit

Permalink
Upgrade build to GHC 9.6
Browse files Browse the repository at this point in the history
  • Loading branch information
elopez committed Apr 29, 2024
1 parent 33c431b commit 8c3bb99
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 34 additions & 14 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
];
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions lib/Echidna/UI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
108 changes: 52 additions & 56 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"'
Expand All @@ -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:
Expand All @@ -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:
Expand Down
14 changes: 5 additions & 9 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8c3bb99

Please sign in to comment.