| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 | 2 |
| 3 # Build Skia with one of Clang's many sanitizers. | 3 # Build Skia with one of Clang's many sanitizers. |
| 4 # | 4 # |
| 5 # $ tools/xsan_build {address,thread,undefined,etc.} [any other flags to pass to
make...] | 5 # $ tools/xsan_build {address,thread,undefined,etc.} [any other flags to pass to
make...] |
| 6 # | 6 # |
| 7 # This script assumes the use of Clang >=3.2. | 7 # This script assumes the use of Clang >=3.2. |
| 8 # | 8 # |
| 9 # For more information, see: | 9 # For more information, see: |
| 10 # http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation | 10 # http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation |
| 11 | 11 |
| 12 set -e | 12 set -e |
| 13 set -x | 13 set -x |
| 14 | 14 |
| 15 here=$(cd `dirname $0`; echo `pwd`) | 15 here=$(cd `dirname $0`; echo `pwd`) |
| 16 cores=48 | 16 cores=48 |
| 17 | 17 |
| 18 echo "Bootstrapping CMake" | 18 echo "Bootstrapping CMake" |
| 19 pushd $here/../third_party/externals/cmake | 19 pushd $here/../third_party/externals/cmake |
| 20 ./bootstrap --parallel=$cores | 20 ./bootstrap --parallel=$cores |
| 21 make -j $cores cmake | 21 make -j $cores cmake |
| 22 popd | 22 popd |
| 23 | 23 |
| 24 cmake=$here/../third_party/externals/cmake/bin/cmake |
| 25 |
| 24 echo "Building Clang" | 26 echo "Building Clang" |
| 25 pushd $here/../third_party/externals/llvm | 27 pushd $here/../third_party/externals/llvm |
| 26 mkdir -p out/ | 28 mkdir -p out/ |
| 27 cd out/ | 29 cd out/ |
| 28 $here/../third_party/externals/cmake/bin/cmake -DCMAKE_BUILD_TYPE=Release -G Nin
ja .. | 30 rm -f CMakeCache.txt # Force CMake to re-configure, in case DEPS has changed. |
| 31 $cmake -DCMAKE_BUILD_TYPE=Release -G Ninja .. |
| 29 ninja | 32 ninja |
| 30 popd | 33 popd |
| 31 | 34 |
| 32 export CC=$here/../third_party/externals/llvm/out/bin/clang | 35 export CC=$here/../third_party/externals/llvm/out/bin/clang |
| 33 export CXX=$here/../third_party/externals/llvm/out/bin/clang++ | 36 export CXX=$here/../third_party/externals/llvm/out/bin/clang++ |
| 34 $CC --version | 37 $CC --version |
| 35 | 38 |
| 36 if [[ "$1" == "memory" ]]; then | 39 if [[ "$1" == "memory" ]]; then |
| 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 chang
ed. |
| 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 |
| 37 export GYP_DEFINES="skia_gpu=0 skia_no_fontconfig=1 skia_freetype_static=1 $
{GYP_DEFINES}" | 51 export GYP_DEFINES="skia_gpu=0 skia_no_fontconfig=1 skia_freetype_static=1 $
{GYP_DEFINES}" |
| 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 ${LD
FLAGS}" |
| 38 fi | 54 fi |
| 39 export GYP_DEFINES="skia_sanitizer=$1 ${GYP_DEFINES}" | 55 export GYP_DEFINES="skia_sanitizer=$1 ${GYP_DEFINES}" |
| 40 | 56 |
| 41 shift | 57 shift |
| 42 make $@ | 58 make $@ |
| OLD | NEW |