__RDSEED__ defined, but no _rdseed* prototypes?

Jeffrey Walton noloader@gmail.com
Thu Dec 24 18:59:00 GMT 2015


Hi Everyone,

I'm performing a round of testing on Ubuntu 14.03.3 server. The
physical machine has an Intel Core 5th gen (i5-5300U) with the
Broadwell chipset, which means it has RDRAND and RDSEED. cat'ing
cpuinfo confirms:

    $ cat /proc/cpuinfo | grep rdseed
    flags        : ... rdseed adx smap xsaveopt
    flags        : ... rdseed adx smap xsaveopt
    flags        : ... rdseed adx smap xsaveopt
    flags        : ... rdseed adx smap xsaveopt

Ubuntu Server 14.04.3 provides GCC 4.8.4. When I attempt to compile a
program using the intrinsics:

    $ make
    g++ -DNDEBUG -g2 -O2 -fPIC -march=native -pipe -c rdrand.cpp
    rdrand.cpp: In function ‘int
CryptoPP::ALL_RSI_GenerateBlock(byte*, size_t, unsigned int)’:
    rdrand.cpp:369:37: error: ‘_rdseed64_step’ was not declared in this scope
       if (_rdseed64_step((word64*)output))
                                         ^
    rdrand.cpp:390:26: error: ‘_rdseed64_step’ was not declared in this scope
       if (_rdseed64_step(&val))
                                         ^

I can verify __RDSEED__ is defined in the preprocessor:

    $ g++ -x c++ -march=native -dM -E - < /dev/null | sort | grep __RD
    #define __RDRND__ 1
    #define __RDSEED__ 1

But it appears the protoype is missing:

    $ grep -R rdseed /usr/include
    $ grep -R rdrand /usr/include
    /usr/include/x86_64-linux-gnu/c++/4.8/bits/c++config.h:/* Defined
if as can handle rdrand. */

I'm not sure what I should try next. I can fallback to a purely ASM
implementation, if needed. The ASM is written and tested, but its not
activating because RDSEED should be available based on the
preprocessor.

The man page does not discuss RDSEED, and does not document the
-mrdseed option
(https://gcc.gnu.org/onlinedocs/gcc-4.8.4/gcc/i386-and-x86-64-Options.html).
However, the preprocessor kind of has me confused.

Any ideas what I should do next?

Thanks in advance.



More information about the Gcc-help mailing list