]> git.puffer.fish Git - matthieu/frr.git/commitdiff
frr: --enable-address-sanitizer
authorQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 22 Mar 2018 00:47:34 +0000 (20:47 -0400)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 22 Mar 2018 00:47:34 +0000 (20:47 -0400)
Modify Autotools files to support an easy option for enabling ASAN.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
common.am
configure.ac

index c0094b1b88bbe6d7bcc36ce81eed9f4c758d64c4..a52e8311992679bb5713307864d95835c3416068 100644 (file)
--- 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:
index 24d6fa086720226095785d3b40b352a2b0eb1c73..b2a997afdd0eaf47915d2e2c6cd95103bc3fd81a 100755 (executable)
@@ -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)