about summary refs log tree commit diff homepage
path: root/.travis/sanitizer_flags.sh
blob: 4d3dce2c88e165ba6cc4fe4efc34410ffe9bf1f8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# This file is meant to be included by shell scripts
# that need to do a sanitized build.

# Users of this script can use this variable
# to detect if a Sanitized build was enabled.
IS_SANITIZED_BUILD=0

# AddressSanitizer
if [ "X${ASAN_BUILD}" == "X1" ]; then
  echo "Using ASan"
  ASAN_CXX_FLAGS="-fsanitize=address -fno-omit-frame-pointer"
  ASAN_C_FLAGS="${ASAN_CXX_FLAGS}"
  ASAN_LD_FLAGS="${ASAN_CXX_FLAGS}"
  IS_SANITIZED_BUILD=1
else
  echo "Not using ASan"
  ASAN_CXX_FLAGS=""
  ASAN_C_FLAGS=""
  ASAN_LD_FLAGS=""
fi

# Undefined Behaviour Sanitizer
if [ "X${UBSAN_BUILD}" == "X1" ]; then
  echo "Using UBSan"
  UBSAN_CXX_FLAGS="-fsanitize=undefined"
  UBSAN_C_FLAGS="${UBSAN_CXX_FLAGS}"
  UBSAN_LD_FLAGS="${UBSAN_CXX_FLAGS}"
  IS_SANITIZED_BUILD=1
else
  echo "Not using UBSan"
  UBSAN_CXX_FLAGS=""
  UBSAN_C_FLAGS=""
  UBSAN_LD_FLAGS=""
fi

# Set variables to be used by clients.
SANITIZER_CXX_FLAGS="${ASAN_CXX_FLAGS} ${UBSAN_CXX_FLAGS}"
SANITIZER_C_FLAGS="${ASAN_C_FLAGS} ${UBSAN_C_FLAGS}"
SANITIZER_LD_FLAGS="${ASAN_LD_FLAGS} ${UBSAN_LD_FLAGS}"