Don't use TEST_CXX as CXX for build

Since the C++ compiler is also used to compile links-dso-program.cc in
libsupport, use TEST_CXX to get C++ headers for testing, but don't use
TEST_CXX as CXX for build.

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-14 08:43:01 +08:00
parent ca7d48a80f
commit ad36038c32
2 changed files with 14 additions and 4 deletions

9
configure vendored
View File

@ -3910,7 +3910,7 @@ esac
fi
# We need the C++ compiler only for testing.
# We need the C++ compiler for testing and libsupport.
@ -4300,6 +4300,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
ac_compiler_gnu=$ac_cv_c_compiler_gnu
saved_CXX="$CXX"
if test -z "$TEST_CXX"; then
TEST_CXX="$CXX"
else
@ -4378,6 +4379,7 @@ esac
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cxx_link_ok" >&5
printf "%s\n" "$libc_cv_cxx_link_ok" >&6; }
CXX="$saved_CXX"
if test $libc_cv_cxx_link_ok != yes
then :
CXX=; TEST_CXX=
@ -6535,7 +6537,9 @@ fi
# Obtain some C++ header file paths. This is used to make a local
# copy of those headers in Makerules.
if test -n "$CXX"; then
if test -n "$TEST_CXX"; then
saved_CXX="$CXX"
CXX="$TEST_CXX"
find_cxx_header () {
echo "#include <$1>" | $CXX -H -fsyntax-only -x c++ - 2>&1 \
| $AWK '$1 == "."{print $2}'
@ -6543,6 +6547,7 @@ if test -n "$CXX"; then
CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
CXX_CMATH_HEADER="$(find_cxx_header cmath)"
CXX_BITS_STD_ABS_H="$(find_cxx_header bits/std_abs.h)"
CXX="$saved_CXX"
fi

View File

@ -73,10 +73,11 @@ AC_ARG_ENABLE([static-c++-link-check],
[static_cxx_link_check=$enableval],
[static_cxx_link_check=yes])
# We need the C++ compiler only for testing.
# We need the C++ compiler for testing and libsupport.
AC_PROG_CXX
AC_ARG_VAR([TEST_CXX],
[C++ compiler for testing])
saved_CXX="$CXX"
if test -z "$TEST_CXX"; then
TEST_CXX="$CXX"
else
@ -108,6 +109,7 @@ main()
LDFLAGS="$old_LDFLAGS"
fi
AC_LANG_POP([C++])])
CXX="$saved_CXX"
AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=; TEST_CXX=])
if test "`cd $srcdir; pwd -P`" = "`pwd -P`"; then
@ -1077,7 +1079,9 @@ AC_SUBST(CXX_SYSINCLUDES)
# Obtain some C++ header file paths. This is used to make a local
# copy of those headers in Makerules.
if test -n "$CXX"; then
if test -n "$TEST_CXX"; then
saved_CXX="$CXX"
CXX="$TEST_CXX"
find_cxx_header () {
echo "#include <$1>" | $CXX -H -fsyntax-only -x c++ - 2>&1 \
| $AWK '$1 == "."{print $2}'
@ -1085,6 +1089,7 @@ if test -n "$CXX"; then
CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
CXX_CMATH_HEADER="$(find_cxx_header cmath)"
CXX_BITS_STD_ABS_H="$(find_cxx_header bits/std_abs.h)"
CXX="$saved_CXX"
fi
AC_SUBST(CXX_CSTDLIB_HEADER)
AC_SUBST(CXX_CMATH_HEADER)