Merge branch 'refs/heads/t/ubsan'
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 28 Nov 2021 17:10:11 +0000 (18:10 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 28 Nov 2021 17:11:17 +0000 (18:11 +0100)
A single patch which adds an option to ./configure to instruct the
compiler to activate its undefined behaviour checker.

Cooking for two months.

* refs/heads/t/ubsan:
  New configure option: --enable-ubsan.

Makefile.in
Makefile.real
NEWS.md
configure.ac

index d4a83a776eec0dfd602aa4329a72718cc15ea7f4..11fa2001d1e6678cdc8968d58d6729d7ce0955b4 100644 (file)
@@ -67,4 +67,6 @@ curses_ldflags := @curses_ldflags@
 crypto_ldflags := @crypto_ldflags@
 iconv_ldflags := @iconv_ldflags@
 
+ENABLE_UBSAN := @ENABLE_UBSAN@
+
 include Makefile.real
index b88de22533048979bcfef8f3396b7608297afb3b..e0296b1fe2f1909b785b6a329238e334d456168b 100644 (file)
@@ -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/NEWS.md b/NEWS.md
index 1082671002acf196e004abae216f8b6dd1957c65..292cfa43fa2e4da0c1532138ed4f0779c53a544d 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -11,6 +11,8 @@ NEWS
 - The alsa writer no longer warns about spurious underruns.
 - The score formula  of the audio file selector has been reworked.
 - Cleanups of the doubly linked lists code.
+- New option for configure: --enable-ubsan to detect and report undefined
+  behaviour.
 
 --------------------------------------
 0.6.4 (2021-11-04) "fuzzy calibration"
index f518f89af154933ffaa64401ba1086b7e3f369c9..850e814f21cbe3601441f3f625a712290b7d3015 100644 (file)
@@ -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