]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
autotools: add support for ASAN and UBSAN
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 27 Feb 2020 20:48:39 +0000 (21:48 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 27 Feb 2020 20:48:39 +0000 (21:48 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Makefile.am
configure.ac

index 5029ef302fe9b7b4d417e6ea388ac5d625a79552..e6dc703f5c2feb42831f3e3761abf705f8b0daa1 100644 (file)
@@ -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 \
index ad2b0b864267fcb50d7c153ab6fb3a2b57b59163..dbe26e792051f2c0afcdb611c4ffe863a707ed43 100644 (file)
@@ -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