mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-31 11:50:57 +08:00
re PR bootstrap/54419 (Compiling libstdc++-v3/src/c++11/random.cc fails on platforms not knowing rdrand)
2012-09-09 Ulrich Drepper <drepper@gmail.com> Dominique d'Humieres <dominiq@lps.ens.fr> Jack Howarth <howarth@bromo.med.uc.edu> PR bootstrap/54419 * acinclude.m4: Define GLIBCXX_CHECK_X86_RDRAND. * configure.ac: Use GLIBCXX_CHECK_X86_RDRAND to test for rdrand support in assembler. * src/c++11/random.cc (__x86_rdrand): Depend on _GLIBCXX_X86_RDRAND. (random_device::_M_init): Likewise. (random_device::_M_getval): Likewise. * configure: Regenerated. * config.h.in: Regenerated. Co-Authored-By: Dominique d'Humieres <dominiq@lps.ens.fr> Co-Authored-By: Jack Howarth <howarth@bromo.med.uc.edu> From-SVN: r191111
This commit is contained in:
parent
ef64d158fb
commit
3ca6351daa
@ -1,3 +1,17 @@
|
||||
2012-09-09 Ulrich Drepper <drepper@gmail.com>
|
||||
Dominique d'Humieres <dominiq@lps.ens.fr>
|
||||
Jack Howarth <howarth@bromo.med.uc.edu>
|
||||
|
||||
PR bootstrap/54419
|
||||
* acinclude.m4: Define GLIBCXX_CHECK_X86_RDRAND.
|
||||
* configure.ac: Use GLIBCXX_CHECK_X86_RDRAND to test for rdrand
|
||||
support in assembler.
|
||||
* src/c++11/random.cc (__x86_rdrand): Depend on _GLIBCXX_X86_RDRAND.
|
||||
(random_device::_M_init): Likewise.
|
||||
(random_device::_M_getval): Likewise.
|
||||
* configure: Regenerated.
|
||||
* config.h.in: Regenerated.
|
||||
|
||||
2012-09-09 Ulrich Drepper <drepper@gmail.com>
|
||||
|
||||
* src/c++11/random.cc (random_device::_M_init): Use new macro
|
||||
|
@ -3359,6 +3359,26 @@ AC_DEFUN([AC_LC_MESSAGES], [
|
||||
])
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Check whether rdrand is supported in the assembler.
|
||||
AC_DEFUN([GLIBCXX_CHECK_X86_RDRAND], [
|
||||
AC_MSG_CHECKING([for rdrand support in assembler])
|
||||
AC_CACHE_VAL($ac_cv_x86_rdrand, [
|
||||
ac_cv_x86_rdrand=no
|
||||
case "$target" in
|
||||
i?86-*-* | \
|
||||
x86_64-*-*)
|
||||
AC_TRY_COMPILE(, [asm("rdrand %eax");],
|
||||
[ac_cv_x86_rdrand=yes], [ac_cv_x86_rdrand=no])
|
||||
esac
|
||||
])
|
||||
if test $ac_cv_x86_rdrand = yes; then
|
||||
AC_DEFINE(_GLIBCXX_X86_RDRAND, 1,
|
||||
[ Defined if as can handle rdrand. ])
|
||||
fi
|
||||
AC_MSG_RESULT($ac_cv_x86_rdrand)
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Check whether get_nprocs is available in <sys/sysinfo.h>, and define _GLIBCXX_USE_GET_NPROCS.
|
||||
dnl
|
||||
|
@ -845,6 +845,9 @@
|
||||
/* Define if code specialized for wchar_t should be used. */
|
||||
#undef _GLIBCXX_USE_WCHAR_T
|
||||
|
||||
/* Defined if as can handle rdrand. */
|
||||
#undef _GLIBCXX_X86_RDRAND
|
||||
|
||||
/* Define to 1 if mutex_timedlock is available. */
|
||||
#undef _GTHREAD_USE_MUTEX_TIMEDLOCK
|
||||
|
||||
|
42
libstdc++-v3/configure
vendored
42
libstdc++-v3/configure
vendored
@ -70621,6 +70621,48 @@ $as_echo "#define _GLIBCXX_LONG_DOUBLE_COMPAT 1" >>confdefs.h
|
||||
esac
|
||||
|
||||
|
||||
# Check if assembler supports rdrand opcode.
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rdrand support in assembler" >&5
|
||||
$as_echo_n "checking for rdrand support in assembler... " >&6; }
|
||||
if { as_var=$ac_cv_x86_rdrand; eval "test \"\${$as_var+set}\" = set"; }; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
|
||||
ac_cv_x86_rdrand=no
|
||||
case "$target" in
|
||||
i?86-*-* | \
|
||||
x86_64-*-*)
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
asm("rdrand %eax");
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
ac_cv_x86_rdrand=yes
|
||||
else
|
||||
ac_cv_x86_rdrand=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
if test $ac_cv_x86_rdrand = yes; then
|
||||
|
||||
$as_echo "#define _GLIBCXX_X86_RDRAND 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_x86_rdrand" >&5
|
||||
$as_echo "$ac_cv_x86_rdrand" >&6; }
|
||||
|
||||
|
||||
# This depends on GLIBCXX_ENABLE_SYMVERS and GLIBCXX_IS_NATIVE.
|
||||
|
||||
if $GLIBCXX_IS_NATIVE ; then
|
||||
|
@ -330,6 +330,9 @@ case "$target" in
|
||||
esac
|
||||
GLIBCXX_CONDITIONAL(GLIBCXX_LDBL_COMPAT, test $ac_ldbl_compat = yes)
|
||||
|
||||
# Check if assembler supports rdrand opcode.
|
||||
GLIBCXX_CHECK_X86_RDRAND
|
||||
|
||||
# This depends on GLIBCXX_ENABLE_SYMVERS and GLIBCXX_IS_NATIVE.
|
||||
GLIBCXX_CONFIGURE_TESTSUITE
|
||||
|
||||
|
@ -50,7 +50,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
|
||||
return __ret;
|
||||
}
|
||||
|
||||
#if defined __i386__ || defined __x86_64__
|
||||
#if (defined __i386__ || defined __x86_64__) && defined _GLIBCXX_X86_RDRAND
|
||||
unsigned int
|
||||
__attribute__ ((target("rdrnd")))
|
||||
__x86_rdrand(void)
|
||||
@ -75,7 +75,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
|
||||
|
||||
if (token == "default")
|
||||
{
|
||||
#if defined __i386__ || defined __x86_64__
|
||||
#if (defined __i386__ || defined __x86_64__) && defined _GLIBCXX_X86_RDRAND
|
||||
unsigned int eax, ebx, ecx, edx;
|
||||
// Check availability of cpuid and, for now at least, also the
|
||||
// CPU signature for Intel's
|
||||
@ -118,7 +118,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
|
||||
random_device::result_type
|
||||
random_device::_M_getval()
|
||||
{
|
||||
#if (defined __i386__ || defined __x86_64__)
|
||||
#if (defined __i386__ || defined __x86_64__) && defined _GLIBCXX_X86_RDRAND
|
||||
if (! _M_file)
|
||||
return __x86_rdrand();
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user