From: Vincent Bernat Date: Fri, 18 Mar 2016 19:05:03 +0000 (+0100) Subject: build: let configure tell us if we have address sanitizer X-Git-Tag: 0.9.2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dc37bc8d4d8928d9330a027112cf0427d490ac3d;p=thirdparty%2Flldpd.git build: let configure tell us if we have address sanitizer 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. --- diff --git a/configure.ac b/configure.ac index e19a2530..da03047c 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/src/client/client.h b/src/client/client.h index 6563346a..e3ee3525 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -29,12 +29,7 @@ #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 # define SUPPRESS_LEAK(x) __lsan_ignore_object(x) #else