mtklein@google.com | 9f3b0e4 | 2013-10-08 15:16:36 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Build Skia with one of Clang's many sanitizers. |
| 4 | # |
commit-bot@chromium.org | 7eb529f | 2014-04-24 18:16:13 +0000 | [diff] [blame] | 5 | # $ tools/xsan_build {address,thread,undefined,etc.} [any other flags to pass to make...] |
mtklein@google.com | 9f3b0e4 | 2013-10-08 15:16:36 +0000 | [diff] [blame] | 6 | # |
| 7 | # This script assumes the use of Clang >=3.2. |
| 8 | # |
| 9 | # For more information, see: |
| 10 | # http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation |
| 11 | |
| 12 | set -e |
mtklein | 8ca88e4 | 2016-02-03 09:21:44 -0800 | [diff] [blame] | 13 | set -x |
mtklein@google.com | 9f3b0e4 | 2013-10-08 15:16:36 +0000 | [diff] [blame] | 14 | |
mtklein | 013475a | 2016-02-12 12:15:23 -0800 | [diff] [blame] | 15 | here=$(cd `dirname $0`; echo `pwd`) |
| 16 | cores=48 |
| 17 | |
| 18 | echo "Bootstrapping CMake" |
| 19 | pushd $here/../third_party/externals/cmake |
| 20 | ./bootstrap --parallel=$cores |
| 21 | make -j $cores cmake |
| 22 | popd |
| 23 | |
mtklein | 0da8537 | 2016-02-16 14:03:14 -0800 | [diff] [blame] | 24 | cmake=$here/../third_party/externals/cmake/bin/cmake |
| 25 | |
mtklein | 013475a | 2016-02-12 12:15:23 -0800 | [diff] [blame] | 26 | echo "Building Clang" |
| 27 | pushd $here/../third_party/externals/llvm |
| 28 | mkdir -p out/ |
| 29 | cd out/ |
mtklein | 0da8537 | 2016-02-16 14:03:14 -0800 | [diff] [blame] | 30 | rm -f CMakeCache.txt # Force CMake to re-configure, in case DEPS has changed. |
| 31 | $cmake -DCMAKE_BUILD_TYPE=Release -G Ninja .. |
mtklein | 013475a | 2016-02-12 12:15:23 -0800 | [diff] [blame] | 32 | ninja |
| 33 | popd |
| 34 | |
| 35 | export CC=$here/../third_party/externals/llvm/out/bin/clang |
| 36 | export CXX=$here/../third_party/externals/llvm/out/bin/clang++ |
commit-bot@chromium.org | 7eb529f | 2014-04-24 18:16:13 +0000 | [diff] [blame] | 37 | $CC --version |
mtklein@google.com | 9f3b0e4 | 2013-10-08 15:16:36 +0000 | [diff] [blame] | 38 | |
mtklein | 8ca88e4 | 2016-02-03 09:21:44 -0800 | [diff] [blame] | 39 | if [[ "$1" == "memory" ]]; then |
mtklein | 0da8537 | 2016-02-16 14:03:14 -0800 | [diff] [blame] | 40 | echo "Building libc++ with MSAN" |
| 41 | pushd $here/../third_party/externals/llvm |
| 42 | mkdir -p msan_out/ |
| 43 | cd msan_out/ |
| 44 | rm -f CMakeCache.txt # Force CMake to re-configure, in case DEPS has changed. |
| 45 | $cmake -DLLVM_USE_SANITIZER=MemoryWithOrigins -DCMAKE_BUILD_TYPE=Release -G Ninja .. |
| 46 | ninja cxx cxxabi # No need to build all of LLVM+Clang with MSAN, just libc++. |
| 47 | popd |
| 48 | |
| 49 | msan_out=$here/../third_party/externals/llvm/msan_out |
| 50 | |
mtklein | 8ca88e4 | 2016-02-03 09:21:44 -0800 | [diff] [blame] | 51 | export GYP_DEFINES="skia_gpu=0 skia_no_fontconfig=1 skia_freetype_static=1 ${GYP_DEFINES}" |
mtklein | 0da8537 | 2016-02-16 14:03:14 -0800 | [diff] [blame] | 52 | export CXXFLAGS="-stdlib=libc++ -I$msan_out/include ${CXX_FLAGS}" |
| 53 | export LDFLAGS="-stdlib=libc++ -L$msan_out/lib -Wl,-rpath,$msan_out/lib ${LDFLAGS}" |
mtklein | 8ca88e4 | 2016-02-03 09:21:44 -0800 | [diff] [blame] | 54 | fi |
| 55 | export GYP_DEFINES="skia_sanitizer=$1 ${GYP_DEFINES}" |
| 56 | |
| 57 | shift |
| 58 | make $@ |