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].
|
|
|
|
|
2018-02-15 14:03:44 +00:00
|
|
|
We find that testing sanitizer builds with libc++ uncovers more issues than
|
|
|
|
with the system-provided C++ standard library, which is usually libstdc++.
|
|
|
|
libc++ proactively hooks into sanitizers to help their analyses.
|
|
|
|
We ship a copy of libc++ with our Linux toolchain in /lib.
|
|
|
|
|
2018-02-05 19:36:34 +00:00
|
|
|
[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
|
2018-02-15 14:03:44 +00:00
|
|
|
of Clang and the instrumented libc++, located in /msan.
|
2018-02-05 19:36:34 +00:00
|
|
|
|
|
|
|
Downloading Clang binaries (Googlers Only)
|
2017-04-10 19:08:59 +00:00
|
|
|
------------------------------------------
|
2018-04-03 19:22:25 +00:00
|
|
|
This requires gsutil, part of the [gcloud sdk](https://cloud.google.com/sdk/downloads).
|
2017-04-10 19:08:59 +00:00
|
|
|
|
2018-11-01 17:38:43 +00:00
|
|
|
<!--?prettify lang=sh?-->
|
|
|
|
|
2017-04-10 19:08:59 +00:00
|
|
|
CLANGDIR="${HOME}/clang"
|
2019-05-13 18:51:45 +00:00
|
|
|
python2 infra/bots/assets/clang_linux/download.py -t $CLANGDIR
|
2017-04-10 19:08:59 +00:00
|
|
|
|
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
|
|
|
|
2018-11-01 17:38:43 +00:00
|
|
|
<!--?prettify lang=sh?-->
|
|
|
|
|
2017-03-02 20:14:07 +00:00
|
|
|
CLANGDIR="${HOME}/clang"
|
|
|
|
|
2019-05-13 18:51:45 +00:00
|
|
|
python2 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
|
|
|
|
------------------------------------
|
|
|
|
|
2018-11-01 17:38:43 +00:00
|
|
|
<!--?prettify lang=sh?-->
|
|
|
|
|
2017-03-02 20:14:07 +00:00
|
|
|
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" ]
|
2018-11-01 17:38:43 +00:00
|
|
|
extra_ldflags = [
|
|
|
|
"-B${CLANGDIR}/bin",
|
|
|
|
"-fuse-ld=lld",
|
|
|
|
"-L${CLANGDIR}/msan",
|
|
|
|
"-Wl,-rpath,${CLANGDIR}/msan" ]
|
2017-03-02 20:14:07 +00:00
|
|
|
sanitize = "MSAN"
|
|
|
|
skia_use_fontconfig = false
|
|
|
|
EOF
|
2019-05-13 18:51:45 +00:00
|
|
|
python2 tools/git-sync-deps
|
2017-03-02 20:14:07 +00:00
|
|
|
bin/gn gen out/msan
|
|
|
|
ninja -C out/msan
|
|
|
|
|
|
|
|
Configure and Compile Skia with ASAN
|
|
|
|
------------------------------------
|
|
|
|
|
2018-11-01 17:38:43 +00:00
|
|
|
<!--?prettify lang=sh?-->
|
|
|
|
|
2017-03-02 20:14:07 +00:00
|
|
|
CLANGDIR="${HOME}/clang"
|
|
|
|
mkdir -p out/asan
|
|
|
|
cat > out/asan/args.gn <<- EOF
|
|
|
|
cc = "${CLANGDIR}/bin/clang"
|
|
|
|
cxx = "${CLANGDIR}/bin/clang++"
|
|
|
|
sanitize = "ASAN"
|
2018-11-01 17:38:43 +00:00
|
|
|
extra_ldflags = [ "-fuse-ld=lld", "-Wl,-rpath,${CLANGDIR}/lib" ]
|
2017-03-02 20:14:07 +00:00
|
|
|
EOF
|
2019-05-13 18:51:45 +00:00
|
|
|
python2 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
|
|
|
|
------------------------------------
|
|
|
|
|
2018-11-01 17:38:43 +00:00
|
|
|
<!--?prettify lang=sh?-->
|
|
|
|
|
2017-03-02 20:14:07 +00:00
|
|
|
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
|
2018-11-01 17:38:43 +00:00
|
|
|
extra_ldflags = [ "-Wl,-rpath,${CLANGDIR}/lib" ]
|
2017-03-02 20:14:07 +00:00
|
|
|
EOF
|
2019-05-13 18:51:45 +00:00
|
|
|
python2 tools/git-sync-deps
|
2017-03-02 20:14:07 +00:00
|
|
|
bin/gn gen out/tsan
|
|
|
|
ninja -C out/tsan
|
|
|
|
|