Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Mar 2015 22:02:44 -0500
From:      Pedro Giffuni <pfg@FreeBSD.org>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r280636 - head/include
Message-ID:  <551376D4.4030003@FreeBSD.org>
In-Reply-To: <20150326130403.W993@besplex.bde.org>
References:  <201503252153.t2PLrInc025854@svn.freebsd.org> <20150326130403.W993@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help


On 03/25/15 21:14, Bruce Evans wrote:
> On Wed, 25 Mar 2015, Pedro F. Giffuni wrote:
>
>> Log:
>>  Temporarily revert 280458.
>>
>>  GCC is still carries an old version of cdefs.h which doesn't
>>  accept multiple parameters for the nonnull attribute.
>>
>>  Since this issue probably affects many ports in the tree
>>  we will revert it for now until gcc gets fixed.
>
> Note that sys/cdefs.h is supposed to work with any version of
> gcc back to gcc-1, and does mostly work back to at least gcc-2.95.
> The whole point of sys/cdefs.h is to provide compatibity macros
> for old and other non-default compilers.  Standard compilers don't
> even have __attribute__(()).  So no changes in future versions
> of gcc will fix the previous commit.
>
cdefs.h still works for all versions of gcc back to gcc-1 AFAICT.

> The ifdefs for __nonnull() seem to be broken.  They assume that
> all versions of gcc >= 3.3 support the same semantics for __nonnull()
> and that no non-gcc compiler supports the __nonnull__() attribute.

All versions of gcc >= 3.3 support the same semantics for __nonnull().
Unfortunately an older revision of cdefs.h was only accepting one
argument while gcc accepts multiple arguments just fine.

> Non-gcc compilers like clang get this by pretending to be gcc.

Clang claims support for gcc attributes [1] and has a __has_attribute()
macro for testing. It also reports itself as gcc 4.2 for compatibility so
we don't need to test for availability for the older attributes.

>
> Non-gcc compilers like icc tend to not get this by not pretending to
> be gcc.  __nonnull__() is one of the few attributes that is only a
> hint, so definining it as nothing when it is not known to work is
> correct.
>

The reason why I had to revert the change is actually a systematic
bug in gcc: during it's build process gcc generates a new cdefs.h
from our headers. Attempting to use an older gcc from ports
that was build with the broken mono-parameter __nonnull() ended
up causing breakage in any code using signal.h or pthreads.h.

The lesson here is to update gcc every time cdefs.h is updated
(I will be updating it at least once more[2]) and, in my case,
I'll have to wait a couple of weeks after committing a cdefs.h
change before using the new attributes to give time for people
to update their gcc* ports, and I'll likely have to note it in
UPDATING too, JIC.

Cheers,

Pedro.

[1] 
http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros
[2] https://reviews.freebsd.org/D2107




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?551376D4.4030003>