summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2021-01-14 12:13:28 +0100
committerAlexander Larsson <alexander.larsson@gmail.com>2021-01-14 12:43:46 +0100
commit97a153fe0a8612909c43f24701ff84b769284e73 (patch)
tree92a37e20162a7822356fba506382fce5e0146d0a
parentdad9a9c20d75158256c1cefea99e0dfacb776809 (diff)
downloadflatpak-97a153fe0a8612909c43f24701ff84b769284e73.tar.gz
Add --enable-asan option
This passes -fsanitize=address in the right place. Passing it this way instead of CFLAGS allows us to strategically not add sanitize in specific places as needed.
-rw-r--r--Makefile.am8
-rw-r--r--configure.ac7
2 files changed, 14 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index 99f944b5..3e8a93c1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -56,7 +56,13 @@ AM_CPPFLAGS = \
-include "config.h" \
$(NULL)
-AM_CFLAGS = $(WARN_CFLAGS)
+ASAN_FLAGS=
+if ENABLE_ASAN
+ASAN_FLAGS = -fsanitize=undefined -fsanitize-undefined-trap-on-error -fsanitize=address
+endif
+
+AM_CFLAGS = $(WARN_CFLAGS) $(ASAN_FLAGS)
+AM_LDFLAGS = $(ASAN_FLAGS)
if WITH_SYSTEM_BWRAP
AM_CPPFLAGS += -DHELPER=\"$(BWRAP)\"
diff --git a/configure.ac b/configure.ac
index 9e1ae919..73bf9386 100644
--- a/configure.ac
+++ b/configure.ac
@@ -360,6 +360,13 @@ AC_ARG_ENABLE(sudo,
[SUDO_BIN="sudo"], [SUDO_BIN=""])
AC_SUBST([SUDO_BIN])
+AC_ARG_ENABLE(asan,
+ [AS_HELP_STRING([--enable-asan],
+ [Use build with address sanitazion])],
+ [],
+ [enable_asan=no])
+AM_CONDITIONAL([ENABLE_ASAN], [test "x$enable_asan" = xyes])
+
AC_ARG_WITH(system-install-dir,
[AS_HELP_STRING([--with-system-install-dir=DIR],
[Location of system installation [LOCALSTATEDIR/lib/flatpak]])],