bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fix compilation errors in C++ mode with xlclang++ on AIX


From: Bruno Haible
Subject: fix compilation errors in C++ mode with xlclang++ on AIX
Date: Thu, 05 Dec 2019 03:39:17 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; )

Christian Biesinger wrote:
> (tested on the GCC compile farm, gcc119, /opt/IBM/xlC/16.1.0/bin/xlclang++)

First, we need to make sure that gnulib basically works fine on this platform.
To this effect, I build a testdir

  ./gnulib-tool --create-testdir --dir=../testdir1 --single-configure 
--with-c++-tests `./posix-modules`

and fix all compilation errors that can be seen with this compiler.
(With the stock xlc and gcc on AIX, there are no compilation errors that come
from the header files.)

I'm seeing three problems.

1) Errors about expm1l, fmal, remainderl, roundl, such as:

In file included from ../../gltests/test-math-c++.cc:22:
../gllib/math.h:1257:19: error: declaration of 'expm1l' has a different 
language linkage
_GL_FUNCDECL_SYS (expm1l, long double, (long double x));
                  ^

Here the issue is that the header files of this compiler define expm1l as a
function with C++ linkage, not with C linkage. The fix is simply to disable
the _GL_FUNCDECL_SYS invocations. Their purpose is to provide the declarations
on platforms that don't provide them (from FreeBSD 6.0 to IRIX and AIX 5.1).
On versions of AIX which have the functions, this _GL_FUNCDECL_SYS is not
needed.

2) Errors about signbit, isfinite, such as:

In file included from ../../gltests/test-math-c++2.cc:20:
/opt/IBM/xlC/16.1.0/include2/c++/cmath:321:7: error: no member named 
'rpl_isfinite' in the global namespace; did you mean
      'gnulib::rpl_isfinite'?
using ::isfinite;
      ^~
../gllib/math.h:2729:46: note: 'gnulib::rpl_isfinite' declared here
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite, rpl_isfinite, bool)
                                             ^

The issue here is that some C++ header file does
  using ::isfinite;
which macroexpands to
  using ::rpl_isfinite;

The fix is to use the other way of invoking _GL_MATH_CXX_REAL_FLOATING_DECL_2.

3) Errors about pthread_exit, thrd_exit, such as

In file included from ../../gltests/test-pthread-c++.cc:22:
../gllib/pthread.h:1206:1: error: cannot initialize return object of type 
'type' (aka 'void (*)(void *) __attribute__((noreturn))') with
      an lvalue of type 'void (void *)'
_GL_CXXALIAS_SYS (pthread_exit, _Noreturn void, (void *value));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The compiler is apparently complaining about differences in _Noreturn
attributes. To make it ignore these differences, the usual trick is to
use _GL_CXXALIAS_SYS_CAST instead of _GL_CXXALIAS_SYS.


This patch fixes the issues.


2019-12-04  Bruno Haible  <address@hidden>

        Fix compilation errors in C++ mode with xlclang++ on AIX.
        * lib/math.in.h (expm1l, fmal, remainderl, roundl): Don't redeclare in
        C++ mode on AIX.
        (isfinite, signbit): In C++ mode on AIX with clang, use the approach
        without C preprocessor macro.
        * lib/pthread.in.h (pthread_exit): Use _GL_CXXALIAS_SYS_CAST instead of
        _GL_CXXALIAS_SYS.
        * lib/threads.in.h (thrd_exit): Likewise.

diff --git a/lib/math.in.h b/lib/math.in.h
index 3aa7f4e..3bb9663 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -780,7 +780,9 @@ _GL_CXXALIAS_RPL (expm1l, long double, (long double x));
 # else
 #  if !@HAVE_DECL_EXPM1L@
 #   undef expm1l
+#   if !(defined __cplusplus && defined _AIX)
 _GL_FUNCDECL_SYS (expm1l, long double, (long double x));
+#   endif
 #  endif
 _GL_CXXALIAS_SYS (expm1l, long double, (long double x));
 # endif
