Problems with RDSEED on Cygwin and MinGW

74 views
Skip to first unread message

Jeffrey Walton

unread,
Oct 25, 2015, 7:33:05 AM10/25/15
to Crypto++ Users
It looks like the GCC compiler is broken for RDSEED on Cygwin and MinGW (RDRAND gear is fine). Here's a test under Cygwin-X86. Cygwin-X64 produced a similar error

    g++ -DNDEBUG -g2 -O3 -maes -msse4 -msse3 -msse2 -mrdrnd -mrdseed -Wall -march=native -c rdrand.cpp
    rdrand.cpp: In function ‘int CryptoPP::GCC_RSI_GenerateBlock(byte*, size_t, unsigned int)’:
    rdrand.cpp:616:51: error: ‘__builtin_ia32_rdseed32_step’ was not declared in this scope
       if (__builtin_ia32_rdseed32_step((word32*)output))
                                                   ^
    rdrand.cpp:634:40: error: ‘__builtin_ia32_rdseed32_step’ was not declared in this scope
       if (__builtin_ia32_rdseed32_step(&val))
                                        ^
    GNUmakefile:414: recipe for target 'rdrand.o' failed
    make: *** [rdrand.o] Error 1

As far as I know, __builtin_ia32_rdseed{16|32|64}_step are the only functions semi-documented by GCC. Confer, https://gcc.gnu.org/onlinedocs/gcc/x86-Built-in-Functions.html. Everything else is undocumented (counter examples are welcomed).

JPM wanted RDSEED, and I think we should provide it. We have to decide what to do here.

I think the options are:

  (1) Remove RDSEED completely until GCC provides full support
  (2) Disable RDSEED for the Unix on Windows gear until GCC provides full support
  (3) Provide an ASM implementation that always "just works"

What is the course of action we should take?

Jeff

Mobile Mouse

unread,
Oct 25, 2015, 7:22:35 PM10/25/15
to Jeffrey Walton, Crypto++ Users
I vote for option (3). 2nd preference - (2).

--
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-user...@googlegroups.com.
More information about Crypto++ and this group is available at http://www.cryptopp.com.
---
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jean-Pierre Münch

unread,
Oct 26, 2015, 2:08:35 PM10/26/15
to cryptop...@googlegroups.com
My "vote":

I'd vote for (3) if we can't make the intrinsics work. This will also enable us to provide RDSEED ( / RDRAND) for older compiler versions (pre- 4.6 and pre- 4.8)

If this is too much work, (2) may be an option.

We should avoid (1) if anyhow possible.

BR

JPM

Jeffrey Walton

unread,
Oct 26, 2015, 9:20:09 PM10/26/15
to Crypto++ Users

I think the options are:

  (1) Remove RDSEED completely until GCC provides full support
  (2) Disable RDSEED for the Unix on Windows gear until GCC provides full support
  (3) Provide an ASM implementation that always "just works"

What is the course of action we should take?
My "vote":

I'd vote for (3) if we can't make the intrinsics work. This will also enable us to provide RDSEED ( / RDRAND) for older compiler versions (pre- 4.6 and pre- 4.8)

If this is too much work, (2) may be an option.

We should avoid (1) if anyhow possible.

Yes, agreed. I like it when things "just work" :)

 We can (1) provide the ASM that always "just works" and (2) provide an optional Intrinsics in case things go sideways in unexpected ways.

Jeff

Jeffrey Walton

unread,
Oct 27, 2015, 2:29:52 AM10/27/15
to Crypto++ Users


On Sunday, October 25, 2015 at 7:33:05 AM UTC-4, Jeffrey Walton wrote:
It looks like the GCC compiler is broken for RDSEED on Cygwin and MinGW (RDRAND gear is fine). Here's a test under Cygwin-X86. Cygwin-X64 produced a similar error

    g++ -DNDEBUG -g2 -O3 -maes -msse4 -msse3 -msse2 -mrdrnd -mrdseed -Wall -march=native -c rdrand.cpp
    rdrand.cpp: In function ‘int CryptoPP::GCC_RSI_GenerateBlock(byte*, size_t, unsigned int)’:
    rdrand.cpp:616:51: error: ‘__builtin_ia32_rdseed32_step’ was not declared in this scope
       if (__builtin_ia32_rdseed32_step((word32*)output))
                                                   ^
    rdrand.cpp:634:40: error: ‘__builtin_ia32_rdseed32_step’ was not declared in this scope
       if (__builtin_ia32_rdseed32_step(&val))
                                        ^
    GNUmakefile:414: recipe for target 'rdrand.o' failed
    make: *** [rdrand.o] Error 1

As far as I know, __builtin_ia32_rdseed{16|32|64}_step are the only functions semi-documented by GCC. Confer, https://gcc.gnu.org/onlinedocs/gcc/x86-Built-in-Functions.html. Everything else is undocumented (counter examples are welcomed).

This issue appears to be wider spread than I thought. I'm catching failures under Debian 8, too.

Jeff
Reply all
Reply to author
Forward
0 new messages