2013-10-08 15:16:36 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Build Skia with one of Clang's many sanitizers.
|
|
|
|
#
|
2014-04-24 18:16:13 +00:00
|
|
|
# $ tools/xsan_build {address,thread,undefined,etc.} [any other flags to pass to make...]
|
2013-10-08 15:16:36 +00:00
|
|
|
#
|
|
|
|
# This script assumes the use of Clang >=3.2.
|
|
|
|
#
|
|
|
|
# For more information, see:
|
|
|
|
# http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation
|
|
|
|
|
|
|
|
set -e
|
2016-02-03 17:21:44 +00:00
|
|
|
set -x
|
2013-10-08 15:16:36 +00:00
|
|
|
|
2016-02-12 20:15:23 +00:00
|
|
|
here=$(cd `dirname $0`; echo `pwd`)
|
|
|
|
cores=48
|
|
|
|
|
|
|
|
echo "Bootstrapping CMake"
|
|
|
|
pushd $here/../third_party/externals/cmake
|
|
|
|
./bootstrap --parallel=$cores
|
|
|
|
make -j $cores cmake
|
|
|
|
popd
|
|
|
|
|
2016-02-16 22:03:14 +00:00
|
|
|
cmake=$here/../third_party/externals/cmake/bin/cmake
|
|
|
|
|
2016-02-12 20:15:23 +00:00
|
|
|
echo "Building Clang"
|
|
|
|
pushd $here/../third_party/externals/llvm
|
|
|
|
mkdir -p out/
|
|
|
|
cd out/
|
2016-02-16 22:03:14 +00:00
|
|
|
rm -f CMakeCache.txt # Force CMake to re-configure, in case DEPS has changed.
|
|
|
|
$cmake -DCMAKE_BUILD_TYPE=Release -G Ninja ..
|
2016-02-12 20:15:23 +00:00
|
|
|
ninja
|
|
|
|
popd
|
|
|
|
|
|
|
|
export CC=$here/../third_party/externals/llvm/out/bin/clang
|
|
|
|
export CXX=$here/../third_party/externals/llvm/out/bin/clang++
|
2016-02-03 17:21:44 +00:00
|
|
|
$CC --version
|
2013-10-08 15:16:36 +00:00
|
|
|
|
2016-02-03 17:21:44 +00:00
|
|
|
if [[ "$1" == "memory" ]]; then
|
2016-02-16 22:03:14 +00:00
|
|
|
echo "Building libc++ with MSAN"
|
|
|
|
pushd $here/../third_party/externals/llvm
|
|
|
|
mkdir -p msan_out/
|
|
|
|
cd msan_out/
|
|
|
|
rm -f CMakeCache.txt # Force CMake to re-configure, in case DEPS has changed.
|
|
|
|
$cmake -DLLVM_USE_SANITIZER=MemoryWithOrigins -DCMAKE_BUILD_TYPE=Release -G Ninja ..
|
|
|
|
ninja cxx cxxabi # No need to build all of LLVM+Clang with MSAN, just libc++.
|
|
|
|
popd
|
|
|
|
|
|
|
|
msan_out=$here/../third_party/externals/llvm/msan_out
|
|
|
|
|
2016-02-03 17:21:44 +00:00
|
|
|
export GYP_DEFINES="skia_gpu=0 skia_no_fontconfig=1 skia_freetype_static=1 ${GYP_DEFINES}"
|
2016-02-16 22:03:14 +00:00
|
|
|
export CXXFLAGS="-stdlib=libc++ -I$msan_out/include ${CXX_FLAGS}"
|
|
|
|
export LDFLAGS="-stdlib=libc++ -L$msan_out/lib -Wl,-rpath,$msan_out/lib ${LDFLAGS}"
|
2013-10-08 15:16:36 +00:00
|
|
|
fi
|
2016-02-03 17:21:44 +00:00
|
|
|
export GYP_DEFINES="skia_sanitizer=$1 ${GYP_DEFINES}"
|
2013-10-08 15:16:36 +00:00
|
|
|
|
2016-02-03 17:21:44 +00:00
|
|
|
shift
|
|
|
|
make $@
|