microsoft/SymCrypt

Build break in GCC 8

xumia opened this issue · 2 comments

xumia commented

Build error:

/__w/1/SymCrypt/lib/rdseed.c: In function 'SymCryptRdseedSizet':
/__w/1/SymCrypt/lib/rdseed.c:22:28: warning: implicit declaration of function '_rdseed64_step'; did you mean '_rdseedxx_step'? [-Wimplicit-function-declaration]
 #define _rdseedxx_step(_p) _rdseed64_step( (UINT64  *) (_p) )
                            ^~~~~~~~~~~~~~
/__w/1/SymCrypt/lib/rdseed.c:40:7: note: in expansion of macro '_rdseedxx_step'
   if( _rdseedxx_step( p ) != 0 )
       ^~~~~~~~~~~~~~


[ 98%] Built target symcryptunittest_lib
Scanning dependencies of target symcryptunittest
[ 99%] Building CXX object unittest/exe_linux/CMakeFiles/symcryptunittest.dir/main_exe.cpp.o
[ 99%] Linking CXX executable ../../exe/AMD64/LinuxUserMode/symcryptunittest
/usr/bin/ld: ../../lib/AMD64/LinuxUserMode/libsymcrypt_common.a(rdseed.c.o): in function `SymCryptRdseedSizet':
/__w/1/SymCrypt/lib/rdseed.c:40: undefined reference to `_rdseed64_step'
collect2: error: ld returned 1 exit status
make[2]: *** [unittest/exe_linux/CMakeFiles/symcryptunittest.dir/build.make:86: exe/AMD64/LinuxUserMode/symcryptunittest] Error 1
make[1]: *** [CMakeFiles/Makefile2:433: unittest/exe_linux/CMakeFiles/symcryptunittest.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
##[error]Bash exited with code '2'.

See detail: https://dev.azure.com/mssonic/build/_build/results?buildId=22857&view=logs&j=12f1170f-54f2-53f3-20dd-22fc7dff55f9&t=59a85588-b0ba-5043-24c4-d9e29d89c6f6

To reproduce it, only need to build it in debian:buster docker image.

Analysis:

#include <immintrin.h>

/usr/lib/gcc/x86_64-linux-gnu/8/include/rdseedintrin.h:# error "Never use <rdseedintrin.h> directly; include <x86intrin.h> instead."

/usr/lib/gcc/x86_64-linux-gnu/9/include/rdseedintrin.h:# error "Never use <rdseedintrin.h> directly; include <immintrin.h> instead."

For GCC <=8, need to change to include <x86intrin.h>
See gcc-mirror/gcc@59a9514

Workaround:

cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake-toolchain/LinuxUserMode-AMD64.cmake -DCMAKE_C_FLAGS="-D_rdseed64_step=__builtin_ia32_rdseed_di_step"

Support request:

GCC 8 is used by debian:buster, which is the latest version of debian currently. Could you please help support it?

@xumia apologies for not replying to this earlier - support for Debian/older versions of GCC hasn't been a priority for us. It looks like the current stable version of Debian is now "bullseye." Is this change still needed?

xumia commented

@mlindgren , we have changed to use bullseye, not necessary to support the earlier version for us, thanks.