From b287a53fa3e3dffb51febedebff6efb0d1065c2c Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 15 Jul 2017 14:34:29 +0200 Subject: [PATCH] New configure option: --enable-ubsan. If the new option is given, -fsanitize=undefined is passed to the compiler to enable the undefined behavior detector. We don't check whether this option is supported because the configure option is off by default. --- Makefile.in | 2 ++ Makefile.real | 5 +++++ configure.ac | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/Makefile.in b/Makefile.in index d4a83a77..11fa2001 100644 --- a/Makefile.in +++ b/Makefile.in @@ -67,4 +67,6 @@ curses_ldflags := @curses_ldflags@ crypto_ldflags := @crypto_ldflags@ iconv_ldflags := @iconv_ldflags@ +ENABLE_UBSAN := @ENABLE_UBSAN@ + include Makefile.real diff --git a/Makefile.real b/Makefile.real index b88de225..e0296b1f 100644 --- a/Makefile.real +++ b/Makefile.real @@ -129,6 +129,11 @@ STRICT_CFLAGS += -Wno-sign-compare -Wno-unknown-pragmas STRICT_CFLAGS += -Wdeclaration-after-statement STRICT_CFLAGS += -Wformat -Wformat-security -Wmissing-format-attribute +ifeq ($(ENABLE_UBSAN), yes) + STRICT_CFLAGS += -fsanitize=undefined + LDFLAGS += -lubsan +endif + ifeq ($(uname_s),Linux) # these cause warnings on *BSD CPPFLAGS += -Wunused-macros diff --git a/configure.ac b/configure.ac index f518f89a..850e814f 100644 --- a/configure.ac +++ b/configure.ac @@ -373,6 +373,11 @@ AC_CHECK_HEADER(samplerate.h, [], HAVE_SAMPLERATE=no) AC_CHECK_LIB([samplerate], [src_process], [], HAVE_SAMPLERATE=no) LIB_SUBST_FLAGS(samplerate) UNSTASH_FLAGS +######################################################################### ubsan +AC_ARG_ENABLE([ubsan], [AS_HELP_STRING(--enable-ubsan, + [Detect and report undefined behaviour.])], + [ENABLE_UBSAN=yes], [ENABLE_UBSAN=no]) +AC_SUBST(ENABLE_UBSAN) ######################################################################### server if test -n "$CRYPTOLIB" && test $HAVE_OSL = yes && test -n "$BISON" && \ test -n "$FLEX"; then -- 2.39.5