bug-gnulib
[Top][All Lists]
Advanced

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

Re: uchar C++ tests: Fix build error on FreeBSD 12


From: Bruno Haible
Subject: Re: uchar C++ tests: Fix build error on FreeBSD 12
Date: Wed, 19 Aug 2020 03:26:15 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-186-generic; KDE/5.18.0; x86_64; ; )

>  configure.ac:
> +AC_REQUIRE([gl_ANSI_CXX])
> +if test "$CXX" != no; then
> +  dnl On FreeBSD 12, 'c++' defines __cplusplus to 201402, although it does 
> not
> +  dnl have the <cuchar> header file from C++11.
> +  AC_CACHE_CHECK([whether the C++ compiler has <cuchar>],
> +    [gl_cv_cxxheader_cuchar],
> +    [AC_LANG_PUSH([C++])
> +     AC_COMPILE_IFELSE(
> +       [AC_LANG_PROGRAM(
> +          [[#include <cuchar>]],
> +          [[]])
> +       ],
> +       [gl_cv_cxxheader_cuchar=yes],
> +       [gl_cv_cxxheader_cuchar=no])
> +     AC_LANG_POP([C++])
> +    ])
> +else
> +  gl_cv_cxxheader_cuchar=no
> +fi
> +AM_CONDITIONAL([CXX_HAVE_CUCHAR], [test $gl_cv_cxxheader_cuchar != no])

This patch caused a serious regression. Namely, in a testdir produced by
gnulib-tool, many math function tests fail to link. E.g. test-remainder
fails to link because of an unknown function 'remainder'. Why? Because this
change causes the "checking whether remainder() can be used without libm"
test to report "yes" instead of "no", and likewise for many similar tests,
and thus 'test-remainder' gets built without the link option '-lm'.

I've reported it as an autoconf bug <https://savannah.gnu.org/support/?110294>.
Here is the workaround.


2020-08-18  Bruno Haible  <bruno@clisp.org>

        uchar C++ tests: Fix side effect on math modules (regr. 2020-08-17).
        * modules/uchar-c++-tests (configure.ac): Don't use AC_LANG_PUSH and
        AC_LANG_POP.

diff --git a/modules/uchar-c++-tests b/modules/uchar-c++-tests
index 2cbc331..351bdff 100644
--- a/modules/uchar-c++-tests
+++ b/modules/uchar-c++-tests
@@ -16,15 +16,16 @@ if test "$CXX" != no; then
   dnl have the <cuchar> header file from C++11.
   AC_CACHE_CHECK([whether the C++ compiler has <cuchar>],
     [gl_cv_cxxheader_cuchar],
-    [AC_LANG_PUSH([C++])
-     AC_COMPILE_IFELSE(
-       [AC_LANG_PROGRAM(
-          [[#include <cuchar>]],
-          [[]])
-       ],
-       [gl_cv_cxxheader_cuchar=yes],
-       [gl_cv_cxxheader_cuchar=no])
-     AC_LANG_POP([C++])
+    [dnl We can't use AC_LANG_PUSH([C++]) and AC_LANG_POP([C++]) here, due to
+     dnl an autoconf bug <https://savannah.gnu.org/support/?110294>.
+     echo '#include <cuchar>' > conftest.cpp
+     gl_command="$CXX $CXXFLAGS $CPPFLAGS -c conftest.cpp"
+     if AC_TRY_EVAL([gl_command]); then
+       gl_cv_cxxheader_cuchar=yes
+     else
+       gl_cv_cxxheader_cuchar=no
+     fi
+     rm -fr conftest*
     ])
 else
   gl_cv_cxxheader_cuchar=no




reply via email to

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