@@ -960,8 +962,10 @@ _GL_CXXALIAS_RPL (fmal, long double,
 # else
 #  if !@HAVE_FMAL@
 #   undef fmal
+#   if !(defined __cplusplus && defined _AIX)
 _GL_FUNCDECL_SYS (fmal, long double,
                   (long double x, long double y, long double z));
+#   endif
 #  endif
 _GL_CXXALIAS_SYS (fmal, long double,
                   (long double x, long double y, long double z));
@@ -1838,7 +1842,9 @@ _GL_CXXALIAS_RPL (remainderl, long double, (long double 
x, long double y));
 # else
 #  if !@HAVE_DECL_REMAINDERL@
 #   undef remainderl
+#   if !(defined __cplusplus && defined _AIX)
 _GL_FUNCDECL_SYS (remainderl, long double, (long double x, long double y));
+#   endif
 #  endif
 _GL_CXXALIAS_SYS (remainderl, long double, (long double x, long double y));
 # endif
@@ -1965,7 +1971,9 @@ _GL_CXXALIAS_RPL (roundl, long double, (long double x));
 # else
 #  if !@HAVE_DECL_ROUNDL@
 #   undef roundl
+#   if !(defined __cplusplus && defined _AIX)
 _GL_FUNCDECL_SYS (roundl, long double, (long double x));
+#   endif
 #  endif
 _GL_CXXALIAS_SYS (roundl, long double, (long double x));
 # endif
@@ -2249,7 +2257,7 @@ _GL_EXTERN_C int gl_isfinitel (long double x);
 #  if defined isfinite || defined GNULIB_NAMESPACE
 _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isfinite)
 #   undef isfinite
-#   if __GNUC__ >= 6 || defined __clang__
+#   if __GNUC__ >= 6 || (defined __clang__ && !defined _AIX)
   /* This platform's <cmath> possibly defines isfinite through a set of inline
      functions.  */
 _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite, rpl_isfinite, bool)
@@ -2491,7 +2499,7 @@ _GL_EXTERN_C int gl_signbitl (long double arg);
 #  if defined signbit || defined GNULIB_NAMESPACE
 _GL_MATH_CXX_REAL_FLOATING_DECL_1 (signbit)
 #   undef signbit
-#   if __GNUC__ >= 6 || defined __clang__
+#   if __GNUC__ >= 6 || (defined __clang__ && !defined _AIX)
   /* This platform's <cmath> possibly defines signbit through a set of inline
      functions.  */
 _GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit, rpl_signbit, bool)
diff --git a/lib/pthread.in.h b/lib/pthread.in.h
index e564140..c94638b 100644
--- a/lib/pthread.in.h
+++ b/lib/pthread.in.h
@@ -689,7 +689,7 @@ _GL_CXXALIAS_RPL (pthread_exit, _Noreturn void, (void 
*value));
 #  if !@HAVE_PTHREAD_EXIT@
 _GL_FUNCDECL_SYS (pthread_exit, _Noreturn void, (void *value));
 #  endif
-_GL_CXXALIAS_SYS (pthread_exit, _Noreturn void, (void *value));
+_GL_CXXALIAS_SYS_CAST (pthread_exit, _Noreturn void, (void *value));
 # endif
 _GL_CXXALIASWARN (pthread_exit);
 #elif defined GNULIB_POSIXCHECK
diff --git a/lib/threads.in.h b/lib/threads.in.h
index 0ed87b3..39ccead 100644
--- a/lib/threads.in.h
+++ b/lib/threads.in.h
@@ -268,7 +268,7 @@ _GL_WARN_ON_USE (thrd_join, "thrd_join is unportable - "
 # if !@HAVE_THREADS_H@
 _GL_FUNCDECL_SYS (thrd_exit, _Noreturn void, (int));
 # endif
-_GL_CXXALIAS_SYS (thrd_exit, _Noreturn void, (int));
+_GL_CXXALIAS_SYS_CAST (thrd_exit, _Noreturn void, (int));
 _GL_CXXALIASWARN (thrd_exit);
 #elif defined GNULIB_POSIXCHECK
 # undef thrd_exit




reply via email to

[Prev in Thread] Current Thread [Next in Thread]