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  <r...@cebitec.uni-bielefeld.de>

        PR libobjc/63765
        * thr.c (_XOPEN_SOURCE): Remove.

# HG changeset patch
# Parent aaf3e36e39afa20b793581e6a1122e96c43d46d4
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
@@ -25,11 +25,6 @@ see the files COPYING3 and COPYING.RUNTI
 #include "objc-private/common.h"
 #include "objc-private/error.h"
 #define _LIBOBJC
-/* 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.  */
-#define _XOPEN_SOURCE 600
 #include "config.h"
 #include "tconfig.h"
 #include "coretypes.h"
2014-11-07  Rainer Orth  <r...@cebitec.uni-bielefeld.de>

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

# 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"
-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

Reply via email to