From fac8a744c6033a9c03a3edd40e4fc4a0f72e6e1f Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Wed, 21 Mar 2018 20:47:34 -0400 Subject: [PATCH] frr: --enable-address-sanitizer Modify Autotools files to support an easy option for enabling ASAN. Signed-off-by: Quentin Young --- common.am | 3 ++- configure.ac | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/common.am b/common.am index c0094b1b88..a52e831199 100644 --- a/common.am +++ b/common.am @@ -8,12 +8,13 @@ am__v_CLIPPY_ = $(am__v_CLIPPY_$(AM_DEFAULT_VERBOSITY)) am__v_CLIPPY_0 = @echo " CLIPPY " $@; am__v_CLIPPY_1 = +CLIPPY_SUPPRESSIONS = LSAN_OPTIONS="suppressions=$(top_builddir)/tools/lsan-suppressions.txt" CLIPPY_DEPS = $(HOSTTOOLS)lib/clippy $(top_srcdir)/python/clidef.py SUFFIXES = _clippy.c .proto .pb-c.c .pb-c.h .pb.h .c_clippy.c: @{ test -x $(top_builddir)/$(HOSTTOOLS)lib/clippy || $(MAKE) -C $(top_builddir)/$(HOSTTOOLS) lib/clippy; } - $(AM_V_CLIPPY)$(top_builddir)/$(HOSTTOOLS)lib/clippy $(top_srcdir)/python/clidef.py -o $@ $< + $(AM_V_CLIPPY) $(CLIPPY_SUPPRESSIONS) $(top_builddir)/$(HOSTTOOLS)lib/clippy $(top_srcdir)/python/clidef.py -o $@ $< ## automake's "ylwrap" is a great piece of GNU software... not. .l.c: diff --git a/configure.ac b/configure.ac index 24d6fa0867..b2a997afdd 100755 --- a/configure.ac +++ b/configure.ac @@ -185,6 +185,17 @@ CC="${CC% -std=c99}" AC_C_FLAG([-std=gnu11], [CC="$ac_cc"], [CC="$CC -std=gnu11"]) +dnl AddressSanitizer support +AC_ARG_ENABLE([address-sanitizer], AS_HELP_STRING([--enable-address-sanitizer], \ + [enabled AddressSanitizer support for detecting a wide variety of \ + memory allocation and deallocation errors]), \ + [AC_DEFINE(HAVE_ADDRESS_SANITIZER, 1, [enable AddressSanitizer]) + CFLAGS="$CFLAGS -fsanitize=address" + CXXFLAGS="$CXXFLAGS -fsanitize=address" + AC_TRY_COMPILE([],[const int i=0;],[AC_MSG_NOTICE([Address Sanitizer Enabled])], + [AC_MSG_ERROR([Address Sanitizer not available])]) + ]) + dnl if the user has specified any CFLAGS, override our settings if test "x${enable_dev_build}" = "xyes"; then AC_DEFINE(DEV_BUILD,,Build for development) -- 2.39.5