Skip to content

Instantly share code, notes, and snippets.

@adietrichs
Last active October 16, 2022 19:35
Show Gist options
  • Save adietrichs/2ad35e57290a9b16359ea5f8f2f310bd to your computer and use it in GitHub Desktop.
Save adietrichs/2ad35e57290a9b16359ea5f8f2f310bd to your computer and use it in GitHub Desktop.
Dapptools Apple Silicon

disclaimer: I don't really know what I am doing - this is probably not the best way to go.

Based on: https://github.com/dapphub/dapptools/tree/master/src/hevm#building-with-stack-or-cabal

Install ghc and cabal

following: https://www.haskell.org/ghcup/

install ghc 8.10.7 and cabal via:

curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

Compile latest version of libBF

git clone https://github.com/GaloisInc/libBF-hs.git
cd libBF-hs
cabal install --lib

The output should include a line like

Wrote tarball sdist to /path/to/libBF-hs/dist-newstyle/sdist/libBF-0.6.3.tar.gz

note the /path/to/libBF-hs/dist-newstyle/sdist/

Modify Cabal config

modify ~/.cabal/config, add at the bottom:

repository my-local-repository
  url: file+noindex:///path/to/libBF-hs/dist-newstyle/sdist/

where you replace /path/to/libBF-hs/dist-newstyle/sdist/ with the actual path from the previous step

Install Dependencies

secp256k1

git clone https://github.com/bitcoin-core/secp256k1.git
cd secp256k1
./autogen.sh
./configure --enable-module-recovery # for generating secp256k1_recovery.h
make
sudo make install

homebrew (skip if already installed)

following: https://docs.brew.sh/Installation

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

libff

brew install boost cmake gmp libsodium
git clone https://github.com/scipr-lab/libff --recursive
cd libff
mkdir build && cd build
cmake .. -DOPENSSL_ROOT_DIR=$(brew --prefix openssl) -DCURVE=ALT_BN128 -DUSE_ASM=OFF
make
sudo make install

Hevm

brew install llvm
export PATH="$(brew --prefix llvm)/bin:$PATH"
git clone https://github.com/dapphub/dapptools.git

modify dapptools/src/hevm/ethjet/ethjet-ff.cc: replace line 6 #include <libff/algebra/fields/bigint.hpp> with #include <libff/algebra/field_utils/bigint.hpp>

cd dapptools/src/hevm
cabal v2-update && cabal v2-configure
cabal v2-install

Workaround for 'gmp.h' file not found

modify dapptools/src/hevm/hevm.cabal

in library section, add:

  include-dirs:
    /path/to/gmp/include

where /path/to/gmp is the output of echo $(brew --prefix gmp) (don't forget the /include)

@scvsh
Copy link

scvsh commented Oct 16, 2022

If you're like me and trying to install this from scratch, ghcup will likely install the higher version of ghc, resulting in conflicting dependencies. To use the correct ghc:
ghcup install ghc 8.10.7
ghcup set ghc 8.10.7
right after the initial curl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment