[Bug bootstrap/54419] [4.8 Regression] Compiling libstdc++-v3/src/c++11/random.cc fails on platforms not knowing rdrand

dominiq at lps dot ens.fr gcc-bugzilla@gcc.gnu.org
Tue Sep 4 15:57:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54419

--- Comment #24 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2012-09-04 15:56:17 UTC ---
As such, the patch in commen #20 does not work:

(1) on x86_64-apple-darwin10 it gives

[macbook] gcc/p_build% grep -r rdr x86_64-apple-darwin10.8.0/*/config.log
x86_64-apple-darwin10.8.0/libstdc++-v3/config.log:ac_cv_x86_rdrand=yes

AFAICT this is due to the fact that "void f(void){asm("rdrand %eax");}" is
optimized out, thus the test passes.

Before reading comment #22, I have tested

  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
void f(void){asm("rdrand %eax");}
_ACEOF

which gives

x86_64-apple-darwin10.8.0/libstdc++-v3/config.log:conftest.c:167:no such
instruction: `rdrand %eax'
x86_64-apple-darwin10.8.0/libstdc++-v3/config.log:| void f(void){asm("rdrand
%eax");}
x86_64-apple-darwin10.8.0/libstdc++-v3/config.log:ac_cv_x86_rdrand=no

(2) I have asked in comment #21

> Before I test the patch, I am surprised to see that only two out of three
> blocks
>
> #if defined __i386__ || defined __x86_64__
> 
> are "protected" by  && defined _GLIBCXX_X86_RDRAND. Is it normal?

Thanks to the quick answer, without 

-#if (defined __i386__ || defined __x86_64__)
+#if (defined __i386__ || defined __x86_64__) && defined _GLIBCXX_X86_RDRAND

bootstrap fails with

../../../../../p_work/libstdc++-v3/src/c++11/random.cc: In member function
'std::random_device::result_type std::random_device::_M_getval()':
../../../../../p_work/libstdc++-v3/src/c++11/random.cc:124:27: error:
'__x86_rdrand' was not declared in this scope
       return __x86_rdrand();

With the two changes I have been able to bootstrap revision 190924 configured
with

../p_work/configure --prefix=/opt/gcc/gcc4.8p-190924p2
--enable-languages=c,c++,lto,fortran,ada,objc,obj-c++ --with-gmp=/opt/mp
--with-system-zlib --enable-checking=release --with-isl=/opt/mp --enable-lto
--enable-plugin --enable-build-with-cxx

I will now try to bootstrap with the following change in libstdc++-v3/configure

ac_cv_x86_rdrand=no
case "$target" in
  i?86-*-* | \
  x86_64-*-*)
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
int
main ()
{
  asm("rdrand %eax");
  return 0;
}
_ACEOF
if ac_fn_c_try_run "$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
if test $ac_cv_x86_rdrand = yes; then

$as_echo "#define _GLIBCXX_X86_RDRAND 1" >>confdefs.h

fi



More information about the Gcc-bugs mailing list