[v3] fix bootstrap/54419
Gerald Pfeifer
gerald@pfeifer.com
Sun Sep 9 19:43:00 GMT 2012
On Sun, 9 Sep 2012, Jonathan Wakely wrote:
> I've committed the patch from
> http://gcc.gnu.org/ml/gcc-patches/2012-09/msg00466.html (with some
> fixes to the changelog entry)
>
> 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.
amd64-unknown-freebsd8.3 doesn't like this, I'm afraid:
configure: visibility supported: yes
checking for rdrand support in assembler... eval: ${+...}: Bad substitution
gmake[2]: *** [configure-stage1-target-libstdc++-v3] Error 2
Note, this is BSD sh, not bash. I'll admit that I had a look, and
did not find the culprit right away.
Gerald
-------------- next part --------------
commit 5202106d9ddcfd92989bfa6c11f7e9b2ea61cd10
Author: Jonathan Wakely <jwakely.gcc@gmail.com>
Date: Sun Sep 9 17:28:50 2012 +0100
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.
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 1179407..267302d 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -3360,6 +3360,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
AC_DEFUN([GLIBCXX_CHECK_GET_NPROCS], [
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index 5c86bb9..555f380 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -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
diff --git a/libstdc++-v3/src/c++11/random.cc b/libstdc++-v3/src/c++11/random.cc
index 3b05318..4342df4 100644
--- a/libstdc++-v3/src/c++11/random.cc
+++ b/libstdc++-v3/src/c++11/random.cc
@@ -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
More information about the Gcc-patches
mailing list