[Freeipa-devel] [PATCH 0390] Fix build with GCC 4.9+

Petr Spacek pspacek at redhat.com
Tue Mar 1 13:35:29 UTC 2016


On 1.3.2016 12:06, Lukas Slebodnik wrote:
> On (25/02/16 15:57), Petr Spacek wrote:
>> On 19.2.2016 13:55, Petr Spacek wrote:
>>> 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
>>
>> Updated version is attached. It contains less autotools magic because it
>> enables attribute nonnull only under Clang static analyzer and Coverity - as a
>> result we do not have to silence GCC warnings from -Wnonnull.
>>
>> Please review so I can fix build in Fedora 24.
>>
>> Thank you.
>>
>> -- 
>> Petr^2 Spacek
> 
>>From 4732fe9f4e525c44b46e7ed0734ccaec94fba49e Mon Sep 17 00:00:00 2001
>> From: Petr Spacek <pspacek at 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 enable nonnull attribute only when the build is running under
>> Clang static analyzer or Coverity.
>>
>> https://bugzilla.redhat.com/show_bug.cgi?id=1307346
>> ---
>> configure.ac | 13 +++++++++++++
>> src/util.h   |  8 ++++++--
>> 2 files changed, 19 insertions(+), 2 deletions(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index a06708b1a5ee64bb64c80272c10ed1a35670c8d0..a0123ac0a62b5acd5238f028d8c42e83af4060db 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -39,6 +39,19 @@ 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])])
>> +
> NACK.
> 
> It failes with clang.
> 
> configure:12982: checking for -fno-delete-null-pointer-checks compiler flag
> configure:12999: clang -c -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -fvisibility=hidden -fno-delete-null-pointer-checks  conftest.c >&5
> clang-3.8: warning: optimization flag '-fno-delete-null-pointer-checks' is not supported
> clang-3.8: warning: argument unused during compilation: '-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1'
> configure:12999: $? = 0
> configure:13000: result: yes
> 
> Reproducer:
> autoreconf -if && CC=clang ./configure && make

Thanks! I was testing this only with Clang static analyzer ...

Here is updated patch.

-- 
Petr^2 Spacek
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bind-dyndb-ldap-pspacek-0390-3-Fix-build-with-GCC-4.9.patch
Type: text/x-patch
Size: 2548 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20160301/0dab1c66/attachment.bin>


More information about the Freeipa-devel mailing list