2 # This file is used by build.sh to setup sanitizers.
7 # This tracks what sanitizers are enabled so they don't get enabled twice. This
8 # means that doing things that enable the same sanitizer twice (such as enabling
9 # both --asan and --fuzz) is order-dependent: only the first is used.
13 for i
in "${sanitizers[@]}"; do
14 [ "$san" = "$i" ] && return
18 if [ -z "$sanitizer_flags" ]; then
19 gyp_params
+=(-Dno_zdefs=1)
22 local cflags
=$
(python
$cwd/coreconf
/sanitizers.py
"$@")
23 sanitizer_flags
="$sanitizer_flags $cflags"
28 local clang_version
=$
($CC --version |
grep -oE '([0-9]{1,}\.)+[0-9]{1,}')
29 if [[ ${clang_version:0:1} -lt 4 && ${clang_version:0:1} -eq 3 && ${clang_version:2:1} -lt 9 ]]; then
30 echo "Need at least clang-3.9 (better 4.0) for sancov." 1>&2
37 elif [ "${clang_version:0:3}" = "3.9" ]; then
38 sancov
=edge
,indirect-calls
,8bit-counters
40 sancov
=trace-pc-guard
,trace-cmp
42 enable_sanitizer sancov
"$sancov"
47 enable_sanitizer sourcecov
56 ubsan
=undefined
,local-bounds
58 enable_sanitizer ubsan
"$ubsan"
61 # Not strictly a sanitizer, but the pattern fits
65 [ "${#scanbuild[@]}" -gt 0 ] && return
67 scanbuild
=(scan-build
)
71 # pass on CC and CCC to scanbuild
73 scanbuild
+=(--use-cc="$CC")
75 if [ -n "$CCC" ]; then
76 scanbuild
+=(--use-c++="$CCC")
82 "${scanbuild[@]}" "$@"