@@ -177,6 +177,7 @@ AC_CONFIG_SYSTEMD_SYSTEM_UNIT_DIR
AC_CONFIG_CROND_DIR
AC_CONFIG_UDEV_RULE_DIR
AC_HAVE_BLKID_TOPO
+AC_HAVE_TRIVIAL_AUTO_VAR_INIT
if test "$enable_ubsan" = "yes" || test "$enable_ubsan" = "probe"; then
AC_PACKAGE_CHECK_UBSAN
@@ -146,7 +146,7 @@ ifeq ($(HAVE_LIBURCU_ATOMIC64),yes)
PCFLAGS += -DHAVE_LIBURCU_ATOMIC64
endif
-SANITIZER_CFLAGS += @addrsan_cflags@ @threadsan_cflags@ @ubsan_cflags@
+SANITIZER_CFLAGS += @addrsan_cflags@ @threadsan_cflags@ @ubsan_cflags@ @autovar_init_cflags@
SANITIZER_LDFLAGS += @addrsan_ldflags@ @threadsan_ldflags@ @ubsan_ldflags@
# Use special ar/ranlib wrappers if we have lto
@@ -57,3 +57,17 @@ AC_DEFUN([AC_PACKAGE_CHECK_THREADSAN],
AC_SUBST(threadsan_cflags)
AC_SUBST(threadsan_ldflags)
])
+
+# Check if we have -ftrivial-auto-var-init=zero
+AC_DEFUN([AC_HAVE_TRIVIAL_AUTO_VAR_INIT],
+ [ AC_MSG_CHECKING([if C compiler supports zeroing automatic vars])
+ OLD_CFLAGS="$CFLAGS"
+ TEST_CFLAGS="-ftrivial-auto-var-init=zero"
+ CFLAGS="$CFLAGS $TEST_CFLAGS"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
+ [AC_MSG_RESULT([yes])]
+ [autovar_init_cflags=$TEST_CFLAGS],
+ [AC_MSG_RESULT([no])])
+ CFLAGS="${OLD_CFLAGS}"
+ AC_SUBST(autovar_init_cflags)
+ ])