]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
build: Add a way to set CFLAGS for AddressSanitizer etc.
authorSimon McVittie <smcv@collabora.com>
Wed, 29 Aug 2018 19:06:00 +0000 (20:06 +0100)
committerSimon McVittie <smcv@collabora.com>
Tue, 11 Dec 2018 12:47:22 +0000 (12:47 +0000)
We don't want to set these globally via the normal CFLAGS, because if
we did, AddressSanitizer would catch test-segfault deliberately
segfaulting, and "helpfully" turn it into exit status 1, which in turn
makes our test fail because it asserts that the segfault is reported
as a segfault.

A typical use with gcc as compiler, on a reasonably recent Debian,
would be:

    ./configure SANITIZE_CFLAGS="-fsanitize=address -fsanitize=undefined -fPIE -pie"

Signed-off-by: Simon McVittie <smcv@collabora.com>
bus/Makefile.am
configure.ac
dbus/Makefile.am
test/Makefile.am
test/name-test/Makefile.am
tools/Makefile.am

index d74080493b226794017d15e7f08ed9fe4204da26..fe0f92b16b4f36ba895c433b40736cc56d960c3e 100644 (file)
@@ -38,6 +38,7 @@ AM_LDFLAGS = @R_DYNAMIC_LDFLAG@
 
 AM_CFLAGS = \
        $(CODE_COVERAGE_CFLAGS) \
+       $(SANITIZE_CFLAGS) \
        $(NULL)
 
 EFENCE=
index 5723ae48d0f02ac7a4b297bc3cc5fbd9c5314885..4636062ab08fd5a47ea58a730267f26f364891e5 100644 (file)
@@ -1224,6 +1224,9 @@ CFLAGS="$EXTRA_CFLAGS $CFLAGS"
 CXXFLAGS="$EXTRA_CXXFLAGS $CXXFLAGS"
 LDFLAGS="$EXTRA_LDFLAGS $LDFLAGS"
 
+AC_ARG_VAR([SANITIZE_CFLAGS],
+           [Extra CFLAGS for modules that are instrumented for error-checking])
+
 case $host_os in
     solaris*)
         # Solaris' C library apparently needs these runes to be threadsafe...
index c003b3998fb145f88d676497bd4c8c269d0c400e..f9561bef1abc2761480965dcf994bb4baffc62f8 100644 (file)
@@ -17,6 +17,7 @@ AM_CPPFLAGS = \
 
 AM_CFLAGS = \
        $(CODE_COVERAGE_CFLAGS) \
+       $(SANITIZE_CFLAGS) \
        $(NULL)
 
 if HAVE_VISIBILITY
index 2f649837b43ec6038d915a95aeab7f77452a7c72..b8df15acd16c67fc0115332a5a4c1590e77c9991 100644 (file)
@@ -23,6 +23,7 @@ AM_LDFLAGS = @R_DYNAMIC_LDFLAG@
 
 AM_CFLAGS = \
        $(CODE_COVERAGE_CFLAGS) \
+       $(SANITIZE_CFLAGS) \
        $(NULL)
 
 noinst_LTLIBRARIES = libdbus-testutils.la
@@ -91,6 +92,12 @@ endif !DBUS_ENABLE_EMBEDDED_TESTS
 
 noinst_PROGRAMS= $(TEST_BINARIES)
 
+# This helper is meant to crash, so if we're compiling the rest with
+# AddressSanitizer, we need to stop it from catching the SIGSEGV and
+# turning it into _exit(1); so don't give it SANITIZE_CFLAGS.
+# CODE_COVERAGE_CFLAGS are fairly pointless here, too.
+test_segfault_CFLAGS =
+
 test_service_LDADD = libdbus-testutils.la
 test_names_LDADD = libdbus-testutils.la
 ## break_loader_LDADD = $(top_builddir)/dbus/libdbus-internal.la
index ea63e579290c4180969ccef0d9a049f145af4731..280eb8ea045527a5d7e00b2d6580fc0c0839a985 100644 (file)
@@ -7,6 +7,7 @@ AM_CPPFLAGS = \
 
 AM_CFLAGS = \
        $(CODE_COVERAGE_CFLAGS) \
+       $(SANITIZE_CFLAGS) \
        $(NULL)
 
 # if assertions are enabled, improve backtraces
index f34500302feab4f88abef7e63df124e070e113d1..85dcba6499707062d3709e2386b1ea317b6576e8 100644 (file)
@@ -8,6 +8,7 @@ AM_CPPFLAGS = \
 
 AM_CFLAGS = \
        $(CODE_COVERAGE_CFLAGS) \
+       $(SANITIZE_CFLAGS) \
        $(NULL)
 
 # if assertions are enabled, improve backtraces