Skip to content
Vladislav Ivanishin edited this page Sep 8, 2016 · 28 revisions

We are going to check out sources of LLV8 and the modified LLVM. V8 (and thus LLV8) comes with binaries of a clang compiler, so we are going to use it to build both LLVM and LLV8 to avoid linking problems.

Checking out LLV8

The easiest way is to follow the process of building regular V8, adding the LLV8 branch as a remote.

cd $LLV8_ROOT # Choose any directory you want. 
# E.g. cd /some/dir && export LLV8_ROOT=`pwd`

Install depot_tools:

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=`pwd`/depot_tools:"$PATH"

Fetch all the code:

fetch v8
cd v8
git remote add llv8 https://github.com/ispras/llv8.git
git fetch llv8
git checkout -b llv8 llv8/llv8
gclient sync

Note that we don't run make yet, since first we need to build LLVM libraries to link against. We had to check out V8 first to obtain the clang compiler though.

LLVM

Check out and build our version of LLVM:

cd $LLV8_ROOT
git clone https://github.com/ispras/llvm-for-v8.git
mkdir build-llvm
cd build-llvm
export CC=$LLV8_ROOT/v8/third_party/llvm-build/Release+Asserts/bin/clang
export CXX=$LLV8_ROOT/v8/third_party/llvm-build/Release+Asserts/bin/clang++
../llvm-for-v8/configure --enable-assertions --enable-optimized --disable-zlib
make -j9
sudo make install # Note: this installs the built version of llvm system-wide.

You can in theory pass --prefix to configure or not install llvm at all and use it from the build directory, because all you need to build llv8 is the llvm-configure of this freshly built llvm in your $PATH. But this makes the subsequent compilation of llv8 a bit more involved (the C++ compiler spews warnings-errors as it compiles LLVM headers).

Building LLV8

Finally, run make (substitute "release" for "debug" if you'd like to test performance):

cd $LLV8_ROOT/v8
export LINK=$CXX
make x64.debug -j9 i18nsupport=off gdbjit=off

Caveats

By default v8's make uses the clang compiler from v8/third_party/llvm-build/Release+Asserts/bin. If you use different compilers for building llvm and v8, make sure they conform to the same ABI. Newer versions of g++ use C++11 ABI by default, the behavior is controlled with the _GLIBCXX_USE_CXX11_ABI flag.