Commit bff86213 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[gcmole] Modernize gcmole bootstrap script.

This updates the existing bootstrap.sh script for gcmole to work against
LLVM and Clang version 8.0 releases. This is a follow-up to a previous
change which adapted the gcmole plugin to compile against those same
versions.

R=mslekova@chromium.org
BUG=v8:8813

Change-Id: Id6052fb9a7ec8a63d205eab2d4e233e2121c733d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1511275Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60116}
parent 27540226
......@@ -27,11 +27,14 @@
# This is Makefile for clang plugin part of gcmole tool. See README.
LLVM_INCLUDE:=$(LLVM_SRC_ROOT)/include
CLANG_INCLUDE:=$(LLVM_SRC_ROOT)/tools/clang/include
LLVM_SRC_INCLUDE:=$(LLVM_SRC_ROOT)/include
LLVM_BUILD_INCLUDE:=$(BUILD_ROOT)/include
CLANG_SRC_INCLUDE:=$(CLANG_SRC_ROOT)/include
CLANG_BUILD_INCLUDE:=$(BUILD_ROOT)/tools/clang/include
libgcmole.so: gcmole.cc
$(CXX) -I$(LLVM_INCLUDE) -I$(CLANG_INCLUDE) -I. -D_DEBUG \
$(CXX) -I$(LLVM_BUILD_INCLUDE) -I$(LLVM_SRC_INCLUDE) \
-I$(CLANG_BUILD_INCLUDE) -I$(CLANG_SRC_INCLUDE) -I. -D_DEBUG \
-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS \
-D__STDC_LIMIT_MACROS -O3 -fomit-frame-pointer -fno-exceptions \
-fno-rtti -fPIC -Woverloaded-virtual -Wcast-qual -fno-strict-aliasing \
......
......@@ -5,12 +5,12 @@ dependent GC-unsafe places in the V8 codebase.
For example the following code is GC-unsafe:
Handle<Object> Foo(); // Assume Foo can trigger a GC.
void Bar(Object*, Object*);
Handle<Object> Foo(); // Assume Foo can trigger a GC.
void Bar(Object*, Object*);
Handle<Object> baz;
baz->Qux(*Foo()); // (a)
Bar(*Foo(), *baz); // (b)
Handle<Object> baz;
baz->Qux(*Foo()); // (a)
Bar(*Foo(), *baz); // (b)
Both in cases (a) and (b) compiler is free to evaluate call arguments (that
includes receiver) in any order. That means it can dereference baz before
......@@ -19,20 +19,30 @@ on the stack.
PREREQUISITES -----------------------------------------------------------------
1) Install Lua 5.1
(1) Install Lua 5.1
2) Get LLVM 8.0 and Clang 8.0 sources and build them.
$ sudo apt-get install lua5.1
Follow the instructions on http://clang.llvm.org/get_started.html.
(2) Get LLVM 8.0 and Clang 8.0 sources and build them.
Make sure to pass --enable-optimized to configure to get Release build
instead of a Debug one.
Follow the instructions on http://clang.llvm.org/get_started.html.
3) Build gcmole Clang plugin (libgcmole.so)
Make sure to pass -DCMAKE_BUILD_TYPE=Release to cmake to get Release build
instead of a Debug one.
In the tools/gcmole execute the following command:
(3) Build gcmole Clang plugin (libgcmole.so)
LLVM_SRC_ROOT=<path-to-llvm-source-root> make
In the tools/gcmole directory execute the following command:
$ BUILD_ROOT=<path> LLVM_SRC_ROOT=<path> CLANG_SRC_ROOT=<path> make
(*) Note that steps (2) and (3) can also be achieved by just using the included
bootstrapping script in this directory:
$ ./tools/gcmole/bootstrap.sh
This will use "third_party/llvm+clang-build" as a build directory and checkout
required sources in the "third_party" directory.
USING GCMOLE ------------------------------------------------------------------
......
......@@ -28,15 +28,16 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# This script will build libgcmole.so. Building a recent clang needs a
# recent GCC, so if you explicitly want to use GCC 4.8, use:
# recent GCC, so if you explicitly want to use e.g. GCC 4.8, use:
#
# CC=gcc-4.8 CPP=cpp-4.8 CXX=g++-4.8 CXXFLAGS=-static-libstdc++ CXXCPP=cpp-4.8 ./bootstrap.sh
CLANG_RELEASE=3.5
CLANG_RELEASE=8.0
THIS_DIR="$(dirname "${0}")"
THIS_DIR="$(readlink -f "$(dirname "${0}")")"
LLVM_DIR="${THIS_DIR}/../../third_party/llvm"
CLANG_DIR="${LLVM_DIR}/tools/clang"
CLANG_DIR="${THIS_DIR}/../../third_party/clang"
BUILD_DIR="${THIS_DIR}/../../third_party/llvm+clang-build"
LLVM_REPO_URL=${LLVM_URL:-https://llvm.org/svn/llvm-project}
......@@ -70,7 +71,7 @@ if [[ "${OS}" = "Darwin" ]] && xcodebuild -version | grep -q 'Xcode 3.2' ; then
fi
fi
echo Getting LLVM r"${CLANG_RELEASE}" in "${LLVM_DIR}"
echo Getting LLVM release "${CLANG_RELEASE}" in "${LLVM_DIR}"
if ! svn co --force \
"${LLVM_REPO_URL}/llvm/branches/release_${CLANG_RELEASE/./}" \
"${LLVM_DIR}"; then
......@@ -81,7 +82,7 @@ if ! svn co --force \
"${LLVM_DIR}"
fi
echo Getting clang r"${CLANG_RELEASE}" in "${CLANG_DIR}"
echo Getting clang release "${CLANG_RELEASE}" in "${CLANG_DIR}"
svn co --force \
"${LLVM_REPO_URL}/cfe/branches/release_${CLANG_RELEASE/./}" \
"${CLANG_DIR}"
......@@ -97,33 +98,31 @@ elif [ "${OS}" = "Darwin" ]; then
fi
# Build clang.
cd "${LLVM_DIR}"
if [[ ! -f ./config.status ]]; then
../llvm/configure \
--enable-optimized \
--disable-threads \
--disable-pthreads \
--without-llvmgcc \
--without-llvmgxx
if [ ! -e "${BUILD_DIR}" ]; then
mkdir "${BUILD_DIR}"
fi
cd "${BUILD_DIR}"
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=clang "${LLVM_DIR}"
MACOSX_DEPLOYMENT_TARGET=10.5 make -j"${NUM_JOBS}"
# Strip the clang binary.
STRIP_FLAGS=
if [ "${OS}" = "Darwin" ]; then
# See http://crbug.com/256342
STRIP_FLAGS=-x
fi
strip ${STRIP_FLAGS} Release+Asserts/bin/clang
strip ${STRIP_FLAGS} bin/clang
cd -
# Build libgcmole.so
make -C "${THIS_DIR}" clean
make -C "${THIS_DIR}" LLVM_SRC_ROOT="${LLVM_DIR}" libgcmole.so
make -C "${THIS_DIR}" LLVM_SRC_ROOT="${LLVM_DIR}" \
CLANG_SRC_ROOT="${CLANG_DIR}" BUILD_ROOT="${BUILD_DIR}" libgcmole.so
set +x
echo
echo You can now run gcmole using this command:
echo
echo CLANG_BIN=\"third_party/llvm/Release+Asserts/bin\" lua tools/gcmole/gcmole.lua
echo CLANG_BIN=\"third_party/llvm+clang-build/bin\" lua tools/gcmole/gcmole.lua
echo
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment