]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
build: let configure tell us if we have address sanitizer
authorVincent Bernat <vincent@bernat.im>
Fri, 18 Mar 2016 19:05:03 +0000 (20:05 +0100)
committerVincent Bernat <vincent@bernat.im>
Fri, 18 Mar 2016 19:21:31 +0000 (20:21 +0100)
We cannot really rely on __has_feature or __ADDRESS_SANITIZER__ in code
since we are mostly interested in the leak sanitizer and there is
neither a feature nor a macro for that. Early version of GCC have the
address sanitizer, but not the leak sanitizer. We don't support this
configuration, but we need to build correctly either way. So, the user
is expected to enable address sanitizers only on configuration
supporting also the leak sanitizer.

configure.ac
src/client/client.h

index e19a253045f306b7ce1b2d7f7d50241c75182e46..da03047cc6512868ee4b41969a2230266d922cf2 100644 (file)
@@ -126,8 +126,11 @@ case "$enableval" in
     yes) sanitizers="-fsanitize=address" ;;
     *) sanitizers="-fsanitize=$enableval" ;;
 esac
-LLDP_CFLAGS="$LLDP_CFLAGS $sanitizers"
-LLDP_LDFLAGS="$LLDP_LDFLAGS $sanitizers"
+if test x"$sanitizers" != x; then
+  LLDP_CFLAGS="$LLDP_CFLAGS $sanitizers"
+  LLDP_LDFLAGS="$LLDP_LDFLAGS $sanitizers"
+  AC_DEFINE([HAVE_ADDRESS_SANITIZER], 1, [Define if have both address and leak sanitizer])
+fi
   ])
 
 # OS
index 6563346af37932ee745396c22cd0250b6f5f4db7..e3ee35250411f1bbcd62b9380e4ac9460ea5fb6b 100644 (file)
 #include "../compat/compat.h"
 #include "writer.h"
 
-#if defined(__has_feature)
-# if __has_feature(address_sanitizer)
-#  define __SANITIZE_ADDRESS__
-# endif
-#endif
-#ifdef __SANITIZE_ADDRESS__
+#ifdef HAVE_ADDRESS_SANITIZER
 # include <sanitizer/lsan_interface.h>
 # define SUPPRESS_LEAK(x) __lsan_ignore_object(x)
 #else