Hello, Fix build with GCC 4.9+.
GCC 4.9+ is too aggressive when optimizing functions with nonnull attributes. This removes most of asserts() in the plugin. GCC 6 adds warnings for these cases. We are disabling the unwanted condition pruning by adding -fno-delete-null-pointer-checks argument. BIND 9 did the same in its commit 603a78708343f063b44affb882ef93bb19a5142a. Additionally we silence warnings to prevent build failures when -Werror is used. https://bugzilla.redhat.com/show_bug.cgi?id=1307346 -- Petr^2 Spacek
From bc379e56336abae93d593b878dac6f4da4b497de Mon Sep 17 00:00:00 2001 From: Petr Spacek <pspa...@redhat.com> Date: Fri, 19 Feb 2016 13:39:27 +0100 Subject: [PATCH] Fix build with GCC 4.9+. GCC 4.9+ is too aggressive when optimizing functions with nonnull attributes. This removes most of asserts() in the plugin. GCC 6 adds warnings for these cases. We are disabling the unwanted condition pruning by adding -fno-delete-null-pointer-checks argument. BIND 9 did the same in its commit 603a78708343f063b44affb882ef93bb19a5142a. Additionally we silence warnings to prevent build failures when -Werror is used. https://bugzilla.redhat.com/show_bug.cgi?id=1307346 --- configure.ac | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/configure.ac b/configure.ac index a06708b1a5ee64bb64c80272c10ed1a35670c8d0..486c9a37b081c8d60111694a5815ac10e4e5559a 100644 --- a/configure.ac +++ b/configure.ac @@ -39,6 +39,52 @@ AC_TRY_COMPILE([ [CFLAGS="$SAVED_CFLAGS" AC_MSG_RESULT([no])]) +# Check if build chain supports -fno-delete-null-pointer-checks +# this flag avoids too agressive optimizations which would remove some asserts +# BIND 9 did the same in its commit 603a78708343f063b44affb882ef93bb19a5142a +AC_MSG_CHECKING([for -fno-delete-null-pointer-checks compiler flag]) +SAVED_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -fno-delete-null-pointer-checks" +AC_TRY_COMPILE([ + extern int fdef(void); +],[], +[AC_MSG_RESULT([yes])], +[CFLAGS="$SAVED_CFLAGS" + AC_MSG_RESULT([no])]) + +# detect if __attribute__(nonnull) is causing warnings we do not care about +# this is typically caused by REQUIRE(ptr != NULL); +AC_MSG_CHECKING([for too agressive __attribute__(nonnull) handling]) +NONNULL_COMPARE_CODE=" + __attribute__((nonnull)) + void f(void *ptr) { + if (ptr == 0) + ; + }; +" +SAVED_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wall -Werror" +AC_TRY_COMPILE([$NONNULL_COMPARE_CODE +],[], +[CFLAGS="$SAVED_CFLAGS" + AC_MSG_RESULT([no problem detected])], +[AC_MSG_RESULT([it is too aggresive]) + AC_MSG_CHECKING([if -Wno-nonnull-compare is sufficient]) + CFLAGS="$SAVED_CFLAGS -Wno-nonnull-compare -Wall -Werror" + AC_TRY_COMPILE([$NONNULL_COMPARE_CODE],[], + [AC_MSG_RESULT([yes]) + CFLAGS="$SAVED_CFLAGS -Wno-nonnull-compare"], + [AC_MSG_RESULT([no]) + AC_MSG_CHECKING([for -Wno-nonnull support]) + CFLAGS="$SAVED_CFLAGS -Wno-nonnull -Wall -Werror" + AC_TRY_COMPILE([$NONNULL_COMPARE_CODE],[], + [AC_MSG_RESULT([yes]) + CFLAGS="$SAVED_CFLAGS -Wno-nonnull"], + [AC_MSG_RESULT([no]) + CFLAGS="$SAVED_CFLAGS"]) + ]) +]) + # Get CFLAGS from isc-config.sh AC_ARG_VAR([BIND9_CFLAGS], [C compiler flags for bind9, overriding isc-config.sh]) -- 2.5.0
-- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code