* Re: [PATCH] configure: Add --enable-sanitize-undefined.
@ 2015-05-27 13:13 Mark Wielaard
0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2015-05-27 13:13 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 693 bytes --]
On Thu, 2015-05-21 at 23:36 +0200, Mark Wielaard wrote:
> Now that we are -fsanitize=undefined clean make sure we keep it that way.
>
> We do have to disable alignment checking. Because we might explicitly
> use unaligned accesses (see ALLOW_UNALIGNED). And we have to disable
> integer overflow checking when running the tests under valgrind. Because
> those are unreliable under VEX emulation.
Turned out that was a bug in valgrind now fixed:
https://bugs.kde.org/show_bug.cgi?id=348247
Luckily that bug never made it into a released valgrind version.
I have pushed this change to master without the disabling of integer
overflow checking under valgrind.
Cheers,
Mark
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] configure: Add --enable-sanitize-undefined.
@ 2015-05-21 21:36 Mark Wielaard
0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2015-05-21 21:36 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 3995 bytes --]
Now that we are -fsanitize=undefined clean make sure we keep it that way.
We do have to disable alignment checking. Because we might explicitly
use unaligned accesses (see ALLOW_UNALIGNED). And we have to disable
integer overflow checking when running the tests under valgrind. Because
those are unreliable under VEX emulation.
Rename DISTCHECK_CONFIGURE_FLAGS to AM_DISTCHECK_CONFIGURE_FLAGS, so the
user can override. And add --enable-sanitize-undefined.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
ChangeLog | 8 ++++++++
Makefile.am | 4 ++--
configure.ac | 23 +++++++++++++++++++++++
3 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d3e46fc..91b2259 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2015-05-21 Mark Wielaard <mjw@redhat.com>
+
+ * configure.ac: Add --enable-sanitize-undefined.
+ Add -fno-sanitize=signed-integer-overflow when both
+ --enable-sanitize-undefined and --enable-valgrind are given.
+ * Makefile.am (DISTCHECK_CONFIGURE_FLAGS): Rename to...
+ (AM_DISTCHECK_CONFIGURE_FLAGS): this. Add --enable-sanitize-undefined.
+
2015-05-04 Anthony G. Basile <blueness@gentoo.org>
* configure.ac (argp_LDADD): Check if libc has argp and set
diff --git a/Makefile.am b/Makefile.am
index d044a7c..1454d04 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -33,9 +33,9 @@ EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING \
# Make sure the test build uses the same compiler, which on e.g. ppc64
# determines which platform we are actually testing.
# Run all tests under valgrind.
-DISTCHECK_CONFIGURE_FLAGS = \
+AM_DISTCHECK_CONFIGURE_FLAGS = \
--libdir=`echo $(libdir) | sed "s,^$(exec_prefix),$$dc_install_base,"`\
- --enable-valgrind \
+ --enable-valgrind --enable-sanitize-undefined \
CC="$(CC)"
distcheck-hook:
diff --git a/configure.ac b/configure.ac
index 68b7f5b..7415233 100644
--- a/configure.ac
+++ b/configure.ac
@@ -193,10 +193,32 @@ if test "$use_gcov" = yes; then
fi
AM_CONDITIONAL(GCOV, test "$use_gcov" = yes)
+AC_ARG_ENABLE([sanitize-undefined],
+ AS_HELP_STRING([--enable-sanitize-undefined],
+ [Use gcc undefined behaviour sanitizer]),
+ [use_undefined=$enableval], [use_undefined=no])
+if test "$use_undefined" = yes; then
+ old_CFLAGS="$CFLAGS"
+ old_CXXFLAGS="$CXXFLAGS"
+ # We explicitly use unaligned access when possible (see ALLOW_UNALIGNED)
+ # We want to fail immediately on first error, don't try to recover.
+ CFLAGS="$CFLAGS -fsanitize=undefined -fno-sanitize=alignment -fno-sanitize-recover"
+ CXXFLAGS="$CXXFLAGS -fsanitize=undefined -fno-sanitize=alignment -fno-sanitize-recover"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([])], use_undefined=yes, use_undefined=no)
+ AS_IF([test "x$use_undefined" != xyes],
+ AC_MSG_WARN([gcc undefined behaviour sanitizer not available])
+ CFLAGS="$old_CFLAGS" CXXFLAGS="$old_CXXFLAGS")
+fi
+
AC_ARG_ENABLE([valgrind],
AS_HELP_STRING([--enable-valgrind],[run all tests under valgrind]),
[use_valgrind=$enableval], [use_valgrind=no])
if test "$use_valgrind" = yes; then
+ # signed overflow checking isn't reliable under valgrind
+ if test "$use_undefined" = yes; then
+ CFLAGS="$CFLAGS -fno-sanitize=signed-integer-overflow"
+ CXXFLAGS="$CXXFLAGS -fno-sanitize=signed-integer-overflow"
+ fi
AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no)
if test "$HAVE_VALGRIND" = "no"; then
AC_MSG_ERROR([valgrind not found])
@@ -421,6 +443,7 @@ AC_MSG_NOTICE([
gprof support : ${use_gprof}
gcov support : ${use_gcov}
run all tests under valgrind : ${use_valgrind}
+ gcc undefined behaviour sanitizer : ${use_undefined}
use rpath in tests : ${tests_use_rpath}
test biarch : ${utrace_cv_cc_biarch}
])
--
2.1.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-05-27 13:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-27 13:13 [PATCH] configure: Add --enable-sanitize-undefined Mark Wielaard
-- strict thread matches above, loose matches on Subject: below --
2015-05-21 21:36 Mark Wielaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).