Add --disable-static-c++-link-check option [BZ #31412]

The current minimum GCC version of glibc build is GCC 6.2 or newer. But
building i686 glibc with GCC 6.4 on Fedora 40 failed since the C++ header
files couldn't be found which was caused by the static C++ link check
failure due to missing __divmoddi4 which was referenced in i686 libc.a
and added to GCC 7.  Add --disable-static-c++-link-check configure option
to disable the static C++ link test.  The newly built i686 libc.a can be
used by GCC 6.4 to create static C++ tests.  This fixes BZ #31412.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
This commit is contained in:
H.J. Lu 2024-06-20 15:28:12 -07:00
parent dce754b155
commit 23f12e6e0c
4 changed files with 50 additions and 12 deletions

View file

@ -224,6 +224,14 @@ if 'CFLAGS' is specified it must enable optimization. For example:
By default for x86_64, the GNU C Library is built with the vector By default for x86_64, the GNU C Library is built with the vector
math library. Use this option to disable the vector math library. math library. Use this option to disable the vector math library.
'--disable-static-c++-link-check'
By default, if the C++ toolchain lacks support for static linking,
configure fails to find the C++ header files and the glibc build
fails. Use this option to disable the static C++ link check so
that the C++ header files can be located. The newly built libc.a
can be used to create static C++ tests if the C++ toolchain has the
necessary static C++ libraries.
'--disable-scv' '--disable-scv'
Disable using 'scv' instruction for syscalls. All syscalls will Disable using 'scv' instruction for syscalls. All syscalls will
use 'sc' instead, even if the kernel supports 'scv'. PowerPC only. use 'sc' instead, even if the kernel supports 'scv'. PowerPC only.

24
configure vendored
View file

@ -771,6 +771,7 @@ ac_user_opts='
enable_option_checking enable_option_checking
with_pkgversion with_pkgversion
with_bugurl with_bugurl
enable_static_c___link_check
with_gd with_gd
with_gd_include with_gd_include
with_gd_lib with_gd_lib
@ -1440,6 +1441,8 @@ Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options --disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--disable-static-c++-link-check
disable static C++ link check [default=no]
--disable-sanity-checks really do not use threads (should not be used except --disable-sanity-checks really do not use threads (should not be used except
in special situations) [default=yes] in special situations) [default=yes]
--enable-shared build shared library [default=yes if GNU ld] --enable-shared build shared library [default=yes if GNU ld]
@ -3855,6 +3858,15 @@ if test -z "$CPP"; then
fi fi
# Check whether --enable-static-c++-link-check was given.
if test ${enable_static_c___link_check+y}
then :
enableval=$enable_static_c___link_check; static_cxx_link_check=$enableval
else $as_nop
static_cxx_link_check=yes
fi
# We need the C++ compiler only for testing. # We need the C++ compiler only for testing.
@ -4279,10 +4291,11 @@ esac
fi fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \ rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext conftest$ac_exeext conftest.$ac_ext
# Static case. if test $static_cxx_link_check = yes; then
old_LDFLAGS="$LDFLAGS" # Static case.
LDFLAGS="$LDFLAGS -static" old_LDFLAGS="$LDFLAGS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext LDFLAGS="$LDFLAGS -static"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
#include <iostream> #include <iostream>
@ -4304,7 +4317,8 @@ esac
fi fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \ rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext conftest$ac_exeext conftest.$ac_ext
LDFLAGS="$old_LDFLAGS" LDFLAGS="$old_LDFLAGS"
fi
ac_ext=c ac_ext=c
ac_cpp='$CPP $CPPFLAGS' ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'

View file

@ -52,6 +52,12 @@ fi
AC_SUBST(cross_compiling) AC_SUBST(cross_compiling)
AC_PROG_CPP AC_PROG_CPP
AC_ARG_ENABLE([static-c++-link-check],
AS_HELP_STRING([--disable-static-c++-link-check],
[disable static C++ link check @<:@default=no@:>@]),
[static_cxx_link_check=$enableval],
[static_cxx_link_check=yes])
# We need the C++ compiler only for testing. # We need the C++ compiler only for testing.
AC_PROG_CXX AC_PROG_CXX
# It's useless to us if it can't link programs (e.g. missing -lstdc++). # It's useless to us if it can't link programs (e.g. missing -lstdc++).
@ -61,10 +67,11 @@ AC_LANG_PUSH([C++])
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
[libc_cv_cxx_link_ok=yes], [libc_cv_cxx_link_ok=yes],
[libc_cv_cxx_link_ok=no]) [libc_cv_cxx_link_ok=no])
# Static case. if test $static_cxx_link_check = yes; then
old_LDFLAGS="$LDFLAGS" # Static case.
LDFLAGS="$LDFLAGS -static" old_LDFLAGS="$LDFLAGS"
AC_LINK_IFELSE([AC_LANG_SOURCE([ LDFLAGS="$LDFLAGS -static"
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include <iostream> #include <iostream>
int int
@ -74,9 +81,10 @@ main()
return 0; return 0;
} }
])], ])],
[], [],
[libc_cv_cxx_link_ok=no]) [libc_cv_cxx_link_ok=no])
LDFLAGS="$old_LDFLAGS" LDFLAGS="$old_LDFLAGS"
fi
AC_LANG_POP([C++])]) AC_LANG_POP([C++])])
AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=]) AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=])

View file

@ -252,6 +252,14 @@ configure with @option{--disable-werror}.
By default for x86_64, @theglibc{} is built with the vector math library. By default for x86_64, @theglibc{} is built with the vector math library.
Use this option to disable the vector math library. Use this option to disable the vector math library.
@item --disable-static-c++-link-check
By default, if the C++ toolchain lacks support for static linking,
configure fails to find the C++ header files and the glibc build fails.
Use this option to disable the static C++ link check so that the C++
header files can be located. The newly built libc.a can be used to
create static C++ tests if the C++ toolchain has the necessary static
C++ libraries.
@item --disable-scv @item --disable-scv
Disable using @code{scv} instruction for syscalls. All syscalls will use Disable using @code{scv} instruction for syscalls. All syscalls will use
@code{sc} instead, even if the kernel supports @code{scv}. PowerPC only. @code{sc} instead, even if the kernel supports @code{scv}. PowerPC only.