Clear CXX and TEST_CXX if C++ link test fails

Since the C++ compiler is used only for testing, use TEST_CXX as the C++
compiler if available.  If C++ link test fails, clear both CXX and
TEST_CXX so that the C++ compiler isn't used for glibc build nor test.

Tested for m68k-linux-gnu-coldfire build and native build on x86-64.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
This commit is contained in:
H.J. Lu 2024-12-12 19:13:52 +08:00
parent 6bc301672b
commit 3ac826b020
2 changed files with 2 additions and 12 deletions

7
configure vendored
View file

@ -4301,10 +4301,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test -z "$TEST_CXX"; then
saved_CXX=
TEST_CXX="$CXX"
else
saved_CXX="$CXX"
CXX="$TEST_CXX"
fi
# It's useless to us if it can't link programs (e.g. missing -lstdc++).
@ -4382,10 +4380,7 @@ fi
printf "%s\n" "$libc_cv_cxx_link_ok" >&6; }
if test $libc_cv_cxx_link_ok != yes
then :
CXX=
fi
if test -n "$saved_CXX"; then
CXX="$saved_CXX"
CXX=; TEST_CXX=
fi
if test "`cd $srcdir; pwd -P`" = "`pwd -P`"; then

View file

@ -78,10 +78,8 @@ AC_PROG_CXX
AC_ARG_VAR([TEST_CXX],
[C++ compiler for testing])
if test -z "$TEST_CXX"; then
saved_CXX=
TEST_CXX="$CXX"
else
saved_CXX="$CXX"
CXX="$TEST_CXX"
fi
# It's useless to us if it can't link programs (e.g. missing -lstdc++).
@ -110,10 +108,7 @@ main()
LDFLAGS="$old_LDFLAGS"
fi
AC_LANG_POP([C++])])
AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=])
if test -n "$saved_CXX"; then
CXX="$saved_CXX"
fi
AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=; TEST_CXX=])
if test "`cd $srcdir; pwd -P`" = "`pwd -P`"; then
AC_MSG_ERROR([you must configure in a separate build directory])