Jim Apple | 147c284 | 2017-03-18 12:56:50 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | set -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 Apple | 147c284 | 2017-03-18 12:56:50 -0700 | [diff] [blame] | 8 | # 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 Apple | 117a5cc | 2017-03-29 20:39:36 -0700 | [diff] [blame] | 12 | export CFLAGS="-fsanitize=undefined -fno-sanitize-recover=undefined" |
Jim Apple | 147c284 | 2017-03-18 12:56:50 -0700 | [diff] [blame] | 13 | # Builds without optimization and with debugging symbols for making crash reports more |
| 14 | # readable. |
| 15 | export CFLAGS="${CFLAGS} -O0 -ggdb3" |
| 16 | export CXXFLAGS="${CFLAGS}" |
| 17 | export 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. |
| 22 | CLANG_PATH="$(mktemp -d)" |
| 23 | trap "rm -rf ${CLANG_PATH}" EXIT |
| 24 | ln -s "$(whereis llvm-symbolizer-3.8 | rev | cut -d ' ' -f 1 | rev)" \ |
| 25 | "${CLANG_PATH}/llvm-symbolizer" |
| 26 | export PATH="${CLANG_PATH}:${PATH}" |
| 27 | llvm-symbolizer -version |
| 28 | |
| 29 | build/docker/scripts/autotools.sh $* |