blob: e1e82c9c5aad2b25496d73bcec348f6fd91c0a4e [file] [log] [blame]
Jim Apple147c2842017-03-18 12:56:50 -07001#!/bin/sh
2
3set -ex
4
5# Wraps autotools.sh, but each binary crashes if it exhibits undefined behavior. See
6# http://releases.llvm.org/3.8.0/tools/clang/docs/UndefinedBehaviorSanitizer.html
7
Jim Apple147c2842017-03-18 12:56:50 -07008# Set the undefined behavior flags. This crashes on all undefined behavior except for
9# undefined casting, aka "vptr".
10#
11# TODO: fix undefined vptr behavior and turn this option back on.
Jim Apple117a5cc2017-03-29 20:39:36 -070012export CFLAGS="-fsanitize=undefined -fno-sanitize-recover=undefined"
Jim Apple147c2842017-03-18 12:56:50 -070013# Builds without optimization and with debugging symbols for making crash reports more
14# readable.
15export CFLAGS="${CFLAGS} -O0 -ggdb3"
16export CXXFLAGS="${CFLAGS}"
17export UBSAN_OPTIONS=print_stacktrace=1
18
19# llvm-symbolizer must be on PATH, but the above installation instals a binary called
20# "llvm-symbolizer-3.8", not "llvm-symbolizer". This fixes that with a softlink in a new
21# directory.
22CLANG_PATH="$(mktemp -d)"
23trap "rm -rf ${CLANG_PATH}" EXIT
24ln -s "$(whereis llvm-symbolizer-3.8 | rev | cut -d ' ' -f 1 | rev)" \
25 "${CLANG_PATH}/llvm-symbolizer"
26export PATH="${CLANG_PATH}:${PATH}"
27llvm-symbolizer -version
28
29build/docker/scripts/autotools.sh $*