From: Christian Brauner Date: Thu, 27 Feb 2020 20:48:39 +0000 (+0100) Subject: autotools: add support for ASAN and UBSAN X-Git-Tag: lxcfs-4.0.0~24^2~1 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=7eac38257f55d4ad92ebef350b4333879e28bfa4;p=mirror_lxcfs.git autotools: add support for ASAN and UBSAN Signed-off-by: Christian Brauner --- diff --git a/Makefile.am b/Makefile.am index 5029ef3..e6dc703 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,6 +28,16 @@ liblxcfs_la_SOURCES = api_extension.h \ sysfs_fuse.c sysfs_fuse.h \ utils.c utils.h liblxcfs_la_CFLAGS = $(AM_CFLAGS) + +if ENABLE_ASAN +liblxcfs_la_CFLAGS += -fsanitize=address \ + -fno-omit-frame-pointer +endif + +if ENABLE_UBSAN +liblxcfs_la_CFLAGS += -fsanitize=undefined +endif + liblxcfs_la_LDFLAGS = $(AM_CFLAGS) -module -avoid-version -shared liblxcfstest_la_SOURCES = api_extension.h \ @@ -46,6 +56,16 @@ liblxcfstest_la_SOURCES = api_extension.h \ sysfs_fuse.c sysfs_fuse.h \ utils.c utils.h liblxcfstest_la_CFLAGS = $(AM_CFLAGS) -DRELOADTEST + +if ENABLE_ASAN +liblxcfstest_la_CFLAGS += -fsanitize=address \ + -fno-omit-frame-pointer +endif + +if ENABLE_UBSAN +liblxcfstest_la_CFLAGS += -fsanitize=undefined +endif + liblxcfstest_la_LDFLAGS = $(AM_CFLAGS) -module -avoid-version -shared noinst_HEADERS = bindings.h \ diff --git a/configure.ac b/configure.ac index ad2b0b8..dbe26e7 100644 --- a/configure.ac +++ b/configure.ac @@ -230,4 +230,29 @@ AX_CHECK_COMPILE_FLAG([-fexceptions], [CFLAGS="$CFLAGS -fexceptions"],,[-Werror] AX_CHECK_LINK_FLAG([-z relro], [LDFLAGS="$LDFLAGS -z relro"],,[]) AX_CHECK_LINK_FLAG([-z now], [LDFLAGS="$LDFLAGS -z now"],,[]) +# Build with ASAN commands +AC_ARG_ENABLE([asan], + [AS_HELP_STRING([--enable-asan], [build with address sanitizer enabled [default=no]])], + [enable_asan=$enableval], [enable_asan=no]) +AM_CONDITIONAL([ENABLE_ASAN], [test "x$enable_asan" = "xyes"]) + +# Build with UBSAN commands +AC_ARG_ENABLE([ubsan], + [AS_HELP_STRING([--enable-ubsan], [build with ubsan sanitizer enabled [default=no]])], + [enable_asan=$enableval], [enable_ubsan=no]) +AM_CONDITIONAL([ENABLE_UBSAN], [test "x$enable_ubsan" = "xyes"]) + AC_OUTPUT + +# Configuration overview +cat << EOF + +---------------------------- +Environment: + - compiler: $CC + +Debugging: + - tests: $enable_tests + - ASAN: $enable_asan + - mutex debugging: $enable_mutex_debugging +EOF