Patchwork [revised] Fix PR bootstrap/54419

login
register
mail settings
Submitter Jack Howarth
Date Sept. 6, 2012, 7:22 p.m.
Message ID <20120906192210.GA17313@bromo.med.uc.edu>
Download mbox | patch
Permalink /patch/182264/
State New
Headers show

Comments

Jack Howarth - Sept. 6, 2012, 7:22 p.m.
The attached patch eliminates the bootstrap failures in libstdc++-v3
of PR 54419 by having configure check for assembler support of the new
rdrand opcode and defining  _GLIBCXX_X86_RDRAND in config.h if supported.
Tested on x86_64-apple-darwin12 against the assembler from Xcode 4.4.1.
Okay for gcc trunk?
             Jack
ps Regenerated config.h.in in libstdc++-v3 with...

autoheader -I. -I../config

and configure with...

autoconf -I. -I../config

libstdc++-v3/

2012-09-06  Ulrich Drepper  <drepper@gmail.com>
	    Dominique d'Humieres <dominiq@lps.ens.ft>
	    Jack Howarth <howarth@bromo.med.uc.edu>

	PR bootstrap/54419
	* configure.ac: 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.
Jakub Jelinek - Sept. 6, 2012, 7:26 p.m.
On Thu, Sep 06, 2012 at 03:22:10PM -0400, Jack Howarth wrote:
>    The attached patch eliminates the bootstrap failures in libstdc++-v3
> of PR 54419 by having configure check for assembler support of the new
> rdrand opcode and defining  _GLIBCXX_X86_RDRAND in config.h if supported.
> Tested on x86_64-apple-darwin12 against the assembler from Xcode 4.4.1.
> Okay for gcc trunk?

Paolo requested in the PR that instead we define a new
AC_DEFUN([GLIBCXX_CHECK_X86_RDRAND], [
...
])
(or similar) in libstdc++-v3/acinclude.m4 and add just
GLIBCXX_CHECK_X86_RDRAND
(or similar) line to libstdc++-v3/configure.ac.

	Jakub
Jakub Jelinek - Sept. 6, 2012, 7:32 p.m.
On Thu, Sep 06, 2012 at 03:22:10PM -0400, Jack Howarth wrote:
>    The attached patch eliminates the bootstrap failures in libstdc++-v3
> of PR 54419 by having configure check for assembler support of the new
> rdrand opcode and defining  _GLIBCXX_X86_RDRAND in config.h if supported.
> Tested on x86_64-apple-darwin12 against the assembler from Xcode 4.4.1.
> Okay for gcc trunk?

Paolo requested in the PR that instead we define a new
AC_DEFUN([GLIBCXX_CHECK_X86_RDRAND], [
...
])
(or similar) in libstdc++-v3/acinclude.m4 and add just
GLIBCXX_CHECK_X86_RDRAND
(or similar) line to libstdc++-v3/configure.ac.

	Jakub

Patch

Index: libstdc++-v3/src/c++11/random.cc
===================================================================
--- libstdc++-v3/src/c++11/random.cc	(revision 191031)
+++ libstdc++-v3/src/c++11/random.cc	(working copy)
@@ -50,7 +50,7 @@  namespace std _GLIBCXX_VISIBILITY(defaul
       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(defaul
 
     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(defaul
   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
Index: libstdc++-v3/configure.ac
===================================================================
--- libstdc++-v3/configure.ac	(revision 191031)
+++ libstdc++-v3/configure.ac	(working copy)
@@ -330,6 +330,18 @@  case "$target" in
 esac
 GLIBCXX_CONDITIONAL(GLIBCXX_LDBL_COMPAT, test $ac_ldbl_compat = yes)
 
+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
+
 # This depends on GLIBCXX_ENABLE_SYMVERS and GLIBCXX_IS_NATIVE.
 GLIBCXX_CONFIGURE_TESTSUITE