From b3594690d9d34c44229e7bcba49f8b0a453f0d73 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Wed, 14 Oct 2020 18:17:34 +0200 Subject: [PATCH] configure: allow to run with UB sanitizer Signed-off-by: Antoine Poinsot --- Makefile | 4 ++++ configure | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/Makefile b/Makefile index 13d6b4de48cd..95e298b0624b 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,10 @@ ifneq ($(ASAN),0) SANITIZER_FLAGS += -fsanitize=address endif +ifneq ($(UBSAN),0) +SANITIZER_FLAGS += -fsanitize=undefined +endif + ifneq ($(FUZZING), 0) SANITIZER_FLAGS += -fsanitize=fuzzer-no-link endif diff --git a/configure b/configure index da10c4664270..4f649916fb74 100755 --- a/configure +++ b/configure @@ -115,6 +115,7 @@ set_defaults() COMPAT=${COMPAT:-1} STATIC=${STATIC:-0} ASAN=${ASAN:-0} + UBSAN=${UBSAN:-0} PYTEST=${PYTEST-$(default_pytest)} COPTFLAGS=${COPTFLAGS-$(default_coptflags "$DEVELOPER")} CONFIGURATOR_CC=${CONFIGURATOR_CC-$CC} @@ -156,6 +157,8 @@ usage() echo " Static link sqlite3, gmp and zlib libraries" usage_with_default "--enable/disable-address-sanitizer" "$ASAN" "enable" "disable" echo " Compile with address-sanitizer" + usage_with_default "--enable/disable-ub-sanitizer" "$UBSAN" "enable" "disable" + echo " Compile with undefined behaviour sanitizer" usage_with_default "--enable/disable-fuzzing" "$FUZZING" "enable" "disable" exit 1 } @@ -208,6 +211,8 @@ for opt in "$@"; do --disable-static) STATIC=0;; --enable-address-sanitizer) ASAN=1;; --disable-address-sanitizer) ASAN=0;; + --enable-ub-sanitizer) UBSAN=1;; + --disable-ub-sanitize) UBSAN=0;; --enable-fuzzing) FUZZING=1;; --disable-fuzzing) FUZZING=0;; --help|-h) usage;; @@ -413,6 +418,7 @@ add_var COMPAT "$COMPAT" $CONFIG_HEADER add_var PYTEST "$PYTEST" add_var STATIC "$STATIC" add_var ASAN "$ASAN" +add_var UBSAN "$UBSAN" add_var TEST_NETWORK "$TEST_NETWORK" add_var HAVE_PYTHON3_MAKO "$HAVE_PYTHON3_MAKO" add_var SHA256SUM "$SHA256SUM"