diff mbox

[libobjc] Fix failures on AIX (PR libobjc/63765)

Message ID yddpp9zjj49.fsf@lokon.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth Jan. 28, 2015, 10:27 a.m. UTC
My fix for Solaris libobjc bootstrap

	https://gcc.gnu.org/ml/gcc-patches/2014-11/msg00073.html

caused many Objective-C failures on AIX.

There are two ways to fix this:

* Remove the definition of _XOPEN_SOURCE completely.  This is slightly
  more risky, but more future-proof since defining features test macros
  has been an endless source of trouble in the past.

* Restrict the XPG6 definition to Solaris, keeping everything else as it
  was before.  This is the more conservative approach, but almost
  guaranteed to haunt us again later.

Both patches have passed bootstrap and regtest by myself on Solaris,
Linux, and Darwin, and David confirmed that both fix the AIX failures,
too.

	Rainer


2014-11-07  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	PR libobjc/63765
	* thr.c (_XOPEN_SOURCE): Remove.
2014-11-07  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	PR libobjc/63765
	* thr.c (_XOPEN_SOURCE): Restrict XPG6 to Solaris.

Comments

Mike Stump Jan. 28, 2015, 6:29 p.m. UTC | #1
On Jan 28, 2015, at 2:27 AM, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote:
> There are two ways to fix this:
> 
> * Remove the definition of _XOPEN_SOURCE completely.  This is slightly
>  more risky, but more future-proof since defining features test macros
>  has been an endless source of trouble in the past.

I think I prefer this one...

But, as I say that, I read:

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=4372

