Skip to content
artur-zawlocki edited this page Oct 31, 2014 · 2 revisions

EVMJIT is a just-in-time compiler and execution engine for EVM bytecode. It translates EVM instructions to LLVM IR (intermediate representation) and uses LLVM backend to generate native code from the IR.

Building EVMJIT on Ubuntu

Follow the instructions for installing dependencies and obtaining sources for cpp-ethereum on Building on Ubuntu.

Installing and building LLVM 3.5

3.5 is the latest stable version of LLVM at the moment of writing this guide. Other versions may work too but have not been tested.

We are going to checkout LLVM sources into ./llvm-3.5-src and build LLVM into ./llvm-3.5-build.

Checkout LLVM 3.5 sources from Subversion repository (detailed instructions on http://llvm.org/releases/3.5.0/docs/GettingStarted.html#checkout-llvm-from-subversion):

mkdir llvm-3.5-src
cd llvm-3.5-src
svn co http://llvm.org/svn/llvm-project/llvm/tags/RELEASE_350/final .

Build LLVM with cmake (detailed instructions on http://llvm.org/releases/3.5.0/docs/CMake.html):

mkdir ../llvm-3.5-build
cd ../llvm-3.5-build
cmake ../llvm-3.5-src
make

Building ethereum with EVMJIT enabled

Now back to the cpp-ethereum building instructions at Building on Ubuntu#user-content-building-the-client. Build ethereum tools as described there, with LLVM_DIR set to the location of LLVM cmake config files and with the additional EVMJIT flag:

cd ../cpp-ethereum/build
cmake .. -DCMAKE_BUILD_TYPE=Release -DHEADLESS=1 -DLLVM_DIR=../../llvm-3.5-build/share/llvm/cmake -DEVMJIT=1

At the end of output from cmake you should see:

-- Found LLVM 3.5.0svn
-- Using LLVMConfig.cmake in: ../../llvm-3.5-build/share/llvm/cmake/
-- Configuring done
-- Generating done
-- Build files have been written to: <cpp-ethereum-root>/build

After running make check that you have libevmjit.so in build/libevmjit and the program evmcc in build/evmcc and you are done.

Building on Windows x64

Build LLVM on Windows x64

  1. Download LLVM 3.5.0 source (http://llvm.org/releases/3.5.0/llvm-3.5.0.src.tar.xz) and unpack it to /llvm folder (same level as cpp-ethereum)

  2. Create & go to folder _build/llvm/x64

  3. Create Visual Studio 2013 project files with cmake

    cmake -G "Visual Studio 12 Win64" -DLLVM_TARGETS_TO_BUILD="X86" ../../../llvm

  4. Open LLVM.sln and build ALL_BUILD project.

Enable LLVM dependency

  1. Open LLVM.props (Property Manager -> LibEvmJit -> Debug | x64 -> LLVM -> Properties), go to User Macros tab and set LLVMEnabled to 1.
  2. Add LibEvmJit dependency for projects eth, TestEthereum (Properties -> References -> Add New Reference...)

Test

Start TestEthereum with option --jit to run tests with JIT.

Using evmcc

Resources (for EVMJIT developers)

See ETC Resources

Clone this wiki locally