kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16.git/commit/?id=01a2163989707693bfdd5e34c12ab0d9035a128c

commit 01a2163989707693bfdd5e34c12ab0d9035a128c
Author: Kim Woelders <[email protected]>
Date:   Tue May 5 11:04:13 2020 +0200

    Add feature to build with ASAN (--enable-gcc-asan)
---
 configure.ac     |  2 ++
 dox/Makefile.am  |  2 ++
 eesh/Makefile.am |  2 ++
 lib/Makefile.am  |  2 ++
 m4/ec_asan.m4    | 20 ++++++++++++++++++++
 src/Makefile.am  |  3 +++
 6 files changed, 31 insertions(+)

diff --git a/configure.ac b/configure.ac
index faeb08bf..1da8a26c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -458,6 +458,8 @@ else
   EC_C_WARNINGS()
 fi
 
+EC_C_ASAN()
+
 AC_DEFINE(USE_EXT_INIT_WIN,          1, [Use external init window during 
restart])
 
 AC_DEFINE(ENABLE_DESKRAY,            0, [Enable deskrays (not functional)])
diff --git a/dox/Makefile.am b/dox/Makefile.am
index d1f3d21f..6008616d 100644
--- a/dox/Makefile.am
+++ b/dox/Makefile.am
@@ -9,5 +9,7 @@ edox_SOURCES = dox.c dox.h file.c format.c text.c ttfont.c
 edox_CPPFLAGS = -I$(top_builddir) $(IMLIB2_CFLAGS) $(X_CFLAGS) \
        $(CFLAGS_WARNINGS) -D ENLIGHTENMENT_ROOT=\"$(pkgdatadir)\"
 
+edox_CFLAGS = $(CFLAGS_ASAN)
+
 LDADD = $(IMLIB2_LIBS) $(X_LIBS) $(XINERAMA_LIBS) -lX11 -lm
 
diff --git a/eesh/Makefile.am b/eesh/Makefile.am
index 3f0ade62..02b46058 100644
--- a/eesh/Makefile.am
+++ b/eesh/Makefile.am
@@ -5,5 +5,7 @@ eesh_SOURCES = E.h comms.c main.c
 
 eesh_CPPFLAGS = -I$(top_builddir) $(X_CFLAGS) $(CFLAGS_WARNINGS)
 
+eesh_CFLAGS = $(CFLAGS_ASAN)
+
 LDADD = $(X_LIBS) -lX11
 
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 8323da3c..a7ebd68e 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -5,6 +5,8 @@ libe16_LTLIBRARIES = $(LIB_HACK) $(LIB_TRIP)
 AM_CPPFLAGS = -I$(top_srcdir)/src $(X_CFLAGS) \
              $(CFLAGS_WARNINGS) $(CFLAGS_VISIBILITY)
 
+AM_CFLAGS = $(CFLAGS_ASAN)
+
 if BUILD_LIBHACK
 
 LIB_HACK = libhack.la
diff --git a/m4/ec_asan.m4 b/m4/ec_asan.m4
new file mode 100644
index 00000000..c7d9bfb4
--- /dev/null
+++ b/m4/ec_asan.m4
@@ -0,0 +1,20 @@
+dnl Copyright (C) 2020 Kim Woelders
+dnl This code is public domain and can be freely used or copied.
+
+dnl Macro to set compiler flags in CFLAGS_ASAN
+
+dnl Usage: EC_C_ASAN()
+
+AC_DEFUN([EC_C_ASAN], [
+  AC_ARG_ENABLE(gcc-asan,
+    [AS_HELP_STRING([--enable-gcc-asan],
+                    [compile with ASAN support @<:@default=no@:>@])],,
+    enable_gcc_asan=no)
+
+  if test "x$GCC" = "xyes"; then
+    if test "x$enable_gcc_asan" = "xyes"; then
+      CFLAGS_ASAN="-fsanitize=address -fno-omit-frame-pointer"
+    fi
+  fi
+  AC_SUBST(CFLAGS_ASAN)
+])
diff --git a/src/Makefile.am b/src/Makefile.am
index 0d798849..d6bb01ee 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -119,6 +119,9 @@ e16_SOURCES = \
        $(SRCS_DBUS)            \
        $(SRCS_SNPRINTF)
 
+AM_CFLAGS = \
+       $(CFLAGS_ASAN)
+
 AM_CPPFLAGS = \
        $(CFLAGS_WARNINGS) \
        $(CFLAGS_VISIBILITY) \

-- 


Reply via email to