Add a build flag for the undefined behavior sanitizer, aka "ubsan".

Ubsan checks for undefined behavior according to the C++
standard. Some of this behavior has been known to be exploited by
optimizing compilers to produce bizarre results, like taking both
branches of a conditional.

This patch only adds build options; fixing the errors ubsan finds, as
well as adding any tests that a build is free from ubsan errors, are
not covered in this patch.

Change-Id: I03044c657ac171daa0648f833bbbeed7bdde49cb
Reviewed-on: http://gerrit.cloudera.org:8080/6186
Reviewed-by: Dan Hecht <dhecht@cloudera.com>
Tested-by: Impala Public Jenkins
This commit is contained in:
Jim Apple
2017-02-28 12:01:13 -08:00
committed by Impala Public Jenkins
parent 1417d764e4
commit 93eb8ccbed
6 changed files with 36 additions and 4 deletions

View File

@@ -59,6 +59,7 @@ CODE_COVERAGE=0
BUILD_ASAN=0
BUILD_FE_ONLY=0
BUILD_TIDY=0
BUILD_UBSAN=0
# Export MAKE_CMD so it is visible in scripts that invoke make, e.g. copy-udfs-udas.sh
export MAKE_CMD=make
LZO_CMAKE_ARGS=
@@ -114,6 +115,9 @@ do
-tidy)
BUILD_TIDY=1
;;
-ubsan)
BUILD_UBSAN=1
;;
-testpairwise)
EXPLORATION_STRATEGY=pairwise
;;
@@ -182,6 +186,7 @@ do
echo "[-codecoverage] : Build with code coverage [Default: False]"
echo "[-asan] : Address sanitizer build [Default: False]"
echo "[-tidy] : clang-tidy build [Default: False]"
echo "[-ubsan] : Undefined behavior build [Default: False]"
echo "[-skiptests] : Skips execution of all tests"
echo "[-notests] : Skips building and execution of all tests"
echo "[-start_minicluster] : Start test cluster including Impala and all"\
@@ -260,6 +265,9 @@ fi
if [[ ${BUILD_TIDY} -eq 1 ]]; then
CMAKE_BUILD_TYPE=TIDY
fi
if [[ ${BUILD_UBSAN} -eq 1 ]]; then
CMAKE_BUILD_TYPE=UBSAN
fi
MAKE_IMPALA_ARGS+=" -build_type=${CMAKE_BUILD_TYPE}"