I have a x86 RDRAND implementation like below. I have a similar implementation for RDSEED.
inline void RDRAND32(void* output)
{
#if defined(HAVE_GCC_RDRAND_ASM)
__asm__
(
"1:\n"
".byte 0x0f, 0xc7, 0xf0;\n"
"jnc 1b;\n"
: "=a" (*(uint32_t*)output)
: : "cc"
);
#endif
}
The byte codes emitted are rdrand eax
and a capable processor happily consumes them. Sun Studio 12.1 and above supports GCC inline assembly and also consumes them.
The Sun docs say I need -xarch=avx_i
for the ISA that provides RDRAND (and -xarch=avx2_i
for RDSEED). Also see Sun Studio 12.6 | -xarch Flags for x86.
Do I still need to add -xarch=avx_i
to my linker flags for RDRAND
in this use case?
In case it matters we guard CPU features at runtime and use a Mapfile to lower the ISA (because runtime paths are guarded):
$ cat cryptopp.mapfile
# Solaris mapfile to override hardware caps to avoid kills
hwcap_1 = SSE SSE2 OVERRIDE;