and there is no hint what host caused him to put the change in, in the first place.  :-(  Alexandre, do you recall what host needed the _XOPEN_SOURCE in libobjc for pthread_mutexattr_settype?

Anyway, going forward, I would say that any target that needs a specific value should just put in the #ifdef arch #define XPOPEN val #end, if they need it.
Alexandre Oliva Jan. 29, 2015, 7:15 a.m. UTC | #2
On Jan 28, 2015, Mike Stump <mikestump@comcast.net> wrote:

> On Jan 28, 2015, at 2:27 AM, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote:
>> There are two ways to fix this:
>> 
>> * Remove the definition of _XOPEN_SOURCE completely.  This is slightly
>> more risky, but more future-proof since defining features test macros
>> has been an endless source of trouble in the past.

> I think I prefer this one...

> But, as I say that, I read:

>   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=4372

> and there is no hint what host caused him to put the change in, in the
> first place.  :-( Alexandre, do you recall what host needed the
> _XOPEN_SOURCE in libobjc for pthread_mutexattr_settype?

The 2005 timeframe suggests it was probably GNU/Linux, and some digging
in glibc indicates this flag affected nptl's pthread.h's declarations of
various such functions back then.  This changed back in 2010, with glibc
commit d3c7e68655, in response to newer standards, so I guess this
confirms the suggestion from the timeframe.  Of course, this being a
standard-compliance issue, other targets were likely affected as well,
since it looks like there was a standards change, and removing the flag
might cause regressions in old systems that remain stuck to the old
standards.
Rainer Orth Jan. 29, 2015, 10:25 a.m. UTC | #3
Hi Alexandre,

> On Jan 28, 2015, Mike Stump <mikestump@comcast.net> wrote:
>
>> On Jan 28, 2015, at 2:27 AM, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote:
>>> There are two ways to fix this:
>>> 
>>> * Remove the definition of _XOPEN_SOURCE completely.  This is slightly
>>> more risky, but more future-proof since defining features test macros
>>> has been an endless source of trouble in the past.
>
>> I think I prefer this one...
>
>> But, as I say that, I read:
>
>>   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=4372
>
>> and there is no hint what host caused him to put the change in, in the
>> first place.  :-( Alexandre, do you recall what host needed the
>> _XOPEN_SOURCE in libobjc for pthread_mutexattr_settype?
>
> The 2005 timeframe suggests it was probably GNU/Linux, and some digging
> in glibc indicates this flag affected nptl's pthread.h's declarations of
> various such functions back then.  This changed back in 2010, with glibc
> commit d3c7e68655, in response to newer standards, so I guess this
> confirms the suggestion from the timeframe.  Of course, this being a
> standard-compliance issue, other targets were likely affected as well,
> since it looks like there was a standards change, and removing the flag
> might cause regressions in old systems that remain stuck to the old
> standards.

Thanks for digging this up.  I doubt that anyone using a 2005 vintage
glibc is really using current GCC trunk, though ;-)

I recall that either or both of IRIX and Tru64 UNIX have been affected
by _XOPEN_SOURCE definitions in the past.  Both of them were last
supported in GCC 4.7, so are now ancient history.

I'm with Mike here: either we remove the _XOPEN_SOURCE definition now
and, in case of breakage, add them back exactly for those targets that
need it, documenting where and why it is necessary.  Otherwise, we will
never get rid of this cruft and break more modern systems on the way.

	Rainer
Rainer Orth Feb. 4, 2015, 10:28 a.m. UTC | #4
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

> Hi Alexandre,
>
>> On Jan 28, 2015, Mike Stump <mikestump@comcast.net> wrote:
>>
>>> On Jan 28, 2015, at 2:27 AM, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote:
>>>> There are two ways to fix this:
>>>> 
>>>> * Remove the definition of _XOPEN_SOURCE completely.  This is slightly
>>>> more risky, but more future-proof since defining features test macros
>>>> has been an endless source of trouble in the past.
>>
>>> I think I prefer this one...
>>
>>> But, as I say that, I read:
>>
>>>   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=4372
>>
>>> and there is no hint what host caused him to put the change in, in the
>>> first place.  :-( Alexandre, do you recall what host needed the
>>> _XOPEN_SOURCE in libobjc for pthread_mutexattr_settype?
>>
>> The 2005 timeframe suggests it was probably GNU/Linux, and some digging
>> in glibc indicates this flag affected nptl's pthread.h's declarations of
>> various such functions back then.  This changed back in 2010, with glibc
>> commit d3c7e68655, in response to newer standards, so I guess this
>> confirms the suggestion from the timeframe.  Of course, this being a
>> standard-compliance issue, other targets were likely affected as well,
>> since it looks like there was a standards change, and removing the flag
>> might cause regressions in old systems that remain stuck to the old
>> standards.
>
> Thanks for digging this up.  I doubt that anyone using a 2005 vintage
> glibc is really using current GCC trunk, though ;-)
>
> I recall that either or both of IRIX and Tru64 UNIX have been affected
> by _XOPEN_SOURCE definitions in the past.  Both of them were last
> supported in GCC 4.7, so are now ancient history.
>
> I'm with Mike here: either we remove the _XOPEN_SOURCE definition now
> and, in case of breakage, add them back exactly for those targets that
> need it, documenting where and why it is necessary.  Otherwise, we will
> never get rid of this cruft and break more modern systems on the way.

It's been a week now since I posted the patches and there's still no
conclusion which of the two alternatives to install.

	Rainer
Mike Stump Feb. 4, 2015, 5:07 p.m. UTC | #5
On Feb 4, 2015, at 2:28 AM, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote:
> Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:
>>> On Jan 28, 2015, Mike Stump <mikestump@comcast.net> wrote:
>>>> On Jan 28, 2015, at 2:27 AM, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote:
>>>>> 
>>>>> * Remove the definition of _XOPEN_SOURCE completely.

>>>> I think I prefer this one…

>>>> and there is no hint what host caused him to put the change in
>>> 
>>> The 2005 timeframe suggests it was probably GNU/Linux

>> I'm with Mike here: either we remove the _XOPEN_SOURCE definition now

> It's been a week now since I posted the patches and there's still no
> conclusion which of the two alternatives to install.

Well, my position is the removal of _XOPEN_SOURCE is the right patch.  I’ve not seen any substantive disagreement.  I’d post and test that patch.  A build person, a libobjc person, a reasonably an affected target person or a global person can approve in my book.  I’m not any of them…  If Pinski is happy with my approving it, he can weigh in.  I’d be happy to approve it.
Andrew Pinski Feb. 4, 2015, 5:39 p.m. UTC | #6
On Wed, Feb 4, 2015 at 9:07 AM, Mike Stump <mikestump@comcast.net> wrote:
> On Feb 4, 2015, at 2:28 AM, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote:
>> Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:
>>>> On Jan 28, 2015, Mike Stump <mikestump@comcast.net> wrote:
>>>>> On Jan 28, 2015, at 2:27 AM, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote:
>>>>>>
>>>>>> * Remove the definition of _XOPEN_SOURCE completely.
>
>>>>> I think I prefer this one…
>
>>>>> and there is no hint what host caused him to put the change in
>>>>
>>>> The 2005 timeframe suggests it was probably GNU/Linux
>
>>> I'm with Mike here: either we remove the _XOPEN_SOURCE definition now
>
>> It's been a week now since I posted the patches and there's still no
>> conclusion which of the two alternatives to install.
>
> Well, my position is the removal of _XOPEN_SOURCE is the right patch.  I’ve not seen any substantive disagreement.  I’d post and test that patch.  A build person, a libobjc person, a reasonably an affected target person or a global person can approve in my book.  I’m not any of them…  If Pinski is happy with my approving it, he can weigh in.  I’d be happy to approve it.


I am happy with which ever approach is decided as the safest and most portable.

Thanks,
Andrew Pinski
Rainer Orth Feb. 5, 2015, 9:44 a.m. UTC | #7
Hi Andrew,

> On Wed, Feb 4, 2015 at 9:07 AM, Mike Stump <mikestump@comcast.net> wrote:
>> On Feb 4, 2015, at 2:28 AM, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote:
>>> Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:
>>>>> On Jan 28, 2015, Mike Stump <mikestump@comcast.net> wrote:
>>>>>> On Jan 28, 2015, at 2:27 AM, Rainer Orth
>>>>>> <ro@CeBiTec.Uni-Bielefeld.DE> wrote:
>>>>>>>
>>>>>>> * Remove the definition of _XOPEN_SOURCE completely.
>>
>>>>>> I think I prefer this one…
>>
>>>>>> and there is no hint what host caused him to put the change in
>>>>>
>>>>> The 2005 timeframe suggests it was probably GNU/Linux
>>
>>>> I'm with Mike here: either we remove the _XOPEN_SOURCE definition now
>>
>>> It's been a week now since I posted the patches and there's still no
>>> conclusion which of the two alternatives to install.
>>
>> Well, my position is the removal of _XOPEN_SOURCE is the right patch.
>> I’ve not seen any substantive disagreement.  I’d post and test that
>> patch.  A build person, a libobjc person, a reasonably an affected target
>> person or a global person can approve in my book.  I’m not any of them…
>> If Pinski is happy with my approving it, he can weigh in.  I’d be happy
>> to approve it.
>
>
> I am happy with which ever approach is decided as the safest and most portable.

given that Mike and myself agree that removing _XOPEN_SOURCE completely
and, should weird systems that need particular values resurface, define
it only for those without breaking others, is the only safe and sane
approach, I've installed that variant.

Thanks.
        Rainer
diff mbox

Patch

# HG changeset patch
# Parent 199ec7b54dc9c471def4ad9cc0452df842e5eff4
Fix failures on AIX (PR libobjc/63765)

diff --git a/libobjc/thr.c b/libobjc/thr.c
--- a/libobjc/thr.c
+++ b/libobjc/thr.c
@@ -28,8 +28,13 @@  see the files COPYING3 and COPYING.RUNTI
 /* The line below is needed for declarations of functions such as
    pthread_mutexattr_settype, without which gthr-posix.h may fail to
    compile within libobjc.  While we only need XPG5 for this, Solaris
-   requires XPG6 for C99 and later.  */
+   requires XPG6 for C99 and later.  We cannot use XPG6 unconditionally
+   since that breaks AIX.  */
+#if defined __sun__ && defined __svr4__
 #define _XOPEN_SOURCE 600
+#else
+#define _XOPEN_SOURCE 500
+#endif
 #include "config.h"
 #include "tconfig.h"
 #include "coretypes.h"