2017-03-06 15:32:54 +00:00
|
|
|
MSAN, ASAN, & TSAN
|
|
|
|
==================
|
|
|
|
|
|
|
|
*Testing Skia with memory, address, and thread santizers.*
|
2017-03-02 20:14:07 +00:00
|
|
|
|
2018-02-05 19:36:34 +00:00
|
|
|
Compiling Skia with ASAN, UBSAN, or TSAN can be done with the latest version of Clang.
|
|
|
|
|
|
|
|
- UBSAN works on Linux, Mac, Android, and Windows, though some checks are platform-specific.
|
|
|
|
- ASAN works on Linux, Mac, Android.
|
|
|
|
- TSAN works on Linux and Mac.
|
|
|
|
- MSAN works on Linux[1].
|
|
|
|
|
|
|
|
[1]To compile and run with MSAN, an MSAN-instrumented version of libc++ is needed.
|
|
|
|
It's generally easiest to run one of the following 2 steps to build/download a recent version
|
|
|
|
of Clang and the instrumented libc++.
|
|
|
|
|
|
|
|
Downloading Clang binaries (Googlers Only)
|
2017-04-10 19:08:59 +00:00
|
|
|
------------------------------------------
|
|
|
|
|
|
|
|
CLANGDIR="${HOME}/clang"
|
|
|
|
python infra/bots/assets/clang_linux/download.py -t $CLANGDIR
|
|
|
|
|
2018-02-05 19:36:34 +00:00
|
|
|
Building Clang binaries from scratch (Other users)
|
2017-04-10 19:08:59 +00:00
|
|
|
---------------------------
|
2017-03-02 20:14:07 +00:00
|
|
|
|
|
|
|
CLANGDIR="${HOME}/clang"
|
|
|
|
|
2017-03-14 14:03:51 +00:00
|
|
|
python tools/git-sync-deps
|
2017-03-02 20:14:07 +00:00
|
|
|
CC= CXX= infra/bots/assets/clang_linux/create.py -t "$CLANGDIR"
|
|
|
|
|
|
|
|
Configure and Compile Skia with MSAN
|
|
|
|
------------------------------------
|
|
|
|
|
|
|
|
CLANGDIR="${HOME}/clang"
|
|
|
|
mkdir -p out/msan
|
|
|
|
cat > out/msan/args.gn <<- EOF
|
|
|
|
cc = "${CLANGDIR}/bin/clang"
|
|
|
|
cxx = "${CLANGDIR}/bin/clang++"
|
2017-10-17 19:32:52 +00:00
|
|
|
extra_cflags = [ "-B${CLANGDIR}/bin" ]
|
|
|
|
extra_ldflags = [ "-B${CLANGDIR}/bin", "-fuse-ld=lld", "-L${CLANGDIR}/msan" ]
|
2017-03-02 20:14:07 +00:00
|
|
|
sanitize = "MSAN"
|
|
|
|
skia_use_fontconfig = false
|
|
|
|
EOF
|
2017-03-14 14:03:51 +00:00
|
|
|
python tools/git-sync-deps
|
2017-03-02 20:14:07 +00:00
|
|
|
bin/gn gen out/msan
|
|
|
|
ninja -C out/msan
|
|
|
|
|
2017-10-18 18:43:41 +00:00
|
|
|
When you run a binary built with MSAN, make sure you force it to use our
|
|
|
|
MSAN-instrumented libc++:
|
2017-10-17 19:32:52 +00:00
|
|
|
|
2017-10-18 18:43:41 +00:00
|
|
|
env LD_LIBRARY_PATH=$CLANGDIR/msan out/dm ...
|
2017-10-17 19:32:52 +00:00
|
|
|
|
2017-03-02 20:14:07 +00:00
|
|
|
Configure and Compile Skia with ASAN
|
|
|
|
------------------------------------
|
|
|
|
|
|
|
|
CLANGDIR="${HOME}/clang"
|
|
|
|
mkdir -p out/asan
|
|
|
|
cat > out/asan/args.gn <<- EOF
|
|
|
|
cc = "${CLANGDIR}/bin/clang"
|
|
|
|
cxx = "${CLANGDIR}/bin/clang++"
|
|
|
|
sanitize = "ASAN"
|
|
|
|
EOF
|
2017-03-14 14:03:51 +00:00
|
|
|
python tools/git-sync-deps
|
2017-03-02 20:14:07 +00:00
|
|
|
bin/gn gen out/asan
|
|
|
|
ninja -C out/asan
|
|
|
|
|
|
|
|
Configure and Compile Skia with TSAN
|
|
|
|
------------------------------------
|
|
|
|
|
|
|
|
CLANGDIR="${HOME}/clang"
|
|
|
|
mkdir -p out/tsan
|
|
|
|
cat > out/tsan/args.gn <<- EOF
|
|
|
|
cc = "${CLANGDIR}/bin/clang"
|
|
|
|
cxx = "${CLANGDIR}/bin/clang++"
|
|
|
|
sanitize = "TSAN"
|
|
|
|
is_debug = false
|
|
|
|
EOF
|
2017-03-14 14:03:51 +00:00
|
|
|
python tools/git-sync-deps
|
2017-03-02 20:14:07 +00:00
|
|
|
bin/gn gen out/tsan
|
|
|
|
ninja -C out/tsan
|
|
|
|
|
|
|
|